Ejemplo n.º 1
0
 public function edit($id)
 {
     if (Request::isMethod('get')) {
         $roles = UserRole::orderBy('id', 'desc')->get();
         $info = User::find($id);
         $cats = BlogCategory::where('lang_code', $info->userblog->lang_code)->get();
         $langs = Language::all();
         return view('admin.users.edit', array('cats' => $cats, 'langs' => $langs, 'info' => $info, 'roles' => $roles));
     }
     // POST
     parse_str(Request::input('data'));
     $category_save = implode(',', $category);
     $u = User::find($id);
     $u->name = $name;
     $u->address = $address;
     $u->zipcode = $zipcode;
     $u->city = $city;
     $u->phone = $phone;
     $u->cpr = $cpr;
     $u->role = $role;
     $u->account_number = $account_number;
     if ($password != null || $password != '') {
         $u->password = Hash::make($password);
     }
     $u->save();
     $info_update = array('blogname' => $blogname, 'domain' => $blogurl, 'lang_code' => $lang_code, 'blog_categories' => $category_save);
     UserBlog::where('user_id', $id)->update($info_update);
 }
Ejemplo n.º 2
0
 public function get_completed_blog_info($category_save, $lang_code, $blogname, $autoget)
 {
     $completed_data = json_decode($this->curl_backlink(Auth::user()->userblog->report_id));
     //// if done in linkresearchtools
     if ($completed_data->report->status == 'Done') {
         $num_of_inbound_link = $completed_data->report->pages->data[0][2];
         $num_of_star = round($num_of_inbound_link / 5);
         $total_star = $num_of_star + Auth::user()->userblog->star;
         if ($total_star > 18) {
             $star = 18;
         } else {
             $star = $total_star;
         }
         /// check if inbound link over - equal 500. email and marking in user list
         if ($num_of_inbound_link >= 500) {
             /// mail to user (under asking Tommy)
             $status_update = 2;
         } else {
             $status_update = 1;
         }
         /*
         	$status_update = 0 . not evaluation yet
         	$status_update = 1 . normal
         	$status_update = 2 . over 500
         */
         if (!$autoget) {
             $arg_update = array('star' => $star, 'inbound_link' => $num_of_inbound_link, 'status' => $status_update, 'blogname' => $blogname, 'blog_categories' => $category_save, 'lang_code' => $lang_code);
         } else {
             $arg_update = array('star' => $star, 'inbound_link' => $num_of_inbound_link, 'status' => $status_update);
         }
         $update_user_blog = UserBlog::where('user_id', Auth::user()->id)->update($arg_update);
     }
     /// else do nothing
 }
Ejemplo n.º 3
0
 public function index()
 {
     $exportExcel = Request::input('exportExcel');
     $lang = Request::input('lang');
     $status = Request::input('status');
     $period = Request::input('period');
     $period_to = Request::input('period_to');
     $data = array();
     $data['langs'] = Language::all();
     $users = User::where('role', '<>', 1)->get(array('id', 'name', 'cpr', 'account_number'));
     $list_user_assigns = array();
     $list_users_lang = array();
     /// filter by langs
     if ($lang && $lang == 'all' || !$lang) {
         foreach ($users as $k => $u) {
             $num = UserBlog::where('user_id', $u->id)->first();
             if ($num) {
                 $list_users_lang[$k] = $u;
                 $list_users_lang[$k]['star'] = $num->star;
                 $list_users_lang[$k]['lang_code'] = $num->lang_code;
                 $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value;
                 if (!$star_value) {
                     $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value;
                 }
                 $list_users_lang[$k]['star_value'] = $star_value;
                 $list_users_lang[$k]['total_amount'] = 0;
             }
         }
     } elseif ($lang && $lang != 'all') {
         foreach ($users as $k => $u) {
             $num = UserBlog::where('user_id', $u->id)->where('lang_code', $lang)->first();
             if ($num) {
                 $list_users_lang[$k] = $u;
                 $list_users_lang[$k]['star'] = $num->star;
                 $list_users_lang[$k]['lang_code'] = $num->lang_code;
                 $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value;
                 if (!$star_value) {
                     $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value;
                 }
                 $list_users_lang[$k]['star_value'] = $star_value;
                 $list_users_lang[$k]['total_amount'] = 0;
             }
         }
     }
     /// filter by status
     /// if status == all or dont isset status
     if ($status && $status == 'all' || !$status) {
         foreach ($list_users_lang as $k_u_l => $v_u_l) {
             /// if period = null, dont query by date
             if ($period == '' || !$period) {
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             } else {
                 // if isset period and period != null
                 $period = date('Y-m-d 00:00:00', strtotime($period));
                 $period_to = date('Y-m-d 23:59:59', strtotime($period_to));
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             }
             if (count($ua)) {
                 $list_user_assigns[$k_u_l] = $v_u_l;
                 $list_user_assigns[$k_u_l]['user_assignment'] = $ua;
                 foreach ($ua as $key_ua => $value_ua) {
                     $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value'];
                     $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'];
                 }
             }
         }
     } elseif ($status && $status != 'all') {
         foreach ($list_users_lang as $k_u_l => $v_u_l) {
             if ($period == '' || !$period) {
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             } else {
                 $period = date('Y-m-d 00:00:00', strtotime($period));
                 $period_to = date('Y-m-d 23:59:59', strtotime($period_to));
                 $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at'));
             }
             if (count($ua)) {
                 $list_user_assigns[$k_u_l] = $v_u_l;
                 $list_user_assigns[$k_u_l]['user_assignment'] = $ua;
                 foreach ($ua as $key_ua => $value_ua) {
                     $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value'];
                     $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'];
                 }
             }
         }
     }
     /// export excel
     if ($exportExcel) {
         return $this->exportExcel($list_user_assigns);
     }
     return view('admin.payment-list.index', array('users' => $list_user_assigns, 'langs' => $data['langs']));
 }