Example #1
1
 /**
  * @param array $parameters
  *
  * @return string
  */
 public static function render(array $parameters)
 {
     list($sortColumn, $sortParameter, $title, $queryParameters) = self::parseParameters($parameters);
     $title = self::applyFormatting($title);
     $icon = Config::get('columnsortable.default_icon_set');
     foreach (Config::get('columnsortable.columns') as $value) {
         if (in_array($sortColumn, $value['rows'])) {
             $icon = $value['class'];
         }
     }
     if (Request::get('sort') == $sortParameter && in_array(Request::get('order'), ['asc', 'desc'])) {
         $icon .= Request::get('order') === 'asc' ? Config::get('columnsortable.asc_suffix', '-asc') : Config::get('columnsortable.desc_suffix', '-desc');
         $direction = Request::get('order') === 'desc' ? 'asc' : 'desc';
     } else {
         $icon = Config::get('columnsortable.sortable_icon');
         $direction = Config::get('columnsortable.default_direction_unsorted', 'asc');
     }
     $iconAndTextSeparator = Config::get('columnsortable.icon_text_separator', '');
     $clickableIcon = Config::get('columnsortable.clickable_icon', false);
     $trailingTag = $iconAndTextSeparator . '<i class="' . $icon . '"></i>' . '</a>';
     if ($clickableIcon === false) {
         $trailingTag = '</a>' . $iconAndTextSeparator . '<i class="' . $icon . '"></i>';
     }
     $anchorClass = self::getAnchorClass();
     $queryString = http_build_query(array_merge($queryParameters, array_filter(Request::except('sort', 'order', 'page')), ['sort' => $sortParameter, 'order' => $direction]));
     return '<a' . $anchorClass . ' href="' . url(Request::path() . '?' . $queryString) . '"' . '>' . htmlentities($title) . $trailingTag;
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     session_start();
     $loguser = $_SESSION['user_id'];
     $input = Request::except('tax');
     //        var_dump($input);
     //
     //        die();
     if (isset($_GET['cid'])) {
         $input['contact_id'] = $_GET['cid'];
         $input['customer_id'] = $_GET['cid'];
     } else {
         $input['contact_no'] = $input['cli'];
         $input['contact_owner'] = $loguser;
         $input['contact_id'] = App\contact::create($input)->id;
         $input['customer_id'] = $input['contact_id'];
     }
     $input['call_owner'] = $loguser;
     $input['assignedto'] = $input['assignedto1'];
     $input['group_id'] = $input['group_id1'];
     $last_id = App\call_log::create($input)->id;
     $input['call_log_id'] = $last_id;
     if ($input['call_type'] == "Inquiry") {
         if ($input['status'] == "complete") {
             $endtime = date('Y-m-d H:i:s');
         } else {
             $endtime = NULL;
         }
         $input['inquiry_end_time'] = $endtime;
         App\inquiry::create($input);
     } elseif ($input['call_type'] == "Sales") {
         $input['owner_id'] = $loguser;
         $input['total'] = $_POST['sub_total'];
         $sale = App\sale::create($input);
         $last_id1 = $sale->id;
         //$log = new crm_log;
         //$log->add_log("sales",$last_id1,"insert"); // add a log
         $cart_details = App\cart::where('user', $loguser)->get();
         foreach ($cart_details as $row4) {
             // select data from cart table
             $input = ['category' => $row4->category, 'product' => $row4->product, 'price' => $row4->price, 'sale_id' => $last_id1, 'qty' => $row4->qty, 'tax' => $row4->tax, 'discount' => $row4->discount];
             $last_sp_id = DB::table('sales_product')->insertGetId($input);
             //$sql5="INSERT INTO `sales_product`(`id`, `category`, `product`,`price`,`sale_id`, `qty`, `tax`, `discount`) VALUES(NULL,'$row4[category]','$row4[product]','$row4[price]','$last_id1','$row4[qty]','$row4[tax]','$row4[discount]')";
             $cart_tax_details = App\cart_tax::where('cart_id', $row4->id)->get();
             foreach ($cart_tax_details as $row6) {
                 $sql_s = "INSERT INTO `s_p_tax`(`s_p_id`, `tax_id`, `tax_name`, `tax_value`, `user`) VALUES ('{$last_sp_id}','{$row6->tax_id}','{$row6->tax_name}','{$row6->tax_value}','{$loguser}')";
                 DB::insert(DB::raw($sql_s));
                 // add data to sales product tax table
             }
         }
         $cart = new cart();
         $cart->delete_user_cart();
         // remove cart data
     } elseif ($input['call_type'] == "Tickets") {
         $input['owner'] = $loguser;
         $ticket_id = App\ticket::create($input)->id;
         $input['last_id_ticket'] = $ticket_id;
         App\ticket_problem::create($input);
     }
 }
