/**
  * O método precisa informar uma lista de produtos
  * @return {view}
  */
 public function create()
 {
     $stocks = Stock::all();
     $customers = Customer::all();
     $employees = Employee::all();
     return view('pages.new_sale', ['stocks' => $stocks, 'customers' => $customers, 'employees' => $employees]);
 }
 public function delete(Request $request)
 {
     $id = $request->get('id');
     $employee = Employee::find($id);
     $employee->delete();
     $employees = Employee::all();
     return view('pages.employees', ['employees' => $employees]);
 }
 public function create()
 {
     $types = StockType::getType();
     $employees = Employee::all();
     $products = Product::all();
     $params = ['types' => $types, 'employees' => $employees, 'products' => $products];
     return view('pages.new_stock', $params);
 }
 /**
  * Employee JSON.
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function json()
 {
     return Employee::all()->map(function ($item) {
         $item->sex = ['female' => '<i class="fa fa-fw fa-female"></i> მდედრ.', 'male' => '<i class="fa fa-fw fa-male"></i> მამრ.'][$item->sex];
         $item->actions = view('partials.actions')->withId($item->id)->render();
         return $item;
     });
 }
 private function updateId()
 {
     $employees = Employee::all();
     foreach ($employees as $employee) {
         $new = Employee::find($employee->id);
         $new->code = str_pad($new->code, 6, '0', STR_PAD_LEFT);
         //$new->id = Employee::get_uid();
         $new->save();
     }
 }
Exemple #6
0
 public function index()
 {
     /*$branchs = Branch::orderBy('name', 'asc')->get(['id', 'name']);
       $branchselectlist = array();
       array_push($branchselectlist,':เลือกสาขา');
       foreach($branchs as $item){
           array_push($branchselectlist,$item->id.':'.$item->name);
       }*/
     $provinces = Province::orderBy('name', 'asc')->get(['id', 'name']);
     $provinceselectlist = array();
     array_push($provinceselectlist, ':เลือกจังหวัด');
     foreach ($provinces as $item) {
         array_push($provinceselectlist, $item->id . ':' . $item->name);
     }
     $occupations = Occupation::orderBy('name', 'asc')->get(['id', 'name']);
     $occupationselectlist = array();
     array_push($occupationselectlist, ':เลือกอาชีพ');
     foreach ($occupations as $item) {
         array_push($occupationselectlist, $item->id . ':' . $item->name);
     }
     $amphurids = Customer::distinct()->lists('amphurid');
     $amphurs = Amphur::whereIn('id', $amphurids)->orderBy('name', 'asc')->get(['id', 'name']);
     $amphurselectlist = array();
     array_push($amphurselectlist, ':เลือกเขต/อำเภอ');
     foreach ($amphurs as $item) {
         array_push($amphurselectlist, $item->id . ':' . $item->name);
     }
     $districtids = Customer::distinct()->lists('districtid');
     $districts = District::whereIn('id', $districtids)->orderBy('name', 'asc')->get(['id', 'name']);
     $districtselectlist = array();
     array_push($districtselectlist, ':เลือกตำบล/แขวง');
     foreach ($districts as $item) {
         array_push($districtselectlist, $item->id . ':' . $item->name);
     }
     $employees = Employee::all(['id', 'firstname', 'lastname']);
     $employeeselectlist = array();
     array_push($employeeselectlist, ':เลือกพนักงาน');
     foreach ($employees as $emp) {
         array_push($employeeselectlist, $emp->id . ':' . $emp->firstname . ' ' . $emp->lastname);
     }
     $carmodels = CarModel::all(['id', 'name']);
     $carmodelselectlist = array();
     array_push($carmodelselectlist, ':เลือกแบบ');
     foreach ($carmodels as $cm) {
         array_push($carmodelselectlist, $cm->id . ':' . $cm->name);
     }
     $defaultProvince = '';
     if (Auth::user()->isadmin == false) {
         $defaultProvince = Auth::user()->branchid == null ? '' : Auth::user()->branch->provinceid;
     }
     return view('customer', ['provinceselectlist' => implode(";", $provinceselectlist), 'amphurselectlist' => implode(";", $amphurselectlist), 'districtselectlist' => implode(";", $districtselectlist), 'carmodelselectlist' => implode(";", $carmodelselectlist), 'employeeselectlist' => implode(";", $employeeselectlist), 'occupationselectlist' => implode(";", $occupationselectlist), 'defaultProvince' => $defaultProvince]);
 }