Esempio n. 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     // return View::make('register.confirm');
     $user = User::find($id);
     $serials = $user->serials()->get();
     //$installer = $user->installer()->first()->business_name;
     if ($user->installer_id) {
         $installer = Installer::find($user->installer_id);
     }
     // echo $user->installer_id;
     // foreach($serials as $serial) {
     //     echo $serial->serial;
     // }
     return View::make('admin.user.view')->with('user', $user)->with('serials', $serials)->with('installer', $installer);
 }
Esempio n. 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     if ($this->isAdminRequest()) {
         // delete
         $installer = Installer::find($id);
         $installer->delete();
         // redirect
         Session::flash('message', 'Successfully deleted the Installer!');
         return Redirect::to('admin/installers');
     }
 }
Esempio n. 3
0
 public function import($name)
 {
     // echo $name;
     // exit;
     $file = '../laravel/app/storage/csv/' . $name . '.csv';
     // echo $file;
     // exit;
     $allowedfilenames = array("serials", "installers");
     if (in_array($name, $allowedfilenames)) {
         //Parse into array
         $array = $this->csvtoarray($file);
         switch ($name) {
             case 'serials':
                 foreach ($array as $item) {
                     $serial = new Serial();
                     $find = $serial->where('serial', '=', $item['serial'])->first();
                     if (!$find) {
                         $serial->model_id = $item['model_id'];
                         $serial->serial = $item['serial'];
                         $serial->save();
                     }
                 }
                 break;
             case 'installers':
                 // echo "<pre>";
                 // print_r($array);
                 // echo "</pre>";
                 // exit;
                 $insertcount = 0;
                 $updatecount = 0;
                 foreach ($array as $item) {
                     $installer = new Installer();
                     $find = $installer->where('account_number', '=', $item['account_number'])->first();
                     if ($find->id) {
                         $installer = Installer::find($find->id);
                     }
                     $installer->account_number = trim($item['account_number']);
                     $installer->business_name = trim($item['business_name']);
                     $installer->address = trim($item['address']);
                     $installer->city = trim($item['city']);
                     $installer->state = trim($item['state']);
                     $installer->zip = trim($item['zip']);
                     $installer->phone = trim($item['phone']);
                     if ($installer->save()) {
                         if ($find->id) {
                             $updatecount++;
                         } else {
                             $insertcount++;
                         }
                     } else {
                         echo "Whoops";
                         exit;
                     }
                 }
                 echo "Updated: " . $updatecount . "<br />";
                 echo "Inserted: " . $insertcount . "<br />";
                 break;
         }
     }
     // echo "<pre>";
     // print_r($array);
     // echo "</pre>";
 }
 function getInstallerName()
 {
     App::import('Model', 'ScheduleManager.Installer');
     $installer_model = new Installer();
     return $installer_model->find("list", array("fields" => array("id", "name_lookup_id")));
 }
 function set_week_calendar_view($set_date = null, $prev = null, $next = null)
 {
     App::uses('Installer', 'ScheduleManager.Model');
     $installerModel = new Installer();
     $installers = $installerModel->find('all');
     if (!empty($set_date)) {
         $set_date = $this->formatDate(str_replace('-', '/', $set_date));
     }
     $this->set(compact('installers', 'set_date', 'prev', 'next'));
 }