示例#1
0
文件: routes.php 项目: kenkode/umash
    return Redirect::back()->with('notice', 'Employees have been succeffully imported');
});
/* #################### IMPORT EARNINGS ################################## */
Route::post('import/earnings', function () {
    if (Input::hasFile('earnings')) {
        $destination = public_path() . '/migrations/';
        $filename = str_random(12);
        $ext = Input::file('earnings')->getClientOriginalExtension();
        $file = $filename . '.' . $ext;
        Input::file('earnings')->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');
                $earning = new Earnings();
                $earning->employee_id = $employeeid;
                $earning->earnings_name = $result->earning_type;
                $earning->narrative = $result->narrative;
                $earning->earnings_amount = $result->amount;
                $earning->save();
            }
        });
    }
    return Redirect::back()->with('notice', 'earnings have been succeffully imported');
});
/* #################### IMPORT RELIEFS ################################## */
Route::post('import/reliefs', function () {
    if (Input::hasFile('reliefs')) {
        $destination = public_path() . '/migrations/';
        $filename = str_random(12);
示例#2
0
 public function processEarnings()
 {
     if ($this->cur_user instanceof User && $this->cur_user->id) {
         include_once LIB_ROOT . '/earnings.class.php';
         $earnins = new Earnings();
         $earnins->calculate();
     }
 }
 public function update($id, $post)
 {
     $errors = array();
     $earning = new Earnings();
     $earning->exchangeArray($post);
     $type = $earning->getType();
     $earning->setType($type);
     $value = trim($earning->getValue());
     $earning->setValue($value);
     $earning->setId($id);
     if (empty($value)) {
         $errors['value'] = "Моля въведете приход!";
     }
     if (!is_numeric($value)) {
         $errors['value'] = "Моля въведете число!";
     }
     if (count($errors) > 0) {
         return $errors;
     } else {
         $this->edit($earning);
         return $errors = array();
     }
 }
示例#4
0
 /**
  * Remove the specified branch from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $earning = Earnings::findOrFail($id);
     Earnings::destroy($id);
     Audit::logaudit('Earnings', 'delete', 'deleted: ' . $earning->earnings_name);
     return Redirect::route('other_earnings.index');
 }