Ejemplo n.º 1
0
 public function index()
 {
     $provinceids = Branch::where('isheadquarter', true)->distinct()->lists('provinceid');
     $provinces = Province::whereIn('id', $provinceids)->orderBy('name', 'asc')->get(['id', 'name']);
     $provinceselectlist = array();
     array_push($provinceselectlist, ':เลือกจังหวัด');
     foreach ($provinces as $item) {
         array_push($provinceselectlist, $item->id . ':' . $item->name);
     }
     $carmodels = CarModel::orderBy('name', 'asc')->get(['id', 'name']);
     $carmodelselectlist = array();
     array_push($carmodelselectlist, ':เลือกแบบ');
     foreach ($carmodels as $item) {
         array_push($carmodelselectlist, $item->id . ':' . $item->name);
     }
     $carsubmodelids = Car::distinct()->lists('carsubmodelid');
     $carsubmodels = CarSubModel::whereIn('id', $carsubmodelids)->orderBy('name', 'asc')->get(['id', 'name']);
     $carsubmodelselectlist = array();
     array_push($carsubmodelselectlist, ':เลือกรุ่น');
     foreach ($carsubmodels as $item) {
         array_push($carsubmodelselectlist, $item->id . ':' . $item->name);
     }
     $colorids = Car::distinct()->lists('colorid');
     $colors = Color::whereIn('id', $colorids)->orderBy('code', 'asc')->get(['id', 'code', 'name']);
     $colorselectlist = array();
     array_push($colorselectlist, ':เลือกสี');
     foreach ($colors as $item) {
         array_push($colorselectlist, $item->id . ':' . $item->code . ' - ' . $item->name);
     }
     $defaultProvince = '';
     if (Auth::user()->isadmin == false) {
         $defaultProvince = Auth::user()->branchid == null ? '' : Auth::user()->branch->provinceid;
     }
     return view('car', ['provinceselectlist' => implode(";", $provinceselectlist), 'carmodelselectlist' => implode(";", $carmodelselectlist), 'carsubmodelselectlist' => implode(";", $carsubmodelselectlist), 'colorselectlist' => implode(";", $colorselectlist), 'defaultProvince' => $defaultProvince]);
 }
Ejemplo n.º 2
0
 /**
  * update information
  *
  * @param id
  * @param options = array()
  * @return true or false
  */
 public function updateItem($id, $options)
 {
     $branch = Branch::find($id);
     if (isset($options['image']) && $options['image'] != 'undefined') {
         $image = $options['image'];
         $original_name = explode(".", $image->getClientOriginalName());
         $original_name = $original_name[0];
         $new_name = str_slug($original_name, "-") . '-' . time() . '.' . $image->getClientOriginalExtension();
         $path = public_path(BRANCH_IMAGE . date('Y-m-d', strtotime($branch->created)));
         if (!file_exists($path)) {
             mkdir($path, 0777, true);
         } else {
             chmod($path, 0777);
         }
         Image::make($image->getRealPath())->resize(200, 200)->save($path . '/' . $new_name);
         $options['image'] = $new_name;
     } else {
         $options['image'] = $branch->image;
     }
     $options['updated'] = date('Y-m-d H:i:s');
     if (isset($options['_token'])) {
         unset($options['_token']);
     }
     return $this->where('id', $id)->update($options);
 }
Ejemplo n.º 3
0
 public function makeAddView(Request $request)
 {
     $lastday = Mansked::getLastDayLastWeekOfYear();
     $branch = Branch::find(Auth::user()->branchid);
     $data = ['branch' => $branch->code . ' - ' . $branch->addr1, 'branchid' => $branch->id, 'manager' => Auth::user()->name, 'managerid' => Auth::user()->id];
     return view('branch.mansked.add')->with('lastday', $lastday)->with('data', $data);
 }
Ejemplo n.º 4
0
 public function pepsi(Request $request)
 {
     /*
       	$components = ['062BFFD1637011E5B83800FF59FBB323',
     '063278FF637011E5B83800FF59FBB323',
     '0631FF85637011E5B83800FF59FBB323',
     '062C796C637011E5B83800FF59FBB323',
     '0615D0AA637011E5B83800FF59FBB323',
     '06163FD0637011E5B83800FF59FBB323'];
     */
     $components = ['08BA6275637011E5B83800FF59FBB323', '08BABBC7637011E5B83800FF59FBB323', '08BA0B96637011E5B83800FF59FBB323', '061BC1EB637011E5B83800FF59FBB323', '06229D04637011E5B83800FF59FBB323', '06232D26637011E5B83800FF59FBB323', '08BD2EDD637011E5B83800FF59FBB323', '08BD8844637011E5B83800FF59FBB323', '08BDE48E637011E5B83800FF59FBB323', '08BE401B637011E5B83800FF59FBB323', '08BE97FC637011E5B83800FF59FBB323', '08BEEB6C637011E5B83800FF59FBB323'];
     $data = [];
     $branches = \App\Models\Branch::orderBy('code')->get();
     if ($request->input('year') != '' && $request->input('branchid') != '') {
         foreach ($components as $key => $value) {
             $date = \Carbon\Carbon::parse($request->input('year') . '-01-01');
             $results = \App\Models\Purchase2::select(DB::raw('date, SUM(qty) AS qty, SUM(tcost) AS tcost'))->where('componentid', $value)->where('branchid', $request->input('branchid'))->where(DB::raw('YEAR(date)'), $request->input('year'))->groupBy(DB::raw('YEAR(date)'))->groupBy(DB::raw('MONTH(date)'))->get();
             for ($i = 0; $i < 12; $i++) {
                 $filtered = $results->filter(function ($item) use($date) {
                     return $item->date->format('Y-m') == $date->format('Y-m') ? $item : null;
                 });
                 $data[$key][$date->format('Y-m-d')] = $filtered->first();
                 $date->addMonth();
             }
         }
     }
     if ($request->input('data') != '') {
         return $data;
     }
     return view('blank')->with('branches', $branches)->with('data', $data);
 }
Ejemplo n.º 5
0
 public function makeAddView(Request $request)
 {
     $mansked = new Mansked();
     $branch = Branch::find($request->user()->branchid);
     $new = $mansked->newWeek($branch->id);
     $data = ['branch' => $branch->code . ' - ' . $branch->descriptor, 'branchid' => $branch->id, 'manager' => $request->user()->name, 'managerid' => $request->user()->id, 'mancost' => $branch->mancost, 'weekno' => $new['weekno'], 'year' => $new['year']];
     return view('task.mansked.add')->with('data', $data);
 }
Ejemplo n.º 6
0
 public function check_headquarter(Request $request)
 {
     $input = $request->only('id', 'provinceid');
     $count = Branch::where('id', '!=', $input['id'])->where('provinceid', $input['provinceid'])->where('isheadquarter', true)->count();
     if ($count > 0) {
         return "true";
     }
 }
Ejemplo n.º 7
0
 private function firstRun()
 {
     $branches = Branch::all();
     foreach ($branches as $branch) {
         $new = Branch::find($branch->id);
         $new->id = Branch::get_uid();
         $new->save();
     }
 }
Ejemplo n.º 8
0
 public static function getBusinessRemainingCount($business_id)
 {
     $uncalled_numbers = 0;
     $branches = Branch::getBranchesByBusinessId($business_id);
     foreach ($branches as $branch) {
         $uncalled_numbers = Analytics::getBranchRemainingCount($branch->branch_id);
     }
     return $uncalled_numbers;
 }
Ejemplo n.º 9
0
 public function customers()
 {
     $client_data = Client::find(Auth::user()->id);
     $branch_data = $client_data->branch()->first();
     //get the client branch information
     $user = Branch::find($branch_data->id)->users()->orderBy('id', 'desc')->get();
     $users = $this->transform_array(json_decode($user), ['branch_id' => $branch_data->id]);
     return view('client.customers', compact('branch_data', 'users'));
 }
Ejemplo n.º 10
0
 public function run()
 {
     DB::table('users')->delete();
     $branches = Branch::all();
     $users = [];
     foreach ($branches as $branch) {
         array_push($users, ['username' => strtolower($branch->code) . '-manager', 'name' => $branch->code . ' Manager', 'branchid' => $branch->id, 'email' => strtolower($branch->code) . '*****@*****.**', 'password' => bcrypt('giligans'), 'id' => $branch->id]);
         $this->command->info($branch->descriptor);
     }
     DB::table('users')->insert($users);
     $this->command->info('Users table seeded!');
 }
