/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = User::find($id); $profile = Profile::find($user->profile_id); $user->delete(); $profile->delete(); if ($user->domain_id == NULL) { $domain = Domain::whereUserId($id)->first(); if ($domain) { $domain->delete(); $subuser = User::whereDomainId($domain->id)->first(); $subuser->delete(); PhoneNumber::whereUserId($subuser->id)->delete(); } } Event::fire('logger', array(array('account_remove', array('id' => $id, 'username' => $user->username), 2))); $path = Request::segment(4) ? 'domain/users/' . Request::segment(4) : 'users'; $path = $user->domain_id ? $path : "managers"; return Output::push(array('path' => $path, 'messages' => array('success' => _('User has been deleted')))); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function getDelete($id) { $domain = Domain::find($id); $domain->delete(); $user = User::whereDomainId($id)->first(); if ($user) { $user->delete(); $phone_number = PhoneNumber::whereUserId($user->id)->first(); $phone_number->delete(); Event::fire('logger', array(array('phone_number_remove', array('id' => $phone_number->id, 'extension' => $phone_number->extension), 2))); } Event::fire('logger', array(array('domain_remove', array('id' => $id, 'domain_name' => $domain->domain), 2))); return Output::push(array('path' => 'domain', 'messages' => array('success' => _('Domain has been deleted')))); }
public function getFilter() { $status = Auth::user()->status; if ($status == 2) { $call_detail_report = Cdr::all(); $condq = "created is not null"; } elseif ($status == 3) { $domain = Domain::whereUserId(Auth::user()->id)->get(array('sip_server')); $sip_server = array(); foreach ($domain as $row) { $sip_server[] = $row['sip_server']; } if ($sip_server) { $call_detail_report = $this->_orWhereIn('caller_domain', 'callee_domain', $sip_server); } else { $call_detail_report = []; } $condq = $this->_orGenerator('caller_domain', 'callee_domain', $sip_server); } else { $sip_server = Domain::find(Cookie::get('domain_hash'))->whereDomain(Request::getHttpHost())->get(array('sip_server')); $domainc = array(); foreach ($sip_server as $row) { $domainc[] = $row['sip_server']; } $extension_arr = PhoneNumber::whereUserId(Auth::user()->id)->get(array('extension')); $extension = array(); foreach ($extension_arr as $row) { $extension[] = $row['extension']; } $call_detail_report = $this->_orWhereInAnd('src_uri', 'dst_uri', $extension, 'caller_domain', 'callee_domain', $domainc); $condq = $this->_orGeneratorAnd('src_uri', 'dst_uri', $extension, 'caller_domain', 'callee_domain', $domainc); } $input = Input::only(array('datefilter', 'datefrom', 'dateto', 'timefilter', 'timefrom', 'timeto', 'durationparam', 'durationfilter', 'duration', 'fromfilter', 'from', 'tofilter', 'to')); $rules = array('datefrom' => 'required_with:datefilter', 'timefrom' => 'required_with:timefilter', 'duration' => 'required_with:durationfilter'); $v = Validator::make($input, $rules); if ($v->fails()) { return Output::push(array('path' => 'call_detail_reports', 'errors' => $v, 'input' => TRUE)); } $bulan_ayeuna = "AND YEAR(call_start_time) = YEAR(curdate()) AND MONTH(call_start_time) = MONTH(curdate()) "; if ($input['datefilter'] || $input['timefilter'] || $input['durationfilter'] || $input['fromfilter'] || $input['tofilter']) { $q = "select * from opensips.cdrs where "; $q = $q . "(" . $condq . ") "; if ($input['datefilter']) { if ($input['datefrom'] && $input['dateto']) { $fromdate = $this->_intlDate($input['datefrom']); $todate = $this->_intlDate($input['dateto']); $q = $q . "AND (date(call_start_time) BETWEEN '" . $fromdate . "' AND '" . $todate . "') "; } elseif ($input['datefrom'] && !$input['dateto']) { $fromdate = $this->_intlDate($input['datefrom']); $todate = date("Y-m-d"); $q = $q . "AND (date(call_start_time) >= '" . $fromdate . "') "; } } else { $q = $q . $bulan_ayeuna; } if ($input['timefilter']) { if ($input['timefrom'] && $input['timeto']) { $q = $q . "AND (time(call_start_time) BETWEEN '" . $input['timefrom'] . "' AND '" . $input['timeto'] . "') "; } elseif ($input['timefrom'] && !$input['timeto']) { $q = $q . "AND (time(call_start_time) >= "; $q = $q . "'" . $input['timefrom'] . "') "; } } if ($input['durationfilter']) { $duration = $this->_getDuration($input['duration']); $q = $q . "AND (duration " . $input['durationparam'] . " " . $duration . ") "; } if ($input['fromfilter']) { $fromarr = explode("@", $input['from']); if (!isset($fromarr[1])) { $fromarr[1] = null; } if ($fromarr[1] == null) { $q = $q . "AND (src_uri = '" . $input['from'] . "') "; } else { $q = $q . "AND (src_uri = '" . $fromarr[0] . "' and caller_domain = '" . $fromarr[1] . "') "; } } if ($input['tofilter']) { $toarr = explode("@", $input['to']); if (!isset($toarr[1])) { $toarr[1] = null; } if ($toarr[1] == null) { $q = $q . "AND (dst_uri = '" . $input['to'] . "') "; } else { $q = $q . "AND (dst_uri = '" . $toarr[0] . "' and callee_domain = '" . $toarr[1] . "') "; } } $q = $q . "order by call_start_time desc"; $results = []; $results = DB::connection('mysql2')->select($q); //print_r($q); return View::make('call_detail_reports.index')->with('call_detail_reports', $results); } else { return View::make('call_detail_reports.index')->with('call_detail_reports', $call_detail_report); } }