Exemplo n.º 1
0
 public function jqgrid(Request $request)
 {
     //        return dd($request->all());
     if (Auth::check()) {
         if (in_array('ADD_EDIT_GEOSEGMENTLIST', $this->permission)) {
             //permission goes here
             $rules = array('lat' => 'required', 'lon' => 'required', 'segment_radius' => 'required');
             if ($request->has('domain_name')) {
                 $rules['domain_name'] = 'required';
             } else {
                 $rules['name'] = 'required';
             }
             $validate = \Validator::make($request->all(), $rules);
             if ($validate->passes()) {
                 if (User::isSuperAdmin()) {
                     $geosegment = GeoSegmentList::find($request->input('parent_id'));
                 } else {
                     $usr_company = $this->user_company();
                     $geosegment = GeoSegmentList::whereHas('getAdvertiser', function ($q) use($usr_company) {
                         $q->whereHas('GetClientID', function ($p) use($usr_company) {
                             $p->whereIn('user_id', $usr_company);
                         });
                     })->find($request->input('parent_id'));
                 }
                 if ($geosegment) {
                     $audit = new AuditsController();
                     switch ($request->input('oper')) {
                         case 'add':
                             $geosegment = new GeoSegment();
                             $geosegment->name = $request->input('domain_name');
                             $geosegment->lat = $request->input('lat');
                             $geosegment->lon = $request->input('lon');
                             $geosegment->segment_radius = $request->input('segment_radius');
                             $geosegment->geosegmentlist_id = $request->input('parent_id');
                             $geosegment->save();
                             $audit->store('geosegmententrie', $geosegment->id, $request->input('parent_id'), 'add');
                             return $msg = ['success' => true, 'msg' => "your Geo Segment has been Added"];
                             break;
                         case 'edit':
                             $geosegmententries = GeoSegment::find($request->input('id'));
                             $data = array();
                             if ($geosegmententries->name != $request->input('name')) {
                                 array_push($data, 'name');
                                 array_push($data, $geosegmententries->name);
                                 array_push($data, $request->input('name'));
                                 $geosegmententries->name = $request->input('name');
                             }
                             if ($geosegmententries->lat != $request->input('lat')) {
                                 array_push($data, 'lat');
                                 array_push($data, $geosegmententries->lat);
                                 array_push($data, $request->input('lat'));
                                 $geosegmententries->lat = $request->input('lat');
                             }
                             if ($geosegmententries->lon != $request->input('lon')) {
                                 array_push($data, 'lon');
                                 array_push($data, $geosegmententries->lon);
                                 array_push($data, $request->input('lon'));
                                 $geosegmententries->lon = $request->input('lon');
                             }
                             if ($geosegmententries->segment_radius != $request->input('segment_radius')) {
                                 array_push($data, 'Segment Radius');
                                 array_push($data, $geosegmententries->segment_radius);
                                 array_push($data, $request->input('segment_radius'));
                                 $geosegmententries->segment_radius = $request->input('segment_radius');
                             }
                             $geosegmententries->save();
                             $audit->store('geosegmententrie', $request->input('id'), $data, 'edit');
                             return $msg = ['success' => true, 'msg' => "your Geo Segment has been Edited"];
                             break;
                         case 'del':
                             $audit = new AuditsController();
                             $d = array($request->input('id'), $request->input('parent_id'));
                             $audit->store('geosegmententrie', $request->input('id'), $d, 'del');
                             GeoSegment::where('id', $request->input('id'))->where('geosegmentlist_id', $request->input('parent_id'))->delete();
                             return $msg = ['success' => true, 'msg' => "your Geo Segment has been Deleted"];
                             break;
                     }
                 }
                 return $msg = ['success' => false, 'msg' => "Please Select a Geo Segment First"];
             }
             return $msg = ['success' => false, 'msg' => "Please fill all Fields"];
         }
         return $msg = ['success' => false, 'msg' => "You don't have permission"];
     }
     return Redirect::to('/user/login');
 }
