Beispiel #1
0
 protected function _channel_influencer()
 {
     try {
         $id = $this->input->post('id');
         $campaign = new Campaign($id);
         $cinfo = $campaign->get();
         if (!$cinfo) {
             throw new \Exception('Invalid campaign');
         }
         if (!($influencer = $this->input->post('influencer'))) {
             throw new \Exception('Invalid influencer');
         }
         $comment = $this->input->post('comment');
         if (empty($comment)) {
             throw new \Exception('Comment must not be empty');
         }
         $comments = MongoDoc::get($cinfo, 'comments.brand_influencer', array());
         if (!isset($comments[$influencer])) {
             $comments[$influencer] = array();
         }
         $comments[$influencer][] = array('from' => UserSession::get('user._id'), 'from_username' => UserSession::get('user.username'), 'user' => 'brand', 'created_at' => time(), 'text' => $comment);
         $comments[$influencer] = array_slice($comments[$influencer], -20);
         $campaign->update(array('comments.brand_influencer' => $comments));
         Alert::once('success', 'Comment added', Url::referrer());
     } catch (\Exception $e) {
         Alert::once('error', $e->getMessage(), Url::referrer());
     }
 }
Beispiel #2
0
 public function get($id)
 {
     $campaign = new Campaign($id);
     $cinfo = $campaign->get();
     if (!$cinfo) {
         $this->_404('Invalid campaign');
     }
     $this->_display->view(array('main/app/admin/campaign/view.php'), array('campaign' => $cinfo));
 }