Example #3
0
 /**
  * Updates a project with the entered info.
  *
  * @param \Gitamin\Models\Project $project
  *
  * @throws \Exception
  *
  * @return \Gitamin\Models\Project
  */
 public function postUpdateProject(Project $project)
 {
     if (!$project->update(Request::except(['_token']))) {
         throw new Exception(trans('dashboard.projects.edit.failure'));
     }
     return $project;
 }
 /**
  * Get paginated models.
  *
  * @param int   $page  Number of models per page
  * @param int   $limit Results per page
  * @param bool  $all   get published models or all
  * @param array $with  Eager load related models
  *
  * @return stdClass Object with $items && $totalItems for pagination
  */
 public function byPage($page = 1, $limit = 10, array $with = [], $all = false)
 {
     $cacheKey = md5(config('app.locale') . 'byPage.' . $page . $limit . $all . serialize(Request::except('page')));
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     $models = $this->repo->byPage($page, $limit, $with, $all);
     // Store in cache for next request
     $this->cache->put($cacheKey, $models);
     return $models;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Request::all();
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'password' => 'required', 'type' => 'required');
     $v = Validator::make($data, $rules);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors())->withInput(Request::except('password'));
     }
     //Otra manera
     //$user = new User($request->all());
     //$user->save();
     //return \Redirect::route('admin.users.index');
     $user = User::create($data);
     return redirect()->route('admin.users.index');
 }
Example #6
0
 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function loginPost()
 {
     $loginData = Request::only(['login', 'password']);
     // Login with username or email.
     $loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
     $loginData[$loginKey] = array_pull($loginData, 'login');
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         //return Redirect::intended('/')
         return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
     }
     return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
 }
Example #7
0
 /**
  * 统一返回格式
  * @param $msgcode
  * @param null $message
  * @param null $data
  * @return string
  */
 protected function encodeResult($msgcode, $message = NULL, $data = NULL)
 {
     if ($data == null) {
         $data = new \stdClass();
     }
     $log = new RestLog();
     $log->request = json_encode(Request::except('file'));
     $log->request_route = Route::currentRouteName();
     $log->response = json_encode($data);
     $log->msgcode = $msgcode;
     $log->message = $message;
     $log->client_ip = Request::getClientIp();
     $log->client_useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL;
     if (Auth::check()) {
         $log->user_id = Auth::user()->user_id;
     }
     $log->save();
     $result = array("rest_id" => $log->id, 'msgcode' => $msgcode, 'message' => $message, 'date' => $data, 'version' => '1.0', 'servertime' => time());
     return \Response::json($result);
 }
Example #8
0
 /**
  * Handle the unsubscribe.
  *
  * @param string|null $code
  *
  * @return \Illuminate\View\View
  */
 public function postSignup($code = null)
 {
     /*
     if ($code === null) {
         throw new NotFoundHttpException();
     }
     
     $invite = Invite::where('code', '=', $code)->first();
     
     if (!$invite || $invite->claimed()) {
         throw new BadRequestHttpException();
     }
     */
     $code = 'gitamin';
     try {
         $user = $this->dispatch(new SignupUserCommand(Request::get('username'), Request::get('password'), Request::get('email'), 2));
     } catch (ValidationException $e) {
         return Redirect::route('signup.signup', ['code' => $code])->withInput(Request::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('gitamin.signup.failure')))->withErrors($e->getMessageBag());
     } catch (UserAlreadyTakenException $e) {
         return Redirect::route('signup.signup', ['code' => $code])->withInput(Request::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('gitamin.signup.failure')))->withErrors(trans('gitamin.signup.taken'));
     }
     //$this->dispatch(new ClaimInviteCommand($invite));
     return Redirect::route('auth.login')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('gitamin.signup.success')));
 }
