Esempio n. 1
0
 /**
  * Function create construct
  */
 public function __construct()
 {
     $language = Language::where('is_default', '=', 1)->first();
     if ($language == null) {
         \App::setLocale('en');
     } else {
         \App::setLocale($language->code);
     }
     $this->getFeatureGroup();
     $d = $this->sidebar();
     $this->getNotification();
     view()->share('format_date', \App\Configure::where('name', '=', 'format_date')->first()->value);
 }
 /**
  * Update configure system
  * 
  * @param  Request $request
  * @return Response
  */
 public function update(Request $request)
 {
     $name = $request->get('name');
     $value = $request->get('value');
     $lan = 0;
     foreach ($name as $key) {
         Configure::where('name', '=', $key)->update(['value' => $value[$lan]]);
         if ($key == "default_language") {
             Language::where('is_default', '=', 1)->update(['is_default' => 0]);
             $language = Language::where('code', '=', $value[$lan])->update(['is_default' => 1]);
         }
         $lan++;
     }
     return redirect()->route('configures.index');
 }
 /**
  * Export list employee
  * @return void
  */
 public function exportExcel()
 {
     Excel::create('List Employee', function ($excel) {
         $excel->sheet('Sheetname', function ($sheet) {
             //$sheet->mergeCells('A1:C1');
             $sheet->setBorder('A1:K1', 'thin');
             $sheet->cells('A1:K1', function ($cells) {
                 $cells->setBackground('blue');
                 $cells->setFontColor('#FFFFFF');
                 $cells->setAlignment('center');
                 $cells->setValignment('middle');
                 $cells->setFontFamily('Times New Roman');
             });
             $sheet->cells('A', function ($cells) {
                 $cells->setAlignment('center');
                 $cells->setFontFamily('Times New Roman');
             });
             $sheet->setFontFamily('Times New Roman');
             $sheet->setWidth(array('A' => '10', 'B' => '15', 'C' => '20', 'D' => '10', 'E' => '30', 'F' => '20', 'G' => '15', 'H' => '20', 'I' => '30', 'J' => '15', 'K' => '50'));
             $data = [];
             /*HEADER EXCEL*/
             array_push($data, array('#', 'Employee Code', 'Last Name', 'First Name', 'Email', 'Date Of Birth', 'Gender', 'Phone', 'Position', 'Nationality', 'Address'));
             /*CONTENT EXCEL*/
             $employee = Employee::all();
             $number = 0;
             foreach ($employee as $key => $value) {
                 $number++;
                 $posname = "";
                 $position = $value->departments;
                 if ($position) {
                     $posname = $position->name;
                 }
                 array_push($data, array($number, $value->employee_code, $value->lastname, $value->firstname, $value->email, date_format(new DateTime($value->date_of_birth), \App\Configure::where('name', '=', 'format_date')->first()->value), $value->gender == '0' ? 'Male' : 'Female', $value->phone, $posname, $value->nationalitys->name, $value->address));
             }
             $sheet->fromArray($data, null, 'A1', false, false);
         });
     })->download('xls');
 }