Ejemplo n.º 11
0
Archivo: Car.php Proyecto: x-Zyte/nhp
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->issold = false;
         $model->isregistered = false;
         $model->isdelivered = false;
         $model->dodate = date('Y-m-d', strtotime($model->dodate));
         $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate));
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
         $rs = DB::select('call running_number("' . $model->provinceid . date("Y") . '","' . $model->receivetype . '")');
         $model->no = $rs[0]->no;
         $min = KeySlot::where('provinceid', $model->provinceid)->where('active', true)->min('no');
         if ($min == null) {
             $branch = Branch::where('provinceid', $model->provinceid)->where('isheadquarter', true)->first();
             $branch->keyslot = $branch->keyslot + 1;
             $branch->save();
             $model->keyno = $branch->keyslot;
         } else {
             $model->keyno = $min;
         }
         $model->save();
         KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => false]);
     });
     static::updating(function ($model) {
         $model->dodate = date('Y-m-d', strtotime($model->dodate));
         $model->receiveddate = date('Y-m-d', strtotime($model->receiveddate));
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
         if ($model->receivecarfilepath != '') {
             File::delete(public_path() . $model->receivecarfilepath);
         }
         if ($model->deliverycarfilepath != '') {
             File::delete(public_path() . $model->deliverycarfilepath);
         }
         KeySlot::where('provinceid', $model->provinceid)->where('no', $model->keyno)->update(['active' => true]);
     });
 }
Ejemplo n.º 12
0
 public function run()
 {
     //DB::table('user')->delete();
     //DB::connection('hr')->table('company')->delete();
     DB::table('user')->insert(array(array('username' => 'admin', 'name' => 'Giligans Admin', 'email' => '*****@*****.**', 'password' => bcrypt('giligans'), 'admin' => 1, 'branchid' => '0C17FE2D78A711E587FA00FF59FBB323', 'id' => '29E4E2FA672C11E596ECDA40B3C0AA12'), array('username' => 'cashier', 'name' => 'Giligans Cashier', 'email' => '*****@*****.**', 'password' => bcrypt('giligans'), 'admin' => 5, 'branchid' => '0C17FE2D78A711E587FA00FF59FBB323', 'id' => '3060F4F3BE6011E5A3FA00FF59FBB323')));
     $branches = Branch::all();
     $users = [];
     foreach ($branches as $branch) {
         array_push($users, ['username' => strtolower($branch->code) . '-cashier', 'name' => $branch->code . ' Cashier', 'branchid' => $branch->id, 'email' => strtolower($branch->code) . '*****@*****.**', 'password' => bcrypt('giligans'), 'admin' => 5, 'id' => $branch->id]);
         $this->command->info(strtolower($branch->code) . '-cashier');
     }
     DB::table('user')->insert($users);
     $this->command->info('User table seeded!');
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Branch::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('company');
     $query->andFilterWhere(['branch_id' => $this->branch_id]);
     $query->andFilterWhere(['like', 'branch_name', $this->branch_name])->andFilterWhere(['like', 'branch_email', $this->branch_email])->andFilterWhere(['like', 'company.name', $this->company_id]);
     return $dataProvider;
 }
Ejemplo n.º 14
0
 public function index()
 {
     $branchs = Branch::all(['id', 'name']);
     $branchselectlist = array();
     array_push($branchselectlist, ':เลือกสาขา');
     foreach ($branchs as $item) {
         array_push($branchselectlist, $item->id . ':' . $item->name);
     }
     $departments = Department::all(['id', 'name']);
     $departmentselectlist = array();
     array_push($departmentselectlist, ':เลือกแผนก');
     foreach ($departments as $item) {
         array_push($departmentselectlist, $item->id . ':' . $item->name);
     }
     $teams = Team::all(['id', 'name']);
     $teamselectlist = array();
     array_push($teamselectlist, ':เลือกทีม');
     foreach ($teams as $item) {
         array_push($teamselectlist, $item->id . ':' . $item->name);
     }
     return view('employee', ['branchselectlist' => implode(";", $branchselectlist), 'departmentselectlist' => implode(";", $departmentselectlist), 'teamselectlist' => implode(";", $teamselectlist)]);
 }
 /**
  * Finds the Branch model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Branch the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Branch::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 16
0
 public function actionLoadBranches()
 {
     $key = 'rusazx2220';
     $raw = file_get_contents('http://catalog.api.2gis.ru/2.0/catalog/marker/search?page=1&page_size=10000&q=%D0%B1%D0%B0%D0%BD%D0%BA%D0%B8&hash=m0qkmb8zr3yvstts&stat%5Bts%5D=1452016254482&stat%5Buser%5D=d241f017-2569-4e2d-8e15-3a6b4ed85efb&stat%5Bsid%5D=02a4e3d3-d6de-4162-8a22-59080e2e6507&region_id=1&key=rusazx2220');
     $json = json_decode($raw);
     $banks = [];
     if ($json->meta->code == '200') {
         //$json->result->total - 1
         for ($i = 0; $i < 50; $i++) {
             $bankID = $json->result->items[$i]->id;
             $bankInfo = json_decode(file_get_contents("http://catalog.api.2gis.ru/2.0/catalog/branch/get?id={$bankID}&key={$key}"));
             if ($bankInfo->meta->code == '200') {
                 $phone = '';
                 if ($bankInfo->result->items[0]->contact_groups) {
                     foreach ($bankInfo->result->items[0]->contact_groups as $cg) {
                         foreach ($cg->contacts as $c) {
                             if ($c->type == 'phone') {
                                 $phone .= $c->text . '; ';
                             }
                         }
                     }
                 }
                 if (!$banks[$bankInfo->result->items[0]->name]) {
                     $banks[$bankInfo->result->items[0]->name] = [['lon' => $json->result->items[$i]->lon, 'lat' => $json->result->items[$i]->lat, 'address' => $bankInfo->result->items[0]->address_name, 'phone' => $phone, 'monWH' => $bankInfo->result->items[0]->schedule->Mon->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Mon->working_hours[0]->to, 'tueWH' => $bankInfo->result->items[0]->schedule->Tue->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Tue->working_hours[0]->to, 'wedWH' => $bankInfo->result->items[0]->schedule->Wed->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Wed->working_hours[0]->to, 'thuWH' => $bankInfo->result->items[0]->schedule->Thu->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Thu->working_hours[0]->to, 'friWH' => $bankInfo->result->items[0]->schedule->Fri->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Fri->working_hours[0]->to, 'satWH' => $bankInfo->result->items[0]->schedule->Sat->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Sat->working_hours[0]->to, 'sunWH' => $bankInfo->result->items[0]->schedule->Sun->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Sun->working_hours[0]->to]];
                 } else {
                     array_push($banks[$bankInfo->result->items[0]->name], ['lon' => $json->result->items[$i]->lon, 'lat' => $json->result->items[$i]->lat, 'address' => $bankInfo->result->items[0]->address_name, 'phone' => $phone, 'monWH' => $bankInfo->result->items[0]->schedule->Mon->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Mon->working_hours[0]->to, 'tueWH' => $bankInfo->result->items[0]->schedule->Tue->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Tue->working_hours[0]->to, 'wedWH' => $bankInfo->result->items[0]->schedule->Wed->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Wed->working_hours[0]->to, 'thuWH' => $bankInfo->result->items[0]->schedule->Thu->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Thu->working_hours[0]->to, 'friWH' => $bankInfo->result->items[0]->schedule->Fri->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Fri->working_hours[0]->to, 'satWH' => $bankInfo->result->items[0]->schedule->Sat->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Sat->working_hours[0]->to, 'sunWH' => $bankInfo->result->items[0]->schedule->Sun->working_hours[0]->from . ' - ' . $bankInfo->result->items[0]->schedule->Sun->working_hours[0]->to]);
                 }
             } else {
                 echo 'Server: ' . $bankInfo->meta->code;
             }
         }
         foreach ($banks as $key => $value) {
             $bank = Bank::findOne(['name' => $key]);
             foreach ($value as $branchInfo) {
                 $branch = new Branch();
                 $branch->bankID = $bank->id;
                 $branch->lon = strval($branchInfo['lon']);
                 $branch->lat = strval($branchInfo['lat']);
                 $branch->address = $branchInfo['address'];
                 $branch->phone = $branchInfo['phone'];
                 $branch->monWH = $branchInfo['monWH'];
                 $branch->tueWH = $branchInfo['tueWH'];
                 $branch->wedWH = $branchInfo['wedWH'];
                 $branch->thuWH = $branchInfo['thuWH'];
                 $branch->friWH = $branchInfo['friWH'];
                 $branch->satWH = $branchInfo['satWH'];
                 $branch->sunWH = $branchInfo['sunWH'];
                 $branch->isActive = true;
                 $branch->save();
             }
         }
     } else {
         echo 'Server: ' . $json->meta->code;
     }
     $this->redirect(['bank/index']);
 }
Ejemplo n.º 17
0
 public static function getFirstServiceOfBusiness($business_id)
 {
     $first_branch = Branch::getFirstBranchOfBusiness($business_id);
     return Service::getFirstServiceOfBranch($first_branch->branch_id);
 }
Ejemplo n.º 18
0
 public function makeAddView(Request $request)
 {
     $branches = Branch::orderBy('code')->get();
     return view('masterfiles.employee.add')->with('branches', $branches);
 }
Ejemplo n.º 19
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         if ($model->isadmin) {
             $model->provinceid = null;
             $model->branchid = null;
             $model->departmentid = null;
             $model->teamid = null;
             $model->candeletedata = true;
         } else {
             if ($model->branchid == '') {
                 $model->branchid = null;
                 $model->provinceid = null;
             } else {
                 if ($model->branchid != null) {
                     $branch = Branch::find($model->branchid);
                     $model->provinceid = $branch->provinceid;
                 }
             }
             if ($model->departmentid == '') {
                 $model->departmentid = null;
             }
             if ($model->teamid == '') {
                 $model->teamid = null;
             }
         }
         if ($model->username == '') {
             $model->username = null;
         }
         if ($model->email == '') {
             $model->email = null;
         }
         if ($model->workingstartdate != null && $model->workingstartdate != '') {
             $model->workingstartdate = date('Y-m-d', strtotime($model->workingstartdate));
         } else {
             $model->workingstartdate = null;
         }
         if ($model->workingenddate != null && $model->workingenddate != '') {
             $model->workingenddate = date('Y-m-d', strtotime($model->workingenddate));
         } else {
             $model->workingenddate = null;
         }
         if ($model->loginstartdate != null && $model->loginstartdate != '') {
             $model->loginstartdate = date('Y-m-d', strtotime($model->loginstartdate));
         } else {
             $model->loginstartdate = null;
         }
         if ($model->loginenddate != null && $model->loginenddate != '') {
             $model->loginenddate = date('Y-m-d', strtotime($model->loginenddate));
         } else {
             $model->loginenddate = null;
         }
         if ($model->username != null && $model->username != '') {
             $model->password = bcrypt("nissanhippro");
         }
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::updating(function ($model) {
         if ($model->isadmin) {
             $model->provinceid = null;
             $model->branchid = null;
             $model->departmentid = null;
             $model->teamid = null;
             $model->candeletedata = true;
         } else {
             if ($model->branchid == '') {
                 $model->branchid = null;
                 $model->provinceid = null;
             } else {
                 if ($model->branchid != null) {
                     $branch = Branch::find($model->branchid);
                     $model->provinceid = $branch->provinceid;
                 }
             }
             if ($model->departmentid == '') {
                 $model->departmentid = null;
             }
             if ($model->teamid == '') {
                 $model->teamid = null;
             }
         }
         if ($model->username == '') {
             $model->username = null;
         }
         if ($model->email == '') {
             $model->email = null;
         }
         if ($model->workingstartdate != null && $model->workingstartdate != '') {
             $model->workingstartdate = date('Y-m-d', strtotime($model->workingstartdate));
         } else {
             $model->workingstartdate = null;
         }
         if ($model->workingenddate != null && $model->workingenddate != '') {
             $model->workingenddate = date('Y-m-d', strtotime($model->workingenddate));
         } else {
             $model->workingenddate = null;
         }
         if ($model->loginstartdate != null && $model->loginstartdate != '') {
             $model->loginstartdate = date('Y-m-d', strtotime($model->loginstartdate));
         } else {
             $model->loginstartdate = null;
         }
         if ($model->loginenddate != null && $model->loginenddate != '') {
             $model->loginenddate = date('Y-m-d', strtotime($model->loginenddate));
         } else {
             $model->loginenddate = null;
         }
         if ($model->username != null && $model->username != '' && ($model->password == null || $model->password == '')) {
             $model->password = bcrypt("nissanhippro");
         }
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
 }
Ejemplo n.º 20
0
 public function getBranch()
 {
     return $this->hasOne(Branch::className(), ['id' => 'branch_id']);
 }
Ejemplo n.º 21
0
 /**
  * @param $ClientTransformer array
  * @return array
  **/
 public function transformLong($item)
 {
     $company_details = Branch::find($item['branch_id'])->company()->select('id AS company_id', 'company_name', 'description', 'facebook')->get();
     return ['client_id' => $item['id'], 'client_name' => $item['name'], 'branch_id' => $item['branch_id'], 'company_details' => $company_details];
 }