Example #9
0
File: Grid.php Project: reillo/grid
 /**
  * Create url for navigation
  *
  * @param array $parameters
  * @return string
  */
 public function createUrl(array $parameters = [])
 {
     $baseUrl = $this->getBaseURL();
     $parameters = array_merge(Request::except('ajax'), $parameters);
     // build url query string
     $query_string = http_build_query($parameters, null, '&');
     $raw_param = !empty($query_string) ? "?" . $query_string : null;
     return $baseUrl . $raw_param . $this->buildFragment();
 }
Example #10
0
 /**
  * Update the specified resource in storage. If it has been deleted, this will undelete it.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Comment $comment)
 {
     if (!Auth::user()->can('create-comments')) {
         abort(401, 'You do not have permission to update a comment');
     }
     if (!$comment) {
         abort(400, 'Comment does not exist');
     }
     if ($comment->user->id != Auth::user()->id && !Auth::user()->can('administrate-comment')) {
         abort(401, 'User does not have permission to edit this comment');
     }
     $comment->secureFill(Request::except('token'));
     if (!$comment->save()) {
         //Validation failed show errors
         abort(403, $comment->errors);
     }
     return $comment;
 }
Example #11
0
 /**
  * Updates the system settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     $redirectUrl = Session::get('redirect_to', route('admin.settings.general'));
     if (Request::get('remove_banner') === '1') {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Request::hasFile('app_banner')) {
         $file = Request::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::to($redirectUrl)->withErrors(trans('admin.settings.general.too-big', ['size' => $maxSize]));
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage());
         }
         if (!starts_with($file->getMimeType(), 'image/')) {
             return Redirect::to($redirectUrl)->withErrors(trans('admin.settings.general.images-only'));
         }
         // Store the banner.
         Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
         // Store the banner type
         Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
     }
     try {
         foreach (Request::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::to($redirectUrl)->withErrors(trans('admin.settings.edit.failure'));
     }
     if (Request::has('app_locale')) {
         Lang::setLocale(Request::get('app_locale'));
     }
     return Redirect::to($redirectUrl)->withSuccess(trans('admin.settings.edit.success'));
 }
Example #12
0
 /**
  * Get all models and nest.
  *
  * @param bool  $all  Show published or all
  * @param array $with Eager load related models
  *
  * @return NestedCollection
  */
 public function allNested(array $with = [], $all = false)
 {
     $cacheKey = md5(config('app.locale') . 'allNested' . serialize($with) . $all . serialize(Request::except('page')));
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     // Item not cached, retrieve it
     $models = $this->repo->allNested($with, $all);
     // Store in cache for next request
     $this->cache->put($cacheKey, $models);
     return $models;
 }
Example #13
0
 private function generateLink($direction)
 {
     $dt = $this->base_dt->copy();
     if ($this->mode == 'week') {
         $direction == 'prev' ? $dt->modify('last sunday') : $dt->modify('next sunday');
     } else {
         if ($this->mode == 'day') {
             $direction == 'prev' ? $dt->subDay() : $dt->addDay();
         } else {
             $dt = $direction == 'prev' ? $dt->modify('first day of previous month') : $dt->modify('first day of next month');
         }
     }
     $base_date = $this->mode == 'month' ? $dt->format('Y-m') : $dt->format('Y-m-d');
     $url = Request::url() . '?base_date=' . $base_date . '&' . http_build_query(Request::except('base_date'));
     $class = isset($this->classes[$direction]) ? $this->generateClass($this->classes[$direction]) : '';
     $onclick = '';
     if (!empty($this->navigation_js_function)) {
         $url = '#';
         $onclick = ' onclick="return ' . $this->navigation_js_function . '(\'' . $base_date . '\');"';
     }
     return '<a id="julius_' . $direction . '_' . $this->mode . '" href="' . $url . '"' . $class . ' data-date="' . $base_date . '"' . $onclick . '>' . $this->icons[$direction] . '</a>';
 }
Example #14
0
 private function getNeatnessUrls($current_key, $current_direction)
 {
     $original_params = [];
     if (isset($this->neatness['appends'])) {
         $original_params = Request::only($this->neatness['appends']);
     } else {
         $original_params = Request::except([$this->_neatness_order_by, $this->_neatness_direction]);
     }
     $urls = [];
     foreach ($this->neatness['columns'] as $key => $column) {
         $direction = $key == $current_key ? $this->getNeatnessReverseDirection($current_direction) : $this->neatness['default'][1];
         $params = $original_params + [$this->_neatness_order_by => $key, $this->_neatness_direction => $direction];
         $urls[$key] = Request::url() . '?' . http_build_query($params);
     }
     return collect($urls);
 }
