123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
-
- namespace App\Http\Controllers\Contractor;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Auth;
-
- use Carbon\Carbon;
- use Validator;
- use PDF;
-
- use App\Staff;
- use App\Model\StaffDetail;
- use App\Model\Form;
- use App\Model\Subscriber;
- use App\Model\WorkOrder;
- use App\Model\PackageDetail;
- use App\Model\Company;
-
- class CalendarController extends Controller
- {
-
- public function viewContractorDashboard()
- {
- $id = Auth::guard('contractor')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->where('contractor_id',$user->StaffDetail->company_id)->get());
- $rs = count(WorkOrder::where('status','Reschedule')->where('contractor_id',$user->StaffDetail->company_id)->get());
- $ss = count(WorkOrder::where('status','Suspend')->where('contractor_id',$user->StaffDetail->company_id)->get());
- $cm = count(WorkOrder::where('status','Completed')->where('contractor_id',$user->StaffDetail->company_id)->get());
-
- $today = Carbon::today();
-
- return view('contractor.view_dashboard', compact('user','pp','sp','rs','ss','cm','today'));
- }
-
- public function getAllCalendar(Request $request){
-
- $id = Auth::guard('contractor')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $event = array(); $color = '';
- $cuw = $request->wk;
-
- if($request->status == ''){
-
- $wo = WorkOrder::where('contractor_id',$user->StaffDetail->company_id)->get();
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
-
- if($w->wo == $cuw){
- $color = '#5C2983';
- }else if($w->wo != $cuw) {
- if($w->status == "Completed") {
- $color = '#00C853';
- }else if($w->status == "Suspend") {
- $color = '#DE006E';
- }else if($w->status == "Reschedule") {
- $color = '#FF6D00';
- }else if($w->status == "Success Non Prelaid"){
- $color = '#2962FF';
- }else if($w->status == "Pending Non Prelaid"){
- $color = '#FFD600';
- }else if($w->status == "Pending Contractor") {
- $color = '#6D4C41';
- }else if($w->status == "Pending Installer"){
- $color = '#546E7A';
- }
- }
-
- array_push($event, array(
- 'id' => $w->wo,
- 'title' => $w->wo,
- 'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
- 'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
- 'url' => url('/contractor/work-order/generate-pdf/'.$w->wo),
- 'color' => $color,
- 'allDay' => false
- ));
- }
- }
-
- }else if($request->status != ''){
-
- $wo = WorkOrder::where('status',$request->status)->where('contractor_id',$user->StaffDetail->company_id)->get();
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
-
- if($w->wo == $cuw){
- $color = '#5C2983';
- }else if($w->wo != $cuw) {
- if($w->status == "Completed") {
- $color = '#00C853';
- }else if($w->status == "Suspend") {
- $color = '#DE006E';
- }else if($w->status == "Reschedule") {
- $color = '#FF6D00';
- }else if($w->status == "Success Non Prelaid"){
- $color = '#2962FF';
- }else if($w->status == "Pending Non Prelaid"){
- $color = '#FFD600';
- }else if($w->status == "Pending Contractor") {
- $color = '#6D4C41';
- }else if($w->status == "Pending Installer"){
- $color = '#546E7A';
- }
- }
-
- array_push($event, array(
- 'id' => $w->wo,
- 'title' => $w->wo,
- 'start' => Carbon::createFromTimestamp(strtotime($w->dateTimeStart))->toRfc2822String(),
- 'end' => Carbon::createFromTimestamp(strtotime($w->dateTimeEnd))->toRfc2822String(),
- 'url' => url('/contractor/work-order/generate-pdf/'.$w->wo),
- 'color' => $color,
- 'allDay' => false
- ));
- }
- }
-
- }
-
- return response()->json($event);
- }
-
- public function getCompanyColor(Request $request){
-
- $datass = array();
- $company = Company::where("_id",$request->company)->first();
-
- if(!empty($company)){
- array_push($datass, array(
- 'name' => '('.$company->name.')',
- 'bg' => $company->color,
- 'text' => '#fff'
- ));
-
- }else {
- array_push($datass, array(
- 'name' => '',
- 'bg' => '#fff',
- 'text' => '#5F5F5F'
- ));
- }
-
- return response()->json($datass);
- }
- }
|