/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $zones = Zone::orderBy('id')->get();
     $status = array();
     foreach ($zones as $zone_count => $zone) {
         $count = $zone_count + 1;
         $switch_relays = $zone->Relays;
         if ($switch_relays->count()) {
             foreach ($switch_relays as $relay) {
                 $status['zone_' . $count . '_status_' . $relay->relay_id] = $relay->status;
             }
         } else {
             for ($i = 0; $i < 6; $i++) {
                 $status['zone_' . $count . '_status_' . $i] = 'False';
             }
         }
     }
     $data = array('page' => 'zones', 'zones' => $zones, 'status' => $status);
     return View::make('zones.index', $data);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $client = Client::where('id', $id)->withTrashed()->with('contacts')->first();
     $deptos = explode(',', DEPARTAMENTOS);
     $zones = Zone::orderBy('name', 'ASC')->get();
     $groups = Group::get();
     $businesses = BusinessType::get();
     $dias = array();
     $fec = str_split($client->frecuency);
     foreach ($fec as $d) {
         array_push($dias, $d == "1" ? true : false);
     }
     if ($client) {
         if ($client->deleted_at != null) {
             $client->restore();
         }
         $contacts = $client->contacts;
         $contactos = array();
         foreach ($contacts as $contact) {
             # code...
             $contactos[] = array('id' => $contact->id, 'nombres' => $contact->first_name, 'apellidos' => $contact->last_name, 'email' => $contact->email, 'phone' => $contact->phone);
             //
         }
         $data = ['client' => $client, 'contactos' => $contactos, 'url' => 'clientes/' . $id, 'title' => 'Editar Cliente', 'zonas' => $zones, 'deptos' => $deptos, 'grupos' => $groups, 'negocios' => $businesses, 'd' => $dias];
         $account = Account::find(Auth::user()->account_id);
         //data = array_merge($data, self::getViewModel());
         $data = array_merge($data, array('cuenta' => $account));
         // return Response::json($data);
         return View::make('clientes.edit', $data);
     }
     Session::flash('error', 'No existe el usuario');
     return Redirect::to('clientes');
 }