public function deletecategory() { $categoryid = Input::get('categoryid'); $usercategory = userinterestModel::where('interest_id', $categoryid)->get()->count(); $contestcategory = contestinterestModel::where('category_id', $categoryid)->get()->count(); if ($usercategory > 0 || $contestcategory > 0) { $er_data = 'This category is used. So not able to delete '; return Redirect::to('category')->with('er_data', $er_data); } else { $deletecategory = InterestCategoryModel::where('Interest_id', $categoryid)->delete(); if ($deletecategory) { $er_data = 'Category deleted successfully'; return Redirect::to('category')->with('er_data', $er_data); } } }
public function contestdelete() { $data = Input::get('contestid'); $searchkey = Input::get('searchkey'); /// Contest details ///// $contestdetailsformail = contestModel::select('user.firstname', 'user.lastname', 'user.username', 'contest.contest_name', 'contest.contesttype', 'user.email', 'contest.themephoto')->LeftJoin('user', 'user.ID', '=', 'contest.createdby')->where('contest.ID', $data)->first(); $contestname = $contestdetailsformail->contest_name; $contesttype = $contestdetailsformail->contesttype; if ($contestdetailsformail->firstname != '') { $name = $contestdetailsformail->firstname . ' ' . $contestdetailsformail->lastname; } else { $name = $contestdetailsformail->username; } $contest_id = $data; $email = $contestdetailsformail->email; $details = "Your contest " . $contestname . " is deleted by admin."; $contestimage = $contestdetailsformail->themephoto; $contestdetails = contestparticipantModel::where('contest_id', $data)->get(); for ($i = 0; $i < count($contestdetails); $i++) { $contestparticipantid = $contestdetails[$i]['ID']; $comment = commentModel::select('id')->where('contest_participant_id', $contestparticipantid)->get(); for ($i = 0; $i < count($comment); $i++) { $replycmt = replycommentModel::where('comment_id', $comment[$i]['id'])->get()->count(); if ($replycmt) { replycommentModel::where('comment_id', $comment[$i]['id'])->delete(); } } if (count($comment)) { commentModel::select('id')->where('contest_participant_id', $contestparticipantid)->delete(); } $votingcnt = votingModel::where('contest_participant_id', $contestparticipantid)->get()->count(); if ($votingcnt) { votingModel::where('contest_participant_id', $contestparticipantid)->delete(); } $participantid = contestparticipantModel::where('ID', $contestparticipantid)->get()->count(); if ($participantid) { $delete = contestparticipantModel::where('ID', $contestparticipantid)->delete(); } } $contestcatgory = contestinterestModel::where('contest_id', $data)->count(); if ($contestcatgory) { contestinterestModel::where('contest_id', $data)->delete(); } $deleteinvitecontest = invitegroupforcontestModel::where('contest_id', $data)->count(); if ($deleteinvitecontest) { invitegroupforcontestModel::where('contest_id', $data)->delete(); } $deletefollowercontest = invitefollowerforcontestModel::where('contest_id', $data)->count(); if ($deletefollowercontest) { invitefollowerforcontestModel::where('contest_id', $data)->delete(); } $privatecontestdelete = privateusercontestModel::where('contest_id', $data)->count(); if ($privatecontestdelete) { privateusercontestModel::where('contest_id', $data)->delete(); } $deletecontest = contestModel::where('ID', $data)->delete(); if ($deletecontest) { $this->contestchangesmaildelete($email, $name, $contestname, $contest_id, $contestimage, $details); } $er_data['message'] = 'Contest removed successfully'; return Redirect::to('managecontest')->with('er_data', $er_data)->with('usercontestlist', '')->with('searchkey', $searchkey); }
?> value="{{ isset($old_data['prize'])?$old_data['prize']:$contestdetails['prize'] }}" class="radius pfix_mar" /> </p>--> <p> <!--<div class="inp_pfix"><img src="img/gender_icons.png" width="25" height="25"></div>--> <textarea name="description" cols="" rows="" class="radius" placeholder="Contest Information" title="Contest Information">{{ isset($old_data['description'])?$old_data['description']:$contestdetails['description'] }}</textarea> </p> </legend> <legend class="radius"><div class="leg_head"><span id="txt_favorite">Favorite</span></div> <p> <div class="inp_pfix mbmtop"><img src="{{ URL::to($assets_path.'img/interest_icons.png')}}" width="25" height="25"></div> <?php $interestList = InterestCategoryModel::where('status', 1)->lists('Interest_name', 'Interest_id'); $contestInterest = contestinterestModel::where('contest_id', $contest_id)->lists('category_id'); ?> {{ Form::select('interest[]', $interestList,$contestInterest, array('class'=>'SlectBox testsel radius','multiple'=>'multiple',(($noofparticipants>0)?'disabled':''),'placeholder'=>'Select Interest','onchange'=>'console.log($(this).children(":selected").length)')) }} </p> </legend> </div> <div class="loginform loginbox mar2"> <legend class="radius"><div class="leg_head"><span id="txt_contestschedule">Contest Schedule</span></div> <p> <div class="inp_pfix "><img src="{{ URL::to($assets_path.'img/date_icons.png')}}" width="25" height="25"></div> <input type="text" value="{{ isset($old_data['conteststartdate'])?date('m/d/Y h:i a',strtotime($old_data['conteststartdate'])):(timezoneModel::convert($contestdetails['conteststartdate'],'UTC',Auth::user()->timezone, 'm/d/Y h:i a')) }}" <?php if (Auth::user()->ID != 1) { if ($noofparticipants > 0 || $contestdetails['conteststartdate'] <= date('Y-m-d H:i:s')) { echo "disabled";
public function updatecontestmobile() { $inputdetails = Input::except(array('_token', 'themephoto', 'contestid', 'interest_id', 'userid', 'timezone')); $timezone = Input::get('timezone'); $inputdetails['conteststartdate'] = timezoneModel::convert(Input::get('conteststartdate'), $timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['contestenddate'] = timezoneModel::convert(Input::get('contestenddate'), $timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingstartdate'] = timezoneModel::convert(Input::get('votingstartdate'), $timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingenddate'] = timezoneModel::convert(Input::get('votingenddate'), $timezone, 'UTC', 'Y-m-d H:i:s'); if (Input::file('themephoto') != '') { $destinationPath = 'public/assets/upload/contest_theme_photo'; $filename = Input::file('themephoto')->getClientOriginalName(); $Image = str_random(8) . '_' . $filename; $inputdetails['themephoto'] = $Image; } $contestid = Input::get('contestid'); $updaterules = array('contest_name' => 'required|unique:contest,contest_name,' . $contestid, 'conteststartdate' => 'required', 'contestenddate' => 'required', 'votingstartdate' => 'required', 'votingenddate' => 'required', 'noofparticipant' => 'required', 'contesttype' => 'required'); $validation = Validator::make($inputdetails, $updaterules); if ($validation->passes()) { if (Input::file('themephoto') != '') { $file = Input::file('themephoto'); $uploadSuccess = $file->move($destinationPath, $Image); } $updatedata = $inputdetails; $affectedRows = contestModel::where('ID', $contestid)->update($updatedata); $interest_id = Input::get('interest_id'); $interestid = explode(',', $interest_id); $interestidcount = count($interestid); $interest['contest_id'] = $contestid; $deleteoldid = contestinterestModel::where('contest_id', $contestid)->delete(); for ($i = 0; $i < $interestidcount; $i++) { $interest['category_id'] = $interestid[$i]; //return $interest; $validationinterest = Validator::make($interest, contestinterestModel::$rules); if ($validationinterest->passes()) { $userregister = contestinterestModel::create($interest); } } $Response = array('success' => '1', 'message' => 'Record updated Successfully', 'msgcode' => "c109"); $final = array("response" => $Response); return json_encode($final); } else { $Response = array('success' => '0', 'message' => $validation->messages()->first(), 'msgcode' => "c115"); $final = array("response" => $Response); return json_encode($final); } }
public function update_contest() { $inputdetails = Input::except(array('_token', 'themephoto', 'sponsor', 'sponsorphoto', 'interest', 'contest_id', 'client_login', 'enable')); $contest_id = Input::get('contest_id'); if (Input::file('themephoto') != '') { $destinationPath_them = 'public/assets/upload/contest_theme_photo'; $filename_them = Input::file('themephoto')->getClientOriginalName(); $Image_them = str_random(8) . '_' . $filename_them; $inputdetails['themephoto'] = $Image_them; } $lantyp = Session::get('language'); if ($lantyp == "") { $lantyp = "value_en"; } $rules = array('contest_name' => 'required|unique:contest,contest_name,' . $contest_id, 'conteststartdate' => 'required', 'contestenddate' => 'required', 'votingstartdate' => 'required', 'votingenddate' => 'required', 'noofparticipant' => 'required', 'contesttype' => 'required'); if (Auth::user()->ID == 1) { $inputdetails['sponsorname'] = Input::get('sponsorname'); //return Input::file('sponsorphoto'); if (Input::file('sponsorphoto') != '') { $destinationPath_spons = 'public/assets/upload/sponsor_photo'; $filename_spons = Input::file('sponsorphoto')->getClientOriginalName(); $Image_spons = str_random(8) . '_' . $filename_spons; $inputdetails['sponsorphoto'] = $Image_spons; } } $usertimezone = contestModel::select('user.email', 'user.timezone', 'user.firstname', 'user.lastname', 'user.username', 'contest.contest_name', 'contest.themephoto')->LeftJoin('user', 'user.ID', '=', 'contest.createdby')->where('contest.ID', $contest_id)->first(); $validation = Validator::make($inputdetails, $rules); if ($validation->passes()) { if (Auth::user()->ID == 1) { $admintimezone = User::where('ID', 1)->get()->first(); $inputdetails['conteststartdate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['conteststartdate'])), $admintimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['contestenddate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['contestenddate'])), $admintimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingstartdate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['votingstartdate'])), $admintimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingenddate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['votingenddate'])), $admintimezone->timezone, 'UTC', 'Y-m-d H:i:s'); } else { $inputdetails['conteststartdate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['conteststartdate'])), $usertimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['contestenddate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['contestenddate'])), $usertimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingstartdate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['votingstartdate'])), $usertimezone->timezone, 'UTC', 'Y-m-d H:i:s'); $inputdetails['votingenddate'] = timezoneModel::convert(date('Y-m-d H:i:s', strtotime($inputdetails['votingenddate'])), $usertimezone->timezone, 'UTC', 'Y-m-d H:i:s'); } //$inputdetails['visibility']="p"; if (Auth::user()->ID == 1) { $inputdetails['visibility'] = Input::get('visibility'); } else { $inputdetails['visibility'] = "p"; } $interest = Input::get('interest'); $interest_length = sizeof(Input::get('interest')); if ($interest_length > 0) { contestinterestModel::whereNotIn('category_id', $interest)->where('contest_id', '=', $contest_id)->delete(); for ($i = 0; $i < $interest_length; $i++) { $interes['contest_id'] = $contest_id; $interes['category_id'] = $interest[$i]; $userInterest = contestinterestModel::where('contest_id', $contest_id)->where('category_id', $interest[$i])->lists('category_id'); if (count($userInterest) < 1) { contestinterestModel::create($interes); } unset($interes); } } else { contestinterestModel::where('contest_id', '=', $contest_id)->delete(); } $file_them = Input::file('themephoto'); $file_spons = Input::file('sponsorphoto'); if (isset($inputdetails['sponsorphoto'])) { $uploadSuccess_spons = $file_spons->move($destinationPath_spons, $Image_spons); } if (isset($inputdetails['themephoto'])) { $uploadSuccess_them = $file_them->move($destinationPath_them, $Image_them); } contestModel::where('ID', $contest_id)->update($inputdetails); if (Auth::user()->ID == 1) { if ($usertimezone->firstname != '') { $name = $usertimezone->firstname . ' ' . $usertimezone->lastname; } else { $name = $usertimezone->username; } $contestname = $usertimezone->contest_name; $themephoto = $usertimezone->themephoto; $email = $usertimezone->email; if ($usertimezone->createdby != 1) { $contestdetailsformail = contestModel::select('user.email', 'user.timezone', 'user.firstname', 'user.lastname', 'user.username', 'contest.contest_name', 'contest.themephoto', 'contest.description', 'contest.noofparticipant', 'contest.conteststartdate', 'contest.contestenddate', 'contest.votingstartdate', 'contest.votingenddate', 'contest.contesttype', 'contest.visibility', 'contest.status', 'contest.sponsorname')->LeftJoin('user', 'user.ID', '=', 'contest.createdby')->where('contest.ID', $contest_id)->first(); if ($contestdetailsformail->status == 1) { $status = "Active"; } else { $status = "Inactive"; } if ($contestdetailsformail->visibility == "p") { $visibility = "Private"; } else { $visibility = "Public"; } $timezone = $contestdetailsformail->timezone; if ($contestdetailsformail->contesttype == "p") { $contesttype = "Photo"; } elseif ($contestdetailsformail->contesttype == "v") { $contesttype = "Video"; } else { $contesttype = "Topic"; } $details = '<div styel"float:left;"> <table width="500" height="95" border="1" style="margin-bottom:10px;float:left;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;"> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Contest Name:</td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $contestdetailsformail->contest_name . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Contest Image:</td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;"><img src=' . URL::to('public/assets/upload/contest_theme_photo/' . $contestdetailsformail->themephoto) . ' width="150" height="150" /></td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Contest Type:</td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $contesttype . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Status </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $status . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Contest Start date </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . timezoneModel::convert($contestdetailsformail->conteststartdate, 'UTC', $timezone, 'd-m-Y H:i:s') . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Contest end date </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . timezoneModel::convert($contestdetailsformail->contestenddate, 'UTC', $timezone, 'd-m-Y H:i:s') . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Voting start date </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . timezoneModel::convert($contestdetailsformail->votingstartdate, 'UTC', $timezone, 'd-m-Y H:i:s') . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Voting end date </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . timezoneModel::convert($contestdetailsformail->votingenddate, 'UTC', $timezone, 'd-m-Y H:i:s') . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Visibility </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $visibility . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">Sponsor </td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $contestdetailsformail->sponsorname . '</td> </tr> <tr> <td style="font-size:12px;color: #3BBA00;font-weight:bold;">No of participant</td> <td style="font-size:12px;color: #5d5d5d;font-weight:bold;">' . $contestdetailsformail->noofparticipant . '</td> </tr> </table> </div>'; $this->editcontestmail($email, $name, $contestname, $themephoto, $contest_id, $details); } $er_data['Message'] = 'Updated successfully'; return Redirect::to('edit_contest/' . $contest_id)->with('er_data', $er_data); } else { return Redirect::to('/contest_info/' . $contest_id); } } else { if ($validation->messages()->first('contest_name') == "The contest name field is required.") { $er_msg_con_name = "The Contest Name field is required."; } else { $er_msg_con_name = $validation->messages()->first('contest_name'); } if ($validation->messages()->first('conteststartdate') == "The conteststartdate field is required.") { $er_msg_con_start = "The Contest Start Date field is required."; } else { $er_msg_con_start = $validation->messages()->first('conteststartdate'); } if ($validation->messages()->first('contestenddate') == "The contestenddate field is required.") { $er_msg_con_end = "The Contest End Date field is required."; } else { $er_msg_con_end = $validation->messages()->first('contestenddate'); } if ($validation->messages()->first('votingstartdate') == "The votingstartdate field is required.") { $er_msg_vote_start = "The Voting Start Date field is required."; } else { $er_msg_vote_start = $validation->messages()->first('votingstartdate'); } if ($validation->messages()->first('votingenddate') == "The votingenddate field is required.") { $er_msg_vote_end = "The Voting End Date field is required."; } else { $er_msg_vote_end = $validation->messages()->first('votingenddate'); } if ($validation->messages()->first('noofparticipant') == "The noofparticipant field is required.") { $er_msg_noof_part = "The No of Participant field is required."; } else { $er_msg_noof_part = $validation->messages()->first('noofparticipant'); } if ($validation->messages()->first('contesttype') == "The contesttype field is required.") { $er_msg_con_type = "The Contest Type field is required."; } else { $er_msg_con_type = $validation->messages()->first('contesttype'); } $languageDetails = languageModel::select($lantyp, 'ctrlCaptionId')->whereIn('value_en', [$er_msg_con_name, $er_msg_con_start, $er_msg_con_end, $er_msg_vote_start, $er_msg_vote_end, $er_msg_noof_part, $er_msg_con_type])->get()->toArray(); //return $validation->messages(); foreach ($languageDetails as $key => $val) { if (in_array($val['ctrlCaptionId'], ['alert_entercontestname', 'alert_alreadycontestname'])) { $er_data['contest_name'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_enterconteststartdate'])) { $er_data['conteststartdate'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_contestenddate'])) { $er_data['contestenddate'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_votingstartdate'])) { $er_data['votingstartdate'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_votingenddate'])) { $er_data['votingenddate'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_enternoofpartis'])) { $er_data['noofparticipant'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } elseif (in_array($val['ctrlCaptionId'], ['alert_entercontesttype'])) { $er_data['contesttype'] = "<span id='" . $val['ctrlCaptionId'] . "'>" . $val[$lantyp] . "</span>"; } } return Redirect::to('edit_contest/' . $contest_id)->with('er_data', $er_data)->with('old_data', $inputdetails); } }