Exemplo n.º 2
0
 public function SubAudit($audit)
 {
     $audit_obj = array();
     foreach ($audit as $index) {
         $entity_obj = null;
         switch ($index->entity_type) {
             case 'user':
                 if (in_array('VIEW_USER', $this->permission)) {
                     $entity_obj = User::find($index->entity_id);
                 }
                 break;
             case 'company':
                 if (User::isSuperAdmin()) {
                     $entity_obj = \App\Models\Company::find($index->entity_id);
                 }
                 break;
             case 'inventory':
                 if (User::isSuperAdmin()) {
                     $entity_obj = Inventory::find($index->entity_id);
                 }
                 break;
             case 'client':
                 if (in_array('VIEW_CLIENT', $this->permission)) {
                     $entity_obj = Client::find($index->entity_id);
                 }
                 break;
             case 'advertiser':
                 if (in_array('VIEW_ADVERTISER', $this->permission)) {
                     $entity_obj = Advertiser::with('GetClientID')->find($index->entity_id);
                 }
                 break;
             case 'creative':
                 if (in_array('VIEW_CREATIVE', $this->permission)) {
                     $entity_obj = Creative::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'campaign':
                 if (in_array('VIEW_CAMPAIGN', $this->permission)) {
                     $entity_obj = Campaign::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'offer':
                 if (in_array('VIEW_OFFER', $this->permission)) {
                     $entity_obj = Offer::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'pixel':
                 if (in_array('VIEW_PIXEL', $this->permission)) {
                     $entity_obj = Pixel::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'targetgroup':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     $entity_obj = Targetgroup::find($index->entity_id);
                 }
                 break;
             case 'targetgroup_geolocation_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = Geolocation::find($index->after_value);
                     } else {
                         $entity_obj = Geolocation::find($index->entity_id);
                     }
                 }
                 break;
             case 'targetgroup_creative_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = Creative::find($index->after_value);
                     } else {
                         $entity_obj = Creative::find($index->entity_id);
                     }
                 }
                 break;
             case 'targetgroup_segment_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = Segment::find($index->after_value);
                     } else {
                         $entity_obj = Segment::find($index->entity_id);
                     }
                 }
                 break;
             case 'targetgroup_geosegment_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = GeoSegmentList::find($index->after_value);
                     } else {
                         $entity_obj = GeoSegmentList::find($index->entity_id);
                     }
                 }
                 break;
             case 'targetgroup_bwlist_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = BWList::find($index->after_value);
                     } else {
                         $entity_obj = BWList::find($index->entity_id);
                     }
                 }
                 break;
             case 'targetgroup_bidprofile_map':
                 if (in_array('VIEW_TARGETGROUP', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = Bid_Profile::find($index->after_value);
                     } else {
                         $entity_obj = Bid_Profile::find($index->entity_id);
                     }
                 }
                 break;
             case 'geosegment':
                 if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) {
                     $entity_obj = GeoSegmentList::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'geosegmententrie':
                 if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = GeoSegment::find($index->after_value);
                     } else {
                         $entity_obj = GeoSegment::find($index->entity_id);
                     }
                 }
                 break;
             case 'bwlist':
                 if (in_array('VIEW_BWLIST', $this->permission)) {
                     $entity_obj = BWList::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'bwlistentrie':
                 if (in_array('VIEW_BWLIST', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = BWEntries::find($index->after_value);
                     } else {
                         $entity_obj = BWEntries::find($index->entity_id);
                     }
                 }
                 break;
             case 'bid_profile':
                 if (in_array('VIEW_BIDPROFILE', $this->permission)) {
                     $entity_obj = Bid_Profile::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'bid_profile_entry':
                 if (in_array('VIEW_BIDPROFILE', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = Bid_Profile::where('id', $index->after_value)->first();
                     } else {
                         $entity_obj = Bid_Profile_Entry::with('getParent')->find($index->entity_id);
                     }
                 }
                 break;
             case 'modelTable':
                 if (in_array('VIEW_MODEL', $this->permission)) {
                     if ($index->audit_type == 'del') {
                         $entity_obj = BWList::where('id', $index->after_value)->first();
                     } else {
                         $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) {
                             $q->with('GetClientID');
                         }])->find($index->entity_id);
                     }
                 }
                 break;
             case 'offer_pixel_map':
                 if (in_array('VIEW_OFFER', $this->permission)) {
                     $entity_obj = Pixel::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'advertiser_model_map':
                 if (in_array('VIEW_ADVERTISER', $this->permission)) {
                     $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'positive_offer_model':
                 if (in_array('VIEW_MODEL', $this->permission)) {
                     $entity_obj = Offer::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
             case 'negative_offer_model':
                 if (in_array('VIEW_MODEL', $this->permission)) {
                     $entity_obj = Offer::with(['getAdvertiser' => function ($q) {
                         $q->with('GetClientID');
                     }])->find($index->entity_id);
                 }
                 break;
         }
         if (!is_null($entity_obj)) {
             array_push($audit_obj, $index);
             array_push($audit_obj, $entity_obj);
         }
     }
     return $audit_obj;
 }