Ejemplo n.º 22
0
 public function importDBFs($br)
 {
     //(Request $request){
     $logfile = base_path() . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'db-import.txt';
     //return Employee::with('childrens')->get();
     $import = true;
     if ($import) {
         $db = dbase_open('D:\\GI\\' . $br . '\\GC113015\\PAY_MAST.DBF', 0);
     } else {
         $db = dbase_open('D:\\GI\\MAR\\GC113015\\PAY_MAST.DBF', 0);
     }
     if ($db) {
         $header = dbase_get_header_info($db);
         if (!$import) {
             echo '<table cellpadding="2" cellspacing="0" border="1"><thead>';
         }
         // render table header
         if (!$import) {
             echo '<tr>';
             foreach ($header as $key => $value) {
                 echo '<th>' . $value['name'] . '</th>';
             }
             echo '</tr>';
         }
         // render table body
         $children_ctr = 0;
         $ecperson_ctr = 0;
         $education_ctr = 0;
         $work_ctr = 0;
         $spouse_ctr = 0;
         $record_numbers = dbase_numrecords($db);
         for ($i = 1; $i <= $record_numbers; $i++) {
             $row = dbase_get_record_with_names($db, $i);
             if ($i == 1) {
                 $brcode = trim($row['BRANCH']);
             }
             if ($import) {
                 $e = Employee::where('code', trim($row['MAN_NO']))->first();
                 if (!is_null($e)) {
                     continue;
                 }
             }
             $employee = new Employee();
             $employee->code = trim($row['MAN_NO']);
             $employee->lastname = trim($row['LAST_NAM']);
             $employee->firstname = trim($row['FIRS_NAM']);
             $employee->middlename = trim($row['MIDL_NAM']);
             $employee->companyid = trim($this->getCompanyId($row['CO_NAME']));
             $employee->id = $employee->get_uid();
             $branch = Branch::where('code', trim($row['BRANCH']))->first();
             $employee->branchid = is_null($branch) ? '' : $branch->id;
             $employee->deptid = $this->getDeptId($row['DEPT']);
             $employee->positionid = $this->getPositionId(trim($row['POSITION']));
             $employee->paytype = 2;
             $employee->ratetype = 2;
             $employee->rate = trim($row['RATE_HR']);
             $employee->ecola = trim($row['RATE_HR']);
             $employee->allowance1 = trim($row['ALW1_RATE']);
             $employee->allowance2 = trim($row['ALW2_RATE']);
             $employee->phicno = trim($row['PHEALTH_NO']);
             $employee->hdmfno = trim($row['PBIG_NO']);
             $employee->tin = trim($row['WTAX_NO']);
             $employee->sssno = trim($row['SSS_NO']);
             $employee->empstatus = $this->getEmpstatus(trim($row['EMP_STUS']));
             $employee->datestart = Carbon::parse(trim($row['STARTED']));
             //$employee->datehired		= trim($row['ALW2_RATE']);
             //$employee->datestop			= trim($row['ALW2_RATE']);
             $employee->punching = 1;
             $employee->processing = 1;
             $employee->address = trim($row['ADDRESS1']) . ', ' . trim($row['ADDRESS2']) . ', ' . trim($row['ADDRESS3']);
             $employee->phone = trim($row['TEL']);
             //$employee->fax 					= trim($row['TEL']);
             $employee->mobile = trim($row['CEL']);
             $employee->email = trim($row['EMAIL']);
             $employee->gender = trim($row['SEX']) == 'M' ? 1 : 2;
             $employee->civstatus = trim($row['CIV_STUS']) == 'SINGLE' ? 1 : 2;
             $employee->height = str_replace("'", '.', trim($row['HEIGHT']));
             $employee->weight = trim($row['WEIGHT']);
             $employee->birthdate = Carbon::parse(trim($row['BIRTHDATE']));
             $employee->birthplace = trim($row['BIRTHPLC']);
             $employee->religionid = trim($this->getReligionId($row['RELIGION']));
             $employee->hobby = trim($row['HOBBIES']);
             $employee->notes = 'UNIFORM:' . trim($row['UNIFORM']) . '; ' . 'SP_NOTES1:' . trim($row['SP_NOTES1']) . '; ' . 'SP_NOTES2:' . trim($row['SP_NOTES2']) . '; ';
             $childrens = [];
             if (!empty(trim($row['CHILDREN1'])) && trim($row['CHILDREN1']) != 'N/A') {
                 $c1 = new Children();
                 $c1->firstname = trim($row['CHILDREN1']);
                 $c1->lastname = $employee->lastname;
                 $c1->id = $c1->get_uid();
                 array_push($childrens, $c1);
                 $children_ctr++;
             }
             if (!empty(trim($row['CHILDREN2'])) && trim($row['CHILDREN2']) != 'N/A') {
                 $c2 = new Children();
                 $c2->firstname = trim($row['CHILDREN2']);
                 $c2->lastname = $employee->lastname;
                 $c2->id = $c2->get_uid();
                 array_push($childrens, $c2);
                 $children_ctr++;
             }
             if ($import) {
                 $employee->childrens()->saveMany($childrens);
             }
             if (!empty(trim($row['EMER_NAM'])) && trim($row['EMER_NAM']) != 'N/A') {
                 $emer = explode(' ', trim($row['EMER_NAM']));
                 $e = new Ecperson();
                 $e->firstname = empty($emer[0]) ? '' : $emer[0];
                 $e->lastname = empty($emer[1]) ? '' : $emer[1];
                 $e->mobile = trim($row['EMER_NO']);
                 $e->id = $e->get_uid();
                 $ecperson_ctr++;
                 if ($import) {
                     $employee->ecperson()->save($e);
                 }
             }
             if (!empty(trim($row['EDUCATION'])) && trim($row['EDUCATION']) != 'N/A') {
                 $edu = new Education();
                 $edu->school = trim($row['EDUCATION']);
                 $edu->id = $edu->get_uid();
                 if ($import) {
                     $employee->educations()->saveMany([$edu]);
                 }
                 $education_ctr++;
             }
             $works = [];
             if (!empty(trim($row['WORKHIST1'])) && trim($row['WORKHIST1']) != 'N/A') {
                 $w1 = new Workexp();
                 $w1->company = trim($row['WORKHIST1']);
                 $w1->id = $w1->get_uid();
                 array_push($works, $w1);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST2'])) && trim($row['WORKHIST2']) != 'N/A') {
                 $w2 = new Workexp();
                 $w2->company = trim($row['WORKHIST2']);
                 $w2->id = $w2->get_uid();
                 array_push($works, $w2);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST3'])) && trim($row['WORKHIST3']) != 'N/A') {
                 $w3 = new Workexp();
                 $w3->company = trim($row['WORKHIST3']);
                 $w3->id = $w3->get_uid();
                 array_push($works, $w3);
                 $work_ctr++;
             }
             if (!empty(trim($row['WORKHIST4'])) && trim($row['WORKHIST4']) != 'N/A') {
                 $w4 = new Workexp();
                 $w4->company = trim($row['WORKHIST2']);
                 $w4->id = $w4->get_uid();
                 array_push($works, $w4);
                 $work_ctr++;
             }
             if ($import) {
                 $employee->workexps()->saveMany($works);
             }
             if (!empty(trim($row['SPOUS_NAM'])) && trim($row['SPOUS_NAM']) != 'N/A' && trim($row['SPOUS_NAM']) != 'NA/A') {
                 $sp = preg_split("/\\s+(?=\\S*+\$)/", trim($row['SPOUS_NAM']));
                 $spou = new Spouse();
                 $spou->firstname = empty($sp[0]) ? '' : $sp[0];
                 $spou->lastname = empty($sp[1]) ? '' : $sp[1];
                 $spou->id = $spou->get_uid();
                 $spouse_ctr++;
                 if ($import) {
                     $employee->spouse()->save($spou);
                 }
             }
             if ($import) {
                 $employee->save();
             }
             if (!$import) {
                 echo '<tr>';
                 foreach ($header as $key => $value) {
                     //if($value['name']=='CO_NAME')
                     //echo '<td>'.$this->getCompanyId($row[$value['name']]).'</td>';
                     //else
                     echo '<td>' . $row[$value['name']] . '</td>';
                 }
                 echo '</tr>';
             }
         }
         if ($import) {
             echo $brcode . ' imported! </br>';
             $handle = fopen($logfile, 'a');
             $content = $brcode . "\n\temployee:\t\t" . $record_numbers . "\n";
             $content .= "\tspouse:\t\t\t" . $spouse_ctr . "\n";
             $content .= "\tchildren:\t\t" . $children_ctr . "\n";
             $content .= "\tecperson:\t\t" . $ecperson_ctr . "\n";
             $content .= "\tworkexp:\t\t" . $work_ctr . "\n";
             fwrite($handle, $content);
             fclose($handle);
         }
         dbase_close($db);
     }
 }