Example #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     session_start();
     $loguser = $_SESSION['user_id'];
     $data = Request::except('tax');
     $data['customer_id'] = $_SESSION['contact_report_to'];
     $data['call_log_id'] = 0;
     $data['owner_id'] = $loguser;
     $data['total'] = $_POST['sub_total'];
     $sale = App\sale::create($data);
     $last_id1 = $sale->id;
     //$sql3="INSERT INTO `sales`(`id`,`call_log_id`, `customer_id`, `category_id`,`product_id`, `qty`, `owner_id`, `created_time`, `modified_by`, `modified_time`, `assignedto`, `tax`, `discount`, `total`, `status`,  `account_id`, `date`, `remark`,`group`) VALUES
     //(NULL,'0','$_SESSION[contact_report_to]',NULL,NULL,NULL,'$loguser',SYSDATE(),NULL,NULL,'$_POST[assigned_to]',NULL,NULL,'$_POST[sub_total]','$_POST[status]',NULL,'$_POST[date]','$_POST[remark1]','$_POST[group_id]')";
     //$log = new crm_log;
     //$log->add_log("sales",$last_id1,"insert"); // add a log
     $cart_details = App\cart::where('user', $loguser)->get();
     foreach ($cart_details as $row4) {
         // select data from cart table
         $data = ['category' => $row4->category, 'product' => $row4->product, 'price' => $row4->price, 'sale_id' => $last_id1, 'qty' => $row4->qty, 'tax' => $row4->tax, 'discount' => $row4->discount];
         $last_sp_id = DB::table('sales_product')->insertGetId($data);
         //$sql5="INSERT INTO `sales_product`(`id`, `category`, `product`,`price`,`sale_id`, `qty`, `tax`, `discount`) VALUES(NULL,'$row4[category]','$row4[product]','$row4[price]','$last_id1','$row4[qty]','$row4[tax]','$row4[discount]')";
         $cart_tax_details = App\cart_tax::where('cart_id', $row4->id)->get();
         foreach ($cart_tax_details as $row6) {
             $sql_s = "INSERT INTO `s_p_tax`(`s_p_id`, `tax_id`, `tax_name`, `tax_value`, `user`) VALUES ('{$last_sp_id}','{$row6->tax_id}','{$row6->tax_name}','{$row6->tax_value}','{$loguser}')";
             DB::insert(DB::raw($sql_s));
             // add data to sales product tax table
         }
     }
     App\cart::where('user', $loguser)->delete();
     App\cart_tax::where('user', $loguser)->delete();
     return redirect('sale');
 }
 /**
  * Update item.
  *
  * @return \Modules\Articles\Entities\Article
  */
 public function update($id, &$context)
 {
     $article = $this->findById($id);
     if (Request::method() == 'PATCH') {
         // restore
         if (Request::has('restore') && (int) Request::get('restore')) {
             $article->restore();
             $context = 'restored';
             return $article;
         } else {
             $data = array_merge($article->toArray(), Request::except($this->publishing_columns));
             // exclude missing keys
             $domain_data = CoreRequest::only($this->publishing_columns);
             // process domain data
             $article_data = is_null($article->data) ? [] : $article->data->toArray();
             $domain_data = array_merge(Arr::only($article_data, $this->publishing_columns), $domain_data);
         }
     } else {
         $input = Request::except($this->publishing_columns);
         $domain_data = Request::only($this->publishing_columns);
         // validate
         $data = $this->validate($input, $article->id);
         // slug is slug
         $data['slug'] = Str::slug(Arr::get($data, 'slug') ?: $data['title']);
     }
     // update
     $article->update($data);
     //
     // update data
     //
     // create
     if (is_null($article->data)) {
         (new ArticleDomainDataRepository())->create($article->toArray() + $domain_data);
     } else {
         $article->data()->update(ArticleDomainDataRepository::validate($domain_data) + ['modified_by' => Request::header('UID', 0)]);
         $article->data()->touch();
     }
     return $article;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $data = $request->except('id', '_token');
     Permission::findOrFail($id)->update($data);
     return $this->toIndex();
 }