예제 #1
0
파일: routes.php 프로젝트: kenkode/umash
});
/* #################### IMPORT ALLOWANCES ################################## */
Route::post('import/allowances', function () {
    if (Input::hasFile('allowances')) {
        $destination = public_path() . '/migrations/';
        $filename = str_random(12);
        $ext = Input::file('allowances')->getClientOriginalExtension();
        $file = $filename . '.' . $ext;
        Input::file('allowances')->move($destination, $file);
        Excel::selectSheetsByIndex(0)->load(public_path() . '/migrations/' . $file, function ($reader) {
            $results = $reader->get();
            foreach ($results as $result) {
                $name = explode(':', $result->employee);
                $employeeid = DB::table('employee')->where('personal_file_number', '=', $name[0])->pluck('id');
                $allowanceid = DB::table('allowances')->where('allowance_name', '=', $result->allowance_type)->pluck('id');
                $allowance = new EAllowances();
                $allowance->employee_id = $employeeid;
                $allowance->allowance_id = $allowanceid;
                $allowance->allowance_amount = $result->amount;
                $allowance->save();
            }
        });
    }
    return Redirect::back()->with('notice', 'allowances have been succefully imported');
});
/* #################### IMPORT DEDUCTIONS ################################## */
Route::post('import/deductions', function () {
    if (Input::hasFile('deductions')) {
        $destination = public_path() . '/migrations/';
        $filename = str_random(12);
        $ext = Input::file('deductions')->getClientOriginalExtension();
 /**
  * Remove the specified branch from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $allowance = EAllowances::findOrFail($id);
     EAllowances::destroy($id);
     Audit::logaudit('Employee Allowances', 'delete', 'deleted: ' . $allowance->allowance_amount);
     return Redirect::route('employee_allowances.index');
 }