Ejemplo n.º 23
0
 /**
  * remove branch
  *
  * @param id
  * @return bool
  */
 public function removeBranch($domain, $id)
 {
     Branch::find($id)->delete();
 }
Ejemplo n.º 24
0
 public function check_headquarter(Request $request)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $input = $request->only('id', 'provinceid');
     $count = Branch::where('id', '!=', $input['id'])->where('provinceid', $input['provinceid'])->where('isheadquarter', true)->count();
     if ($count > 0) {
         return "true";
     }
 }
Ejemplo n.º 25
0
 public static function getFirstBranchOfBusiness($business_id)
 {
     return Branch::where('business_id', '=', $business_id)->first();
 }
Ejemplo n.º 26
0
 public function actionUserform($id = null)
 {
     $user = new \app\models\User();
     if (!empty($id)) {
         $user = \app\models\User::find()->where(['id' => $id])->one();
     }
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         $user->branch_id = $post['User']['branch_id'];
         $user->user_type_id = $post['User']['user_type_id'];
         $user->fname = $post['User']['fname'];
         $user->lname = $post['User']['lname'];
         $user->usr = $post['User']['usr'];
         $user->pwd = $post['User']['pwd'];
         $user->tel = $post['User']['tel'];
         $user->email = $post['User']['email'];
         $user->status = 'use';
         $user->created_at = new \yii\db\Expression('NOW()');
         if ($user->save()) {
             return $this->redirect(['user']);
         }
     }
     $branchs = \app\models\Branch::find()->all();
     $userTypes = \app\models\UserType::find()->all();
     $branchIds = \yii\helpers\ArrayHelper::map($branchs, 'id', 'name');
     $userTypeIds = \yii\helpers\ArrayHelper::map($userTypes, 'id', 'name');
     return $this->render('//config/user_form', ['user' => $user, 'branchIds' => $branchIds, 'userTypeIds' => $userTypeIds]);
 }