Beispiel #3
0
 public function get($id)
 {
     $campaign = new Campaign($id);
     $this->_display->view(array('main/app/influencer/campaign/view.php'), array('campaign' => $campaign->get()));
 }
 public function campaign_bulk(Request $request)
 {
     //        return dd($request->all());
     if (Auth::check()) {
         if (in_array('ADD_EDIT_CAMPAIGN', $this->permission)) {
             $validate = $this->validation($request);
             if ($validate->passes()) {
                 $usr_company = $this->user_company();
                 $audit = new AuditsController();
                 $audit_key = $audit->generateRandomString();
                 if ($request->input('advertiser_id') == 'all' and !$request->has('campaign_list')) {
                     if ($request->input('client_id') == 'all') {
                         if (User::isSuperAdmin()) {
                             $campaign_list = Campaign::get(['id'])->toArray();
                         } else {
                             $campaign_list = Campaign::whereHas('getAdvertiser', function ($q) use($usr_company) {
                                 $q->whereHas('GetClientID', function ($p) use($usr_company) {
                                     $p->whereIn('user_id', $usr_company);
                                 });
                             })->get(['id'])->toArray();
                         }
                     } elseif ($request->input('client_id') != 'all') {
                         if (User::isSuperAdmin()) {
                             $campaign_list = Campaign::whereHas('getAdvertiser', function ($q) use($request) {
                                 $q->where('client_id', $request->input('client_id'));
                             })->get(['id'])->toArray();
                         } else {
                             ////////////////////////
                             $campaign_list = Campaign::whereHas('getAdvertiser', function ($q) use($usr_company, $request) {
                                 $q->whereHas('GetClientID', function ($p) use($usr_company, $request) {
                                     $p->where('id', $request->input('client_id'))->whereIn('user_id', $usr_company);
                                 });
                             })->get(['id'])->toArray();
                         }
                     }
                 } elseif ($request->input('advertiser_id') != 'all' and !$request->has('campaign_list')) {
                     if (User::isSuperAdmin()) {
                         $campaign_list = Campaign::whereHas('getAdvertiser', function ($q) use($request) {
                             $q->where('id', $request->input('advertiser_id'));
                         })->get(['id'])->toArray();
                     } else {
                         ////////////////////////
                         $campaign_list = Campaign::whereHas('getAdvertiser', function ($q) use($usr_company, $request) {
                             $q->where('id', $request->input('advertiser_id'))->whereHas('GetClientID', function ($p) use($usr_company, $request) {
                                 $p->whereIn('user_id', $usr_company);
                             });
                         })->get(['id'])->toArray();
                     }
                 } else {
                     $campaign_list = explode(',', $request->input('campaign_list'));
                 }
                 if (count($campaign_list) > 0) {
                     foreach ($campaign_list as $index) {
                         $data = array();
                         if (!$request->has('campaign_list')) {
                             $campaign_id = $index['id'];
                             $campaign = Campaign::find($campaign_id);
                         } else {
                             $campaign_id = $index;
                             if (User::isSuperAdmin()) {
                                 $campaign = Campaign::find($campaign_id);
                             } else {
                                 $usr_company = $this->user_company();
                                 $campaign = Campaign::whereHas('getAdvertiser', function ($q) use($usr_company) {
                                     $q->whereHas('GetClientID', function ($p) use($usr_company) {
                                         $p->whereIn('user_id', $usr_company);
                                     });
                                 })->find($campaign_id);
                             }
                         }
                         if ($campaign) {
                             if ($request->has('date_range')) {
                                 $check_date = $this->date_validation($request->input('date_range'));
                                 if (!$check_date) {
                                     return Redirect::back()->withErrors(['success' => false, 'msg' => 'please check your date range!']);
                                 }
                                 $date_range = explode('-', $request->input('date_range'));
                                 $start_date = Carbon::createFromFormat('m/d/Y', str_replace(' ', '', $date_range[0]))->toDateString();
                                 $end_date = Carbon::createFromFormat('m/d/Y', str_replace(' ', '', $date_range[1]))->toDateString();
                             }
                             if ($request->has('name')) {
                                 array_push($data, 'Name');
                                 array_push($data, $request->input('name'));
                                 $campaign->name = $request->input('name');
                             }
                             if ($request->has('active')) {
                                 $active = 'Inactive';
                                 if ($request->input('active') == 'on') {
                                     $active = 'Active';
                                 }
                                 array_push($data, 'Status');
                                 array_push($data, $active);
                                 $campaign->status = $active;
                             }
                             if ($request->has('max_impression')) {
                                 array_push($data, 'Max Imps');
                                 array_push($data, $request->input('max_impression'));
                                 $campaign->max_impression = $request->input('max_impression');
                             }
                             if ($request->has('daily_max_impression')) {
                                 array_push($data, 'Daily Max Imps');
                                 array_push($data, $request->input('daily_max_impression'));
                                 $campaign->daily_max_impression = $request->input('daily_max_impression');
                             }
                             if ($request->has('max_budget')) {
                                 array_push($data, 'Max Budget');
                                 array_push($data, $request->input('max_budget'));
                                 $campaign->max_budget = $request->input('max_budget');
                             }
                             if ($request->has('daily_max_budget')) {
                                 array_push($data, 'Daily Max Budget');
                                 array_push($data, $request->input('daily_max_budget'));
                                 $campaign->daily_max_budget = $request->input('daily_max_budget');
                             }
                             if ($request->has('cpm')) {
                                 array_push($data, 'CPM');
                                 array_push($data, $request->input('cpm'));
                                 $campaign->cpm = $request->input('cpm');
                             }
                             if ($request->has('advertiser_domain_name')) {
                                 array_push($data, 'Domain Name');
                                 array_push($data, $request->input('advertiser_domain_name'));
                                 $campaign->advertiser_domain_name = $request->input('advertiser_domain_name');
                             }
                             if ($request->has('description')) {
                                 array_push($data, 'Description');
                                 array_push($data, $request->input('description'));
                                 $campaign->description = $request->input('description');
                             }
                             if (isset($start_date)) {
                                 array_push($data, 'Start Date');
                                 array_push($data, $start_date);
                                 $campaign->start_date = $start_date;
                             }
                             if (isset($end_date)) {
                                 array_push($data, 'End Date');
                                 array_push($data, $end_date);
                                 $campaign->end_date = $end_date;
                             }
                             $audit->store('campaign', $campaign_id, $data, 'bulk_edit', $audit_key);
                             $campaign->save();
                         }
                     }
                     return Redirect::back()->withErrors(['success' => true, 'msg' => 'Campaigns Edited Successfully']);
                 }
             }
             return Redirect::back()->withErrors(['success' => false, 'msg' => $validate->messages()->all()])->withInput();
         }
         return Redirect::back()->withErrors(['success' => false, 'msg' => 'don\'t have Edit Permission']);
     }
     return Redirect::to(url('/user/login'));
 }