Ejemplo n.º 27
0
 public function getforaccountingdetailbyid($id, $donumberformat)
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $accountingdetail = new AccountingDetail();
     $accountingdetail->carpaymentid = $id;
     $carpayment = CarPayment::find($id);
     $branch = Branch::find($carpayment->branchid);
     $accountingdetail->branchname = $branch->name;
     $carpreemption = CarPreemption::find($carpayment->carpreemptionid);
     $customer = Customer::find($carpreemption->buyercustomerid);
     $accountingdetail->customername = $customer->title . $customer->firstname . ' ' . $customer->lastname;
     if ($carpayment->deliverycardate != null && $carpayment->deliverycardate != '') {
         $accountingdetail->date = date('d-m-Y', strtotime($carpayment->deliverycardate));
         $accountingdetail->deliverycardate = date('d-m-Y', strtotime($carpayment->deliverycardate));
     } else {
         $accountingdetail->date = null;
         $accountingdetail->deliverycardate = "-";
     }
     $pricelist = Pricelist::find($carpreemption->pricelistid);
     $accountingdetail->carpriceinpricelist = $pricelist->sellingpricewithaccessories;
     $accountingdetail->colorprice = $carpreemption->colorprice;
     $carwithcolorprice = $pricelist->sellingpricewithaccessories + $carpreemption->colorprice;
     $accountingdetail->carwithcolorprice = $carwithcolorprice;
     $accountingdetail->purchasetype = $carpreemption->purchasetype;
     if ($carpreemption->purchasetype == 0) {
         $openbill = $accountingdetail->carwithcolorprice - $carpreemption->discount;
     } else {
         $openbill = $accountingdetail->carwithcolorprice - $carpreemption->discount + $carpreemption->accessories + $carpayment->accessoriesfeeincludeinyodjud;
     }
     $accountingdetail->openbill = $openbill;
     $accountingdetail->accessoriesfeeincludeinyodjud = $carpayment->accessoriesfeeincludeinyodjud;
     $accountingdetail->fakeaccessories = $carpreemption->accessories;
     $accountingdetail->discount = $carpreemption->discount;
     $accountingdetail->subdown = $carpreemption->subdown;
     $realsalesprice = $carwithcolorprice + $carpayment->accessoriesfeeincludeinyodjud - $carpreemption->discount - $carpreemption->subdown;
     $accountingdetail->realsalesprice = $realsalesprice;
     $accountingdetail->accessoriesfeeactuallypaid = $carpayment->accessoriesfeeactuallypaid;
     $registrationfee = $carpreemption->registrationfeefree ? 0 : $carpreemption->registrationfee;
     $accountingdetail->registrationfee = $registrationfee;
     $accountingdetail->actualinsurancefee = $carpreemption->insurancefee;
     if ($carpreemption->purchasetype == 0) {
         $compulsorymotorinsurancefeecash = $carpreemption->compulsorymotorinsurancefeefree ? 0 : $carpreemption->compulsorymotorinsurancefee;
         $conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeecash;
         $accountingdetail->compulsorymotorinsurancefeecash = $compulsorymotorinsurancefeecash;
         $insurancefeecash = $carpreemption->insurancefeefree ? 0 : $carpreemption->insurancefee;
         $accountingdetail->insurancefeecash = $insurancefeecash;
         $accountingdetail->compulsorymotorinsurancefeefn = 0;
         $compulsorymotorinsurancefeefn = 0;
         $accountingdetail->insurancefeefn = 0;
         $insurancefeefn = 0;
         $accountingdetail->firstinstallmentpayamount = 0;
         $firstinstallmentpayamount = 0;
         $accountingdetail->installmentsinadvance = 0;
         $accountingdetail->amountperinstallment = 0;
         $accountingdetail->payinadvanceamount = 0;
         $payinadvanceamount = 0;
         $accountingdetail->insurancepremium = 0;
         $accountingdetail->totalinadvancefees = 0;
         $totalinadvancefees = 0;
         $accountingdetail->conditioninsurancefee = $carpreemption->insurancefee;
         $accountingdetail->conditioninsurancefeecustomerpaid = $insurancefeecash;
         $conditioninsurancefeecompanypaid = $carpreemption->insurancefee - $insurancefeecash;
         $accountingdetail->conditioninsurancefeecompanypaid = $conditioninsurancefeecompanypaid;
         $accountingdetail->conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeecash;
     } else {
         $compulsorymotorinsurancefeecash = 0;
         $insurancefeecash = 0;
         $compulsorymotorinsurancefeefn = $carpreemption->compulsorymotorinsurancefeefree ? 0 : $carpreemption->compulsorymotorinsurancefee;
         $conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeefn;
         $accountingdetail->compulsorymotorinsurancefeefn = $compulsorymotorinsurancefeefn;
         $insurancefeefn = $carpreemption->insurancefeefree ? 0 : $carpreemption->insurancefee;
         $accountingdetail->insurancefeefn = $insurancefeefn;
         $firstinstallmentpayamount = $carpayment->firstinstallmentpay ? $carpayment->amountperinstallment : 0;
         $accountingdetail->firstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->installmentsinadvance = $carpayment->installmentsinadvance;
         $accountingdetail->amountperinstallment = $carpayment->amountperinstallment;
         $payinadvanceamount = $carpayment->installmentsinadvance * $carpayment->amountperinstallment;
         $accountingdetail->payinadvanceamount = $payinadvanceamount;
         $accountingdetail->insurancepremium = $carpayment->insurancepremium;
         $totalinadvancefees = $insurancefeefn + $compulsorymotorinsurancefeefn + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->totalinadvancefees = $totalinadvancefees;
         $accountingdetail->compulsorymotorinsurancefeecash = 0;
         $accountingdetail->insurancefeecash = 0;
         $accountingdetail->conditioninsurancefee = $carpreemption->insurancefee;
         $accountingdetail->conditioninsurancefeecustomerpaid = $insurancefeefn;
         $conditioninsurancefeecompanypaid = $carpreemption->insurancefee - $insurancefeefn;
         $accountingdetail->conditioninsurancefeecompanypaid = $conditioninsurancefeecompanypaid;
         $accountingdetail->conditioncompulsorymotorinsurancefeecustomerpaid = $compulsorymotorinsurancefeefn;
     }
     $implementfee = $carpreemption->implementfeefree ? 0 : $carpreemption->implementfee;
     $accountingdetail->implementfee = $implementfee;
     $subsidise = $carpreemption->subsidisefree ? 0 : $carpreemption->subsidise;
     $accountingdetail->subsidise = $subsidise;
     $accountingdetail->giveawaywithholdingtax = $carpreemption->giveawaywithholdingtax;
     $accountingdetail->otherfee = $carpreemption->otherfee;
     $accountingdetail->otherfeedetail = $carpreemption->otherfeedetail;
     $accountingdetail->otherfee2 = $carpreemption->otherfee2;
     $accountingdetail->otherfeedetail2 = $carpreemption->otherfeedetail2;
     $accountingdetail->otherfee3 = $carpreemption->otherfee3;
     $accountingdetail->otherfeedetail3 = $carpreemption->otherfeedetail3;
     $totalotherfee = $subsidise + $carpreemption->giveawaywithholdingtax + $carpreemption->otherfee + $carpreemption->otherfee2 + $carpreemption->otherfee3;
     $accountingdetail->totalotherfee = $totalotherfee;
     $totalotherfees = $carpayment->accessoriesfeeactuallypaid + $registrationfee + $compulsorymotorinsurancefeecash + $insurancefeecash + $implementfee + $totalotherfee;
     $accountingdetail->totalotherfees = $totalotherfees;
     $carmodel = CarModel::find($carpreemption->carmodelid);
     $carsubmodel = CarSubModel::find($carpreemption->carsubmodelid);
     $accountingdetail->submodel = $carmodel->name . '/' . $carsubmodel->name;
     $car = Car::find($carpayment->carid);
     $accountingdetail->carno = $car->no;
     $accountingdetail->engineno = $car->engineno;
     $accountingdetail->chassisno = $car->chassisno;
     $color = Color::find($car->colorid);
     $accountingdetail->color = $color->code;
     $accountingdetail->purchasetypetext = $carpreemption->purchasetype == 0 ? "C" : "F";
     $accountingdetail->down = $carpreemption->down;
     $insurancecompany = InsuranceCompany::find($carpayment->insurancecompanyid);
     if ($insurancecompany != null) {
         $accountingdetail->insurancecompany = $insurancecompany->name;
     }
     $accountingdetail->capitalinsurance = $carpayment->capitalinsurance;
     $compulsorymotorinsurancecompany = InsuranceCompany::find($carpayment->compulsorymotorinsurancecompanyid);
     if ($compulsorymotorinsurancecompany != null) {
         $accountingdetail->compulsorymotorinsurancecompany = $compulsorymotorinsurancecompany->name;
     }
     $cartype = CarType::find($carmodel->cartypeid);
     $accountingdetail->conditioncompulsorymotorinsurancefee = $cartype->actpaidincludevat;
     $accountingdetail->hascompulsorymotorinsurancefee = $cartype->actpaidincludevat == 0 ? 0 : 1;
     $conditioncompulsorymotorinsurancefeecompanypaid = $cartype->actpaidincludevat - $conditioncompulsorymotorinsurancefeecustomerpaid;
     $accountingdetail->conditioncompulsorymotorinsurancefeecompanypaid = $conditioncompulsorymotorinsurancefeecompanypaid;
     $note1insurancefee = $carpreemption->insurancefee * 100 / 107.0;
     $accountingdetail->note1insurancefee = $note1insurancefee;
     $accountingdetail->note1insurancefeeincludevat = $carpreemption->insurancefee;
     $note1insurancefeevat = $carpreemption->insurancefee - $note1insurancefee;
     $accountingdetail->note1insurancefeevat = $note1insurancefeevat;
     $accountingdetail->note1compulsorymotorinsurancefee = $cartype->actpaid;
     $accountingdetail->note1compulsorymotorinsurancefeevat = $cartype->actpaidincludevat - $cartype->actpaid;
     $accountingdetail->note1compulsorymotorinsurancefeeincludevat = $cartype->actpaidincludevat;
     $note1totalfee = $note1insurancefee + $cartype->actpaid;
     $accountingdetail->note1totalfee = $note1totalfee;
     $note1totalfeevat = $note1insurancefeevat + ($cartype->actpaidincludevat - $cartype->actpaid);
     $accountingdetail->note1totalfeevat = $note1totalfeevat;
     $note1totalfeeincludevat = $carpreemption->insurancefee + $cartype->actpaidincludevat;
     $accountingdetail->note1totalfeeincludevat = $note1totalfeeincludevat;
     $cashpledgeredlabel = $carpreemption->cashpledgeredlabel;
     $accountingdetail->cashpledgeredlabel = $cashpledgeredlabel;
     if ($cashpledgeredlabel == null || $cashpledgeredlabel == 0) {
         $accountingdetail->hascashpledgeredlabel = 0;
     } else {
         $accountingdetail->hascashpledgeredlabel = 1;
     }
     $redlabelhistory = Redlabelhistory::where('carpreemptionid', $carpreemption->id)->orderBy('id', 'desc')->first();
     if ($redlabelhistory != null) {
         if ($redlabelhistory->returndate != null) {
             $accountingdetail->redlabelreturncashpledgedate = date('d-m-Y', strtotime($redlabelhistory->returncashpledgedate));
         } else {
             $accountingdetail->redlabelreturncashpledgedate = "-";
         }
     } else {
         $accountingdetail->redlabelreturncashpledgedate = "ไม่เอาป้าย";
     }
     $cashpledge = $carpreemption->cashpledge;
     $accountingdetail->cashpledge = $cashpledge;
     $totalcashpledge = $cashpledgeredlabel - $cashpledge;
     $accountingdetail->totalcashpledge = $totalcashpledge;
     $totalcash = $realsalesprice + $totalotherfees + $totalinadvancefees + $totalcashpledge;
     $accountingdetail->totalcash = $totalcash;
     $finacecompany = FinaceCompany::find($carpreemption->finacecompanyid);
     if ($finacecompany != null) {
         $accountingdetail->finacecompany = $finacecompany->name;
     }
     $accountingdetail->incasefinace = $carpreemption->purchasetype;
     if ($carpreemption->purchasetype == 1) {
         $accountingdetail->interest = $carpreemption->interest;
         $accountingdetail->installments = $carpreemption->installments;
         $pricelist = Pricelist::find($carpreemption->pricelistid);
         $carprice = $pricelist->sellingpricewithaccessories + $carpreemption->colorprice;
         $yodjud = $carprice - $carpreemption->discount - $carpreemption->down + $carpreemption->accessories + $carpayment->accessoriesfeeincludeinyodjud;
         $yodjudwithinsurancepremium = $yodjud + $carpayment->insurancepremium;
         $accountingdetail->yodjud = $yodjudwithinsurancepremium;
         $yodjudwithinterest = $yodjudwithinsurancepremium * ($carpreemption->interest + 100) / 100.0;
         $accountingdetail->yodjudwithinterest = $yodjudwithinterest;
         $finaceprofit = $yodjudwithinterest - $yodjudwithinsurancepremium;
         $commissionfinace = CommissionFinace::where('finacecompanyid', $carpreemption->finacecompanyid)->where('interestratetypeid', $carpreemption->interestratetypeid)->where('finaceminimumprofit', '<=', $finaceprofit)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->whereHas('commissionFinaceCars', function ($query) use($carpreemption) {
             $query->where('carmodelid', $carpreemption->carmodelid)->Where(function ($query) use($carpreemption) {
                 $query->where('carsubmodelid', $carpreemption->carsubmodelid)->orWhere('carsubmodelid', 0);
             });
         })->first();
         $percentdown = $carpreemption->down * 100.0 / ($carprice - $carpreemption->discount + $carpreemption->accessories);
         $accountingdetail->comfinpercent = null;
         $comfinpercent = 0;
         $accountingdetail->comfinyear = null;
         $comfinyear = 0;
         if ($commissionfinace != null) {
             $commissionfinaceinterest = CommissionFinaceInterest::where('commissionfinaceid', $commissionfinace->id)->where('downfrom', '<=', $percentdown)->where('downto', '>=', $percentdown)->first();
             if ($commissionfinaceinterest != null) {
                 $commissionstandardinterest = 0;
                 switch ($carpreemption->installments) {
                     case 24:
                         $commissionstandardinterest = $commissionfinaceinterest->installment24;
                         break;
                     case 36:
                         $commissionstandardinterest = $commissionfinaceinterest->installment36;
                         break;
                     case 48:
                         $commissionstandardinterest = $commissionfinaceinterest->installment48;
                         break;
                     case 60:
                         $commissionstandardinterest = $commissionfinaceinterest->installment60;
                         break;
                     case 72:
                         $commissionstandardinterest = $commissionfinaceinterest->installment72;
                         break;
                     case 84:
                         $commissionstandardinterest = $commissionfinaceinterest->installment84;
                         break;
                 }
                 $commissionfinaceinterests = CommissionFinaceCom::where('commissionfinaceid', $commissionfinace->id)->orderBy('com', 'asc')->get();
                 $previousstepcom = null;
                 foreach ($commissionfinaceinterests as $item) {
                     if ($carpreemption->interestratemode == 0) {
                         $currentstepinterest = $commissionstandardinterest + $item->interestcalculationbeginning;
                     } else {
                         $currentstepinterest = $commissionstandardinterest + $item->interestcalculationending;
                     }
                     if ($carpreemption->interest == $currentstepinterest) {
                         $accountingdetail->comfinpercent = $item->com;
                         $accountingdetail->comfinyear = $commissionfinace->years;
                         $comfinpercent = $item->com;
                         $comfinyear = $commissionfinace->years;
                         break;
                     } else {
                         if ($carpreemption->interest < $currentstepinterest) {
                             if ($previousstepcom != null) {
                                 $accountingdetail->comfinpercent = $previousstepcom;
                                 $accountingdetail->comfinyear = $commissionfinace->years;
                                 $comfinpercent = $previousstepcom;
                                 $comfinyear = $commissionfinace->years;
                             } else {
                                 $accountingdetail->comfinpercent = null;
                                 $accountingdetail->comfinyear = null;
                                 $comfinpercent = 0;
                                 $comfinyear = 0;
                             }
                             break;
                         } else {
                             if ($carpreemption->interest > $currentstepinterest) {
                                 $previousstepcom = $item->com;
                             }
                         }
                     }
                 }
                 if ($accountingdetail->comfinpercent == null) {
                     if ($previousstepcom != null) {
                         $accountingdetail->comfinpercent = $previousstepcom;
                         $accountingdetail->comfinyear = $commissionfinace->years;
                         $comfinpercent = $previousstepcom;
                         $comfinyear = $commissionfinace->years;
                     }
                 }
             }
         }
         $employee = Employee::find($carpreemption->salesmanemployeeid);
         $accountingdetail->salename = $employee->title . $employee->firstname . ' ' . $employee->lastname;
         $accountingdetail->incasefinaceinsurancefee = $carpreemption->insurancefee;
         $accountingdetail->note2insurancefeewhtax = $note1insurancefee / 100.0;
         $accountingdetail->note2insurancefee = $insurancefeefn;
         $note2insurancefeeexpense = $conditioninsurancefeecompanypaid > 0 ? $conditioninsurancefeecompanypaid : 0;
         $accountingdetail->note2insurancefeeexpense = $note2insurancefeeexpense;
         $note2insurancefeeincome = $conditioninsurancefeecompanypaid < 0 ? $conditioninsurancefeecompanypaid * -1 : 0;
         $accountingdetail->note2insurancefeeincome = $note2insurancefeeincome;
         $accountingdetail->incasefinacecompulsorymotorinsurancefee = $cartype->actpaidincludevat;
         $accountingdetail->note2compulsorymotorinsurancefeewhtax = $cartype->actpaid / 100.0;
         $accountingdetail->note2compulsorymotorinsurancefee = $compulsorymotorinsurancefeefn;
         $note2compulsorymotorinsurancefeeexpense = $conditioncompulsorymotorinsurancefeecompanypaid > 0 ? $conditioncompulsorymotorinsurancefeecompanypaid : 0;
         $accountingdetail->note2compulsorymotorinsurancefeeexpense = $note2compulsorymotorinsurancefeeexpense;
         $note2compulsorymotorinsurancefeeincome = $conditioncompulsorymotorinsurancefeecompanypaid < 0 ? $conditioncompulsorymotorinsurancefeecompanypaid * -1 : 0;
         $accountingdetail->note2compulsorymotorinsurancefeeincome = $note2compulsorymotorinsurancefeeincome;
         $accountingdetail->incasefinacefirstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->note2firstinstallmentpayamount = $firstinstallmentpayamount;
         $accountingdetail->incasefinacepayinadvanceamount = $payinadvanceamount;
         $accountingdetail->note2payinadvanceamount = $payinadvanceamount;
         $accountingdetail->incasefinaceinsurancepremium = $carpayment->insurancepremium;
         $accountingdetail->note2insurancepremium = $carpayment->insurancepremium;
         $totalincasefinace = $carpreemption->insurancefee + $cartype->actpaidincludevat + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->totalincasefinace = $totalincasefinace;
         $accountingdetail->incasefinacereceivedcash = $yodjudwithinsurancepremium - $totalincasefinace;
         $note2total1 = $insurancefeefn + $compulsorymotorinsurancefeefn + $firstinstallmentpayamount + $payinadvanceamount + $carpayment->insurancepremium;
         $accountingdetail->note2total1 = $note2total1;
         $note2total2 = $note2insurancefeeexpense + $note2compulsorymotorinsurancefeeexpense;
         $accountingdetail->note2total2 = $note2total2;
         $note2total3 = $note2insurancefeeincome + $note2compulsorymotorinsurancefeeincome;
         $accountingdetail->note2total3 = $note2total3;
         $accountingdetail->incasefinacesubsidise = $carpreemption->subsidise;
         $incasefinacesubsidisewithvat = $carpreemption->subsidise + $carpreemption->subsidise * 0.07000000000000001;
         $accountingdetail->incasefinacesubsidisewithvat = $incasefinacesubsidisewithvat;
         $accountingdetail->note2subsidisewhtax = $carpreemption->subsidise * 0.03;
         $note2subsidisetotal = $carpreemption->subsidise + $carpreemption->subsidise * 0.07000000000000001 - $carpreemption->subsidise * 0.03;
         $accountingdetail->note2subsidisetotal = $note2subsidisetotal;
         $incasefinacehassubsidisereceivedcash = $yodjudwithinsurancepremium - $totalincasefinace - $incasefinacesubsidisewithvat;
         $accountingdetail->incasefinacehassubsidisereceivedcash = $incasefinacehassubsidisereceivedcash;
         $note2totalwhtax = $note1insurancefee / 100.0 + $cartype->actpaid / 100.0 + $carpreemption->subsidise * 0.03;
         $accountingdetail->note2totalwhtax = $note2totalwhtax;
         //NLTH,AYCAL,KL
         if ($carpreemption->finacecompanyid == 1 || $carpreemption->finacecompanyid == 2 || $carpreemption->finacecompanyid == 4) {
             $incasefinacecomfinamountwithvat = $yodjud * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0);
             $incasefinacecomfinamount = $incasefinacecomfinamountwithvat / 1.07;
             $incasefinacecomfinvat = $incasefinacecomfinamountwithvat - $incasefinacecomfinamount;
         } else {
             if ($carpreemption->finacecompanyid == 3 || $carpreemption->finacecompanyid == 5) {
                 $incasefinacecomfinamount = floor($yodjud / 1.07 * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0));
                 $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                 $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
             } else {
                 if ($carpreemption->finacecompanyid == 6) {
                     $incasefinacecomfinamount = round($yodjud / 1.07 * ($carpreemption->interest / 100.0) * $comfinyear * ($comfinpercent / 100.0), 2);
                     $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                     $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
                 } else {
                     if ($carpreemption->finacecompanyid == 7) {
                         $incasefinacecomfinamount = ($carpayment->amountperinstallment / 1.07 * $carpreemption->installments - $yodjud / 1.07) * ($comfinpercent / 100.0) * 48 / $carpreemption->installments;
                         $incasefinacecomfinvat = $incasefinacecomfinamount * 0.07000000000000001;
                         $incasefinacecomfinamountwithvat = $incasefinacecomfinamount + $incasefinacecomfinvat;
                     }
                 }
             }
         }
         $accountingdetail->incasefinacecomfinamount = $incasefinacecomfinamount;
         $accountingdetail->incasefinacecomfinvat = $incasefinacecomfinvat;
         $accountingdetail->incasefinacecomfinamountwithvat = $incasefinacecomfinamountwithvat;
         $accountingdetail->incasefinacecomfinwhtax = $incasefinacecomfinamount * 0.03;
         $incasefinacecomfintotal = $incasefinacecomfinamountwithvat - $incasefinacecomfinamount * 0.03;
         $accountingdetail->incasefinacecomfintotal = $incasefinacecomfintotal;
         $commissionextra = CommissionExtra::where('finacecompanyid', $carpreemption->finacecompanyid)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->whereHas('commissionExtraCars', function ($query) use($carpreemption) {
             $query->where('carmodelid', $carpreemption->carmodelid)->Where(function ($query) use($carpreemption) {
                 $query->where('carsubmodelid', $carpreemption->carsubmodelid)->orWhere('carsubmodelid', 0);
             });
         })->first();
         if ($commissionfinace != null) {
             $accountingdetail->incasefinacecomextraamount = $commissionextra->amount;
             $incasefinacecomextraamount = $commissionextra->amount;
             $accountingdetail->incasefinacecomextravat = $commissionextra->amount * 0.07000000000000001;
             $incasefinacecomextravat = $commissionextra->amount * 0.07000000000000001;
             $incasefinacecomextraamountwithvat = $commissionextra->amount + $commissionextra->amount * 0.07000000000000001;
             $accountingdetail->incasefinacecomextraamountwithvat = $incasefinacecomextraamountwithvat;
             $accountingdetail->incasefinacecomextrawhtax = $commissionextra->amount * 0.03;
             $incasefinacecomextrawhtax = $commissionextra->amount * 0.03;
             $incasefinacecomextratotal = $incasefinacecomextraamountwithvat - $commissionextra->amount * 0.03;
             $accountingdetail->incasefinacecomextratotal = $incasefinacecomextratotal;
         } else {
             $accountingdetail->incasefinacecomextraamount = 0;
             $incasefinacecomextraamount = 0;
             $accountingdetail->incasefinacecomextravat = 0;
             $incasefinacecomextravat = 0;
             $accountingdetail->incasefinacecomextraamountwithvat = 0;
             $accountingdetail->incasefinacecomextrawhtax = 0;
             $incasefinacecomextrawhtax = 0;
             $accountingdetail->incasefinacecomextratotal = 0;
             $incasefinacecomextratotal = 0;
         }
         if ($carpayment->insurancepremium > 0) {
             $commissionpa = CommissionPA::where('finacecompanyid', $carpreemption->finacecompanyid)->where('effectivefrom', '<=', $carpreemption->date)->where('effectiveto', '>=', $carpreemption->date)->first();
             if ($commissionpa != null) {
                 $accountingdetail->incasefinacecompaamount = $commissionpa->amount;
                 $incasefinacecompaamount = $commissionpa->amount;
                 $accountingdetail->incasefinacecompavat = $commissionpa->amount * 0.07000000000000001;
                 $incasefinacecompavat = $commissionpa->amount * 0.07000000000000001;
                 $incasefinacecompaamountwithvat = $commissionpa->amount + $commissionpa->amount * 0.07000000000000001;
                 $accountingdetail->incasefinacecompaamountwithvat = $incasefinacecompaamountwithvat;
                 $accountingdetail->incasefinacecompawhtax = $commissionpa->amount * 0.03;
                 $incasefinacecompawhtax = $commissionpa->amount * 0.03;
                 $incasefinacecompatotal = $incasefinacecompaamountwithvat - $commissionpa->amount * 0.03;
                 $accountingdetail->incasefinacecompatotal = $incasefinacecompatotal;
             } else {
                 $accountingdetail->incasefinacecompaamount = 0;
                 $incasefinacecompaamount = 0;
                 $accountingdetail->incasefinacecompavat = 0;
                 $incasefinacecompavat = 0;
                 $accountingdetail->incasefinacecompaamountwithvat = 0;
                 $accountingdetail->incasefinacecompawhtax = 0;
                 $incasefinacecompawhtax = 0;
                 $accountingdetail->incasefinacecompatotal = 0;
                 $incasefinacecompatotal = 0;
             }
         } else {
             $accountingdetail->incasefinacecompaamount = 0;
             $incasefinacecompaamount = 0;
             $accountingdetail->incasefinacecompavat = 0;
             $incasefinacecompavat = 0;
             $accountingdetail->incasefinacecompaamountwithvat = 0;
             $accountingdetail->incasefinacecompawhtax = 0;
             $incasefinacecompawhtax = 0;
             $accountingdetail->incasefinacecompatotal = 0;
             $incasefinacecompatotal = 0;
         }
         $incasefinacetotalcomamount = $incasefinacecomfinamount + $incasefinacecomextraamount + $incasefinacecompaamount;
         $accountingdetail->incasefinacetotalcomamount = $incasefinacetotalcomamount;
         $incasefinacetotalcomvat = $incasefinacecomfinamount * 0.07000000000000001 + $incasefinacecomextravat + $incasefinacecompavat;
         $accountingdetail->incasefinacetotalcomvat = $incasefinacetotalcomvat;
         $incasefinacetotalcomamountwithvat = $incasefinacetotalcomamount + $incasefinacetotalcomvat;
         $accountingdetail->incasefinacetotalcomamountwithvat = $incasefinacetotalcomamountwithvat;
         $incasefinacetotalcomwhtax = $incasefinacecomfinamount * 0.03 + $incasefinacecomextrawhtax + $incasefinacecompawhtax;
         $accountingdetail->incasefinacetotalcomwhtax = $incasefinacetotalcomwhtax;
         $incasefinacetotalcomtotal = $incasefinacecomfintotal + $incasefinacecomextratotal + $incasefinacecompatotal;
         $accountingdetail->incasefinacetotalcomtotal = $incasefinacetotalcomtotal;
         $receivedcashfromfinace = round($incasefinacehassubsidisereceivedcash, 2) + round($note2totalwhtax, 2) + round($incasefinacetotalcomtotal, 2);
         $accountingdetail->receivedcashfromfinace = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinacenet = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinaceshort = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinacenetshort = $receivedcashfromfinace;
         $accountingdetail->receivedcashfromfinaceover = 0;
         $accountingdetail->receivedcashfromfinacenetover = 0;
     } else {
         $yodjud = 0;
         $yodjudwithinsurancepremium = 0;
         $accountingdetail->incasefinacereceivedcash = 0;
     }
     $tradereceivableaccount2amount = $totalcash - $yodjudwithinsurancepremium;
     $accountingdetail->tradereceivableaccount2amount = $tradereceivableaccount2amount;
     $oldcarprice = $carpreemption->oldcarprice;
     $accountingdetail->oldcarprice = $oldcarprice;
     $overdue = $carpayment->overdue;
     $accountingdetail->overdue = $overdue;
     $tradereceivableaccount2remainingamount = $tradereceivableaccount2amount - $oldcarprice - $overdue;
     $accountingdetail->tradereceivableaccount2remainingamount = $tradereceivableaccount2remainingamount;
     $accountingdetail->ins = $accountingdetail->note1insurancefeeincludevat;
     //$carpreemption->insurancefee;
     $accountingdetail->prb = $accountingdetail->note1compulsorymotorinsurancefeeincludevat;
     //$carpreemption->compulsorymotorinsurancefee;
     $accountingdetail->dc = $carpreemption->accessories + $carpreemption->subdown;
     $accountingdetail->totalacc2 = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalacc2short = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalacc2over = 0;
     $accountingdetail->totalaccount2 = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalaccount2short = $tradereceivableaccount2remainingamount;
     $accountingdetail->totalaccount2over = 0;
     $arrNotFormatted = array("id", "purchasetype", "carpaymentid", "hasinsurancefee", "hascompulsorymotorinsurancefee", "hascashpledgeredlabel", "systemcalincasefinacecomfinamount", "systemcalincasefinacecomfinvat", "systemcalincasefinacecomfinamountwithvat", "systemcalincasefinacecomfinwhtax", "systemcalincasefinacecomfintotal", "receivedcashfromfinacenet", "receivedcashfromfinacenetshort", "receivedcashfromfinacenetover", "totalaccount1", "totalaccount1short", "totalaccount1over", "totalaccount2", "totalaccount2short", "totalaccount2over", 'totalaccounts', 'totalaccountsshort', 'totalaccountsover', "invoiceno", "additionalopenbill", "deliverycardate", "cashpledgeredlabelreceiptbookno", "cashpledgeredlabelreceiptno", "cashpledgeredlabelreceiptdate", "redlabelreturncashpledgedate", "cashpledgereceiptbookno", "cashpledgereceiptno", "cashpledgereceiptdate", "incasefinacecomfinamount", "incasefinacecomfinvat", "incasefinacecomfinamountwithvat", "incasefinacecomfinwhtax", "incasefinacecomfintotal", "oldcarcomamount", 'oldcarcomdate', "adj", "insurancefeereceiptcondition", "compulsorymotorinsurancefeereceiptcondition", "payinadvanceamountreimbursementdate", "payinadvanceamountreimbursementdocno", 'insurancebilldifferent', "note1insurancefeereceiptcondition", "note1compulsorymotorinsurancefeereceiptcondition", 'insurancefeepayment', 'insurancefeepaidseparatelydate', 'insurancepremiumnet', 'insurancepremiumcom', 'insurancefeepaidseparatelytotal', 'compulsorymotorinsurancefeepayment', 'compulsorymotorinsurancefeepaidseparatelydate', 'compulsorymotorinsurancepremiumnet', 'compulsorymotorinsurancepremiumcom', 'compulsorymotorinsurancefeepaidseparatelytotal', "carno", "installmentsinadvance", "installments", "comfinyear", "createdby", "createddate", "modifiedby", "modifieddate", 'actualinsurancefee');
     if ($donumberformat == 1) {
         foreach ($accountingdetail->toArray() as $key => $value) {
             if (!in_array($key, $arrNotFormatted)) {
                 if (is_numeric($value) && (double) $value != 0.0) {
                     $value = number_format($value, 2, '.', ',');
                 } else {
                     if ($value == null || $value == '' || is_numeric($value) && (double) $value == 0.0) {
                         $value = '-';
                     }
                 }
                 $accountingdetail->{$key} = $value;
             }
         }
     }
     return $accountingdetail;
 }
Ejemplo n.º 28
0
 public function todayTopSales(Carbon $date, $limit = 10)
 {
     $arr = [];
     $ds_null = false;
     $current_day_zero_sales = false;
     $ds = DailySales::where('date', $date->format('Y-m-d'))->orderBy('sales', 'DESC')->take($limit)->get();
     if (count($ds) == '0') {
         $ds = DailySales::where('date', $date->copy()->subDay()->format('Y-m-d'))->orderBy('sales', 'DESC')->take($limit)->get();
         $ds_null = true;
     } else {
         foreach ($ds as $d) {
             if ($d->sales == '0.00') {
                 $ds = DailySales::where('date', $date->copy()->subDay()->format('Y-m-d'))->orderBy('sales', 'DESC')->take($limit)->get();
                 $ds_null = true;
                 continue;
             }
         }
     }
     foreach ($ds as $d) {
         $branch = Branch::where('id', $d->branchid)->get(['code', 'descriptor', 'id'])->first();
         if ($ds_null) {
             $ds_today = new DailySales();
             $ds_yesteday = $d;
         } else {
             $ds_today = $d;
             $ds_yesteday = DailySales::where('date', $date->copy()->subDay()->format('Y-m-d'))->where('branchid', $d->branchid)->first();
         }
         $ds_otherday = DailySales::where('date', $date->copy()->subDay(2)->format('Y-m-d'))->where('branchid', $d->branchid)->first();
         $s = new StdClass();
         $c = new StdClass();
         $s->branch = $branch;
         $s->today = $ds_today;
         $s->yesterday = $ds_yesteday;
         $s->otherday = $ds_otherday;
         $c->sales = $ds_today->sales - $ds_yesteday->sales;
         $s->today->sign = $this->getSign($ds_today->sales - $ds_yesteday->sales);
         $c->sales1 = $ds_yesteday->sales - $ds_otherday->sales;
         $s->yesterday->sign = $this->getSign($ds_yesteday->sales - $ds_otherday->sales);
         $s->diff = $c;
         array_push($arr, $s);
     }
     return collect($arr);
 }
Ejemplo n.º 29
0
 public static function sendSMS($message, $phone, $service_id)
 {
     //ARA Adding sms as business feature
     $business_features = Business::getBusinessFeatures(Branch::businessId(Service::branchId($service_id)));
     if ($business_features['allow_sms'] == 'true') {
         $gateway = QueueSettings::smsGateway($service_id);
         $api_variables = unserialize(QueueSettings::smsGatewayApi($service_id));
         if ($gateway == 'frontline_sms') {
             $url = QueueSettings::frontlineUrl($service_id);
             $secret = QueueSettings::frontlineSecret($service_id);
             $api_key = null;
             if ($url == FRONTLINE_SMS_URL && $secret == FRONTLINE_SMS_SECRET) {
                 $url = $api_variables['frontline_sms_url'];
                 $api_key = $api_variables['frontline_sms_api_key'];
             }
             Notifier::sendFrontlineSMS($message, $phone, $url, $secret, $api_key);
         } else {
             if ($gateway == 'twilio') {
                 if ($api_variables['twilio_phone_number'] == TWILIO_PHONE_NUMBER && $api_variables['twilio_account_sid'] == TWILIO_ACCOUNT_SID && $api_variables['twilio_auth_token'] == TWILIO_AUTH_TOKEN) {
                     //@todo do something says that they are using featherq twilio service
                 }
                 $from = $api_variables['twilio_phone_number'];
                 $account_sid = $api_variables['twilio_account_sid'];
                 $auth_token = $api_variables['twilio_auth_token'];
                 Notifier::sendTwilio($phone, $message, $from, $account_sid, $auth_token);
             }
         }
     }
 }
Ejemplo n.º 30
-1
 public function index()
 {
     if (!$this->hasPermission($this->menuPermissionName)) {
         return view($this->viewPermissiondeniedName);
     }
     $branchs = Branch::all(['id', 'name']);
     $branchselectlist = array();
     array_push($branchselectlist, ':เลือกสาขา');
     foreach ($branchs as $item) {
         array_push($branchselectlist, $item->id . ':' . $item->name);
     }
     $departments = Department::all(['id', 'nameth', 'nameen']);
     $departmentselectlist = array();
     array_push($departmentselectlist, ':เลือกแผนก');
     foreach ($departments as $item) {
         array_push($departmentselectlist, $item->id . ':' . str_replace('&', '\\u0026', $item->nameth) . ' - ' . str_replace('&', '\\u0026', $item->nameen));
     }
     $teams = Team::all(['id', 'name']);
     $teamselectlist = array();
     array_push($teamselectlist, ':เลือกทีม');
     foreach ($teams as $item) {
         array_push($teamselectlist, $item->id . ':' . $item->name);
     }
     return view('employee', ['branchselectlist' => implode(";", $branchselectlist), 'departmentselectlist' => implode(";", $departmentselectlist), 'teamselectlist' => implode(";", $teamselectlist)]);
 }