| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454 |
- <?php
-
- namespace App\Http\Controllers\CustomerService;
-
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- use Illuminate\Support\Facades\Auth;
-
- use App\Mail\AssignWorkOrder;
- use App\Jobs\SendWorkOrder;
-
- 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;
- use App\Model\Coverage;
- use App\Model\Product;
- use App\Model\Docket;
- use App\Model\FormStatus;
-
- class WorkOrderController extends Controller
- {
-
- function random_code($limit) {
- return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
- }
-
- function createWorkID($limit){
- $number = WorkOrder::select('id','wo')->orderBy('created_at','DESC')->first();
- $numberOnly = str_replace('WO-','',$number->wo);
- $numberOnly++;
- return $numberOnly;
-
- // $allowedNumbers = range(0, 9);
- // shuffle($allowedNumbers);
- // $digits = array_rand($allowedNumbers, $limit);
- // $number = '';
-
- // foreach($digits as $d){
- // $number .= $allowedNumbers[$d];
- // }
- // $unique_id = $number;
- // return $unique_id;
- }
-
- public function viewWorkOrder()
- {
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $pc = count(WorkOrder::where('status','Pending Contractor')->get());
- $pi = count(WorkOrder::where('status','Pending Installer')->get());
- $cance = count(WorkOrder::where('status','Cancelled')->get());
-
- return view('customer-service.view_wo', compact('user','pp','sp','rs','ss','cm','pc','pi','cance'));
- }
-
- public function viewEditWorkOrder($wo)
- {
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $w = WorkOrder::where('wo',$wo)->first();
- $form = Form::with('Subscriber','WorkOrder')->where('_id',$w->_id)->first();
- $coverage = Coverage::all();
-
- return view('customer-service.edit_work_order', compact('user','pp','sp','rs','ss','cm','pc','pi','form','coverage'));
- }
-
-
- public function viewAddNewSchedule($status, $wo, $subscriber_id){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $company = Company::where('team','CBB')->get();
- $today = Carbon::today();
-
- return view('customer-service.view_add_new_schedule', compact('user','pp','sp','rs','ss','cm','company','wo','today','subscriber_id','status'));
- }
-
- public function viewRescheduleCalendar($wo){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $company = Company::where('team','CBB')->get();
- $today = Carbon::today();
-
- return view('customer-service.view_reschedule-work-order', compact('user','pp','sp','rs','ss','cm','company','wo','today'));
- }
-
- public function confirmWorkOrder($wo)
- {
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $w = WorkOrder::where('wo',$wo)->first();
- $form = Form::with('Subscriber','WorkOrder')->where('_id',$w->_id)->first();
- $coverage = Coverage::all();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- return view('customer-service.confirm_work_order', compact('user','pp','sp','rs','ss','cm','pc','pi','form','coverage','wo','company'));
- }
-
- public function viewCreateWorkOrderR()
- {
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $coverage = Coverage::where('Type','R')->get();
- $product = Product::where('formT','R')->get();
-
- return view('customer-service.view_wo_formR', compact('user','pp','sp','rs','ss','cm','pc','pi','coverage','product'));
- }
-
- public function viewCreateWorkOrderB()
- {
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $pp = count(WorkOrder::where('status','Pending Non Prelaid')->get());
- $sp = count(WorkOrder::where('status','Success Non Prelaid')->get());
- $rs = count(WorkOrder::where('status','Reschedule')->get());
- $ss = count(WorkOrder::where('status','Suspend')->get());
- $cm = count(WorkOrder::where('status','Completed')->get());
-
- $coverage = Coverage::where('Type','B')->get();
- $product = Product::where('formT','B')->get();
-
- return view('customer-service.view_wo_formB', compact('user','pp','sp','rs','ss','cm','pc','pi','coverage','product'));
- }
-
- public function getAllPendingContractor($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Pending Contractor')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Contractor')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Contractor')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
-
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllPendingNonPrelaid($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Non Prelaid')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllSuccessNonPrelaid($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Success Non Prelaid')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Success Non Prelaid')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Success Non Prelaid')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllPendingInstaller($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Pending Installer')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Installer')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Pending Installer')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->where('_id',$w->installer_id)->first();
- if(!empty($installer)){
- $installer = $installer->StaffDetail->name;
- }
-
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllReschedule($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Reschedule')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Reschedule')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Reschedule')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->withTrashed()->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllSuspend($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Suspend')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Suspend')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Suspend')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->withTrashed()->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllCancelled($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $wo = WorkOrder::with('Form')->where('status','Cancelled')->orderBy('created_at', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $wo = WorkOrder::with('Form')->where('status','Suspend')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $wo = WorkOrder::with('Form')->where('status','Suspend')->orderBy('created_at', 'desc')->whereBetween('created_at', [$go, $end_year])->get();
- }
-
- if(!empty($wo)){
- foreach ($wo as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->Form->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$w->Form->type_application)->first();
- $company = Company::where('_id',$w->contractor_id)->first();
-
- if($w->installer_id != ''){
- $installer = Staff::with('StaffDetail')->withTrashed()->where('_id',$w->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$w->Form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->dateTimeStart)),
- 'time' => date("h:i A", strtotime($w->dateTimeStart)),
- 'status' => $w->status,
- 'action' => $w->wo,
- ));
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function getAllCompleted($year,$month,$day){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $i = 0; $n1 = '';
- $curr = Carbon::now()->getTimestamp();
- $nested_data = array();
-
- if($year == 'null' && $month == 'null' && $day == 'null'){
- $doc = Docket::with('WorkOrder')->orderBy('end_job', 'desc')->get();
- }else if($year != 'null' && $month == 'null' && $day == 'null'){
-
- $timestamp = $year."-01-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfYear();
-
- $doc = Docket::with('WorkOrder')->orderBy('end_job', 'desc')->whereBetween('dateTimeStart', [$go, $end_year])->get();
-
- }else if($year != 'null' && $month != 'null' && $day == 'null'){
-
- $timestamp = $year."-".$month."-01 00:00:00.000Z";
- $masa = strtotime($timestamp);
- $go = Carbon::createFromTimestamp($masa);
- $go2 = Carbon::createFromTimestamp($masa);
- $end_year = $go2->endOfMonth();
-
- $doc = Docket::with('WorkOrder')->orderBy('end_job', 'desc')->whereBetween('dateTimeStart', [$go, $end_year])->get();
- }
-
- if(!empty($doc)){
- foreach ($doc as $key => $w) {
- $i++;
-
- $n1 = '';
- $reg_time = $w->created_at;
- $expiry_date = $reg_time->addDays(3);
- $expiry_date = $expiry_date->getTimestamp();
-
- if($curr < $expiry_date) {
- $n1 = "New/";
- }
-
- $installer = '';
- if(!empty($w->WorkOrder->_id)){
- $form = Form::with('Subscriber','PackageDetail')->where('_id',$w->WorkOrder->_id)->first();
- $product = Product::where('speed',$form->PackageDetail->name)->where('formT',$form->type_application)->first();
- $company = Company::where('_id',$w->WorkOrder->contractor_id)->first();
-
- if($w->WorkOrder->installer_id != ''){
- $installer = Staff::with('StaffDetail')->withTrashed()->where('_id',$w->WorkOrder->installer_id)->first();
- $installer = $installer->StaffDetail->name;
- }
-
- $building = ''; $unit = '-'; $name = '';
- if($form->type_application == 'R'){
- $name = $form->Subscriber->name;
- $building = $form->Subscriber->building_name;
- $unit = $form->Subscriber->unit_no;
-
- }else if($form->type_application == 'B'){
- $unit = $form->Subscriber->unit_no;
- $name = $form->Subscriber->company_name;
- $building = $form->Subscriber->street;
- }
-
- if(empty($product)){
- $product = 'R Mbps';
- }else {
- $product = $product->package_name;
- }
-
- array_push($nested_data, array(
- 'formT' => $n1.$i.$form->type_application,
- 'service' => $w->nature_work,
- 'wo' => $w->WorkOrder->wo,
- 'name' => $name,
- 'phone' => $form->Subscriber->phone1,
- 'unit' => $unit,
- 'building' => $building,
- 'city' => $form->Subscriber->city,
- 'package' => $product,
- 'contractor' => $company->name,
- 'installer' => $installer,
- 'date' => date("d/m/Y", strtotime($w->end_job)),
- 'time' => date("h:i A", strtotime($w->end_job)),
- 'status' => $w->WorkOrder->status,
- 'docket' => $w->docket_id,
- 'action' => $w->WorkOrder->wo,
- ));
- }
- }
- }
-
- return \DataTables::of($nested_data)->make(true);
- }
-
- public function generateWorkOrderPDF($wo){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $wo = WorkOrder::where('wo',$wo)->first();
- $form = Form::with('PackageDetail','Subscriber')->where('_id',$wo->_id)->first();
- $product = Product::where('formT',$form->type_application)->where('speed',$form->PackageDetail->name)->first();
-
- if(empty($product)){
- if($form->PackageDetail->name == "30"){
- $product = '30Mbps';
- }else{
- $product = 'RMbps';
- }
- }else {
- $product = $product->package_name;
- }
-
- $created_by = Staff::with('StaffDetail')->where("_id",$wo->created_by)->first();
- if(empty($created_by)){
- $created_by = '';
- }
-
- $created_at = Carbon::parse($wo->created_at)->toDateTimeString();
-
- $address = '';
- if($form->type_application == 'R'){
- if($form->Subscriber->street != ''){
- $address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
- }else {
- $address = $form->Subscriber->unit_no. ' , '.$form->Subscriber->building_name. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
- }
-
- }else if($form->type_application == 'B'){
-
- if($form->Subscriber->unit_no != ''){
- $address = $form->Subscriber->unit_no. ', '.$form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
- }else {
- $address = $form->Subscriber->company_name. ', '.$form->Subscriber->street. ' , '.$form->Subscriber->postcode. ' , '.$form->Subscriber->city. ' , '.$form->Subscriber->state;
- }
-
- }
-
-
- $pdf = PDF::loadView('pdf.workorder-pdf',compact('wo','form','product','created_at','created_by','address'));
- $pdf->setPaper('A4', 'potrait');
- return $pdf->stream();
- }
-
- public function sendWorkOrders($work_order_id) {
-
- $work_order = WorkOrder::where('wo',$work_order_id)->first();
- $s = StaffDetail::where('company_id',$work_order->contractor_id)->where('position','Contractor')->get();
- $customer = Subscriber::where('_id',$work_order->_id)->first();
- if($work_order->contractor_id == '5b42b935ee0dc2b707473b76'){
- $company = Company::where('_id',$work_order->contractor_id)->first();
- $staff = StaffDetail::where('company_id',$work_order->contractor_id)->where('email','mimi@jitech.com.my')->first();
- SendWorkOrder::dispatch($work_order,$staff,'cbbinstallation@jitech.com.my',$customer,$company);
- }else {
- $company = Company::where('_id',$work_order->contractor_id)->first();
- foreach($s as $staff){
- SendWorkOrder::dispatch($work_order,$staff,$staff->email,$customer,$company);
- }
- }
- }
-
- public function updateWorkOrder(Request $request){
-
- $id = Auth::guard('cs')->id();
- $user = Staff::with('StaffDetail')->find($id);
-
- $wo = WorkOrder::where('wo',$request->work_order)->first();
- if(!empty($wo)){
-
- $number_phone = '';
- if($request->n_phone == 'Yes'){
- $number_phone = $request->no_phone;
- }
-
- $wo->nature_work = $request->task;
- $wo->pppoe_username = $request->pppoe_username;
- $wo->onu = $request->onu_ont;
- $wo->router = $request->router;
- $wo->need_phone = $request->n_phone;
- $wo->no_phone = $number_phone;
- $wo->remarks_custservice = $request->remark;
- $wo->created_by = $user->_id;
- $wo->save();
-
- $form = Form::where('_id',$wo->_id)->first();
- $contractor = Company::where('_id',$wo->contractor_id)->first();
-
- $status = ''; $st_id = '';
- if($wo->status == 'Pending Contractor'){
- $st_id = 4;
- $status = 'Pending Contractor';
- }else if($wo->status == 'Pending Non Prelaid'){
- $st_id = 5;
- $status = 'Pending Non Prelaid';
- }
-
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = $st_id;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = $status;
- $formH->desc = 'This work order been assigned to particular contractor ('.$contractor->name.')';
- $form->formstatus()->save($formH);
-
- $this->sendWorkOrders($request->work_order);
- return redirect('/customer-service/work-order/list');
- // return redirect()->back()->with('success_msg', 'Success! Update work order '.$request->get('work_order'));
- }else {
- return redirect()->back()->with('error_msg', 'Cant update work order '.$request->get('work_order'));
- }
- }
-
- public function addSchedule(Request $request){
-
- $subscriber = Subscriber::where('subscriber_id',$request->subscriber_id)->first();
- if(!empty($subscriber)){
-
- $wod = WorkOrder::where('wo',$request->wo)->first();
- if(empty($wod)){
-
- $status = '';
- if($request->status == 'non-prelaid'){
- $status = 'Pending Non Prelaid';
- }else {
- $status = 'Pending Contractor';
- }
-
- $form = Form::where('_id',$subscriber->_id)->first();
- $work_order = new WorkOrder;
- $work_order->img_url = '/assets/img/activation_icon_nRead1.png';
- $work_order->wo = $request->wo;
- $work_order->nature_work = '';
- $work_order->sub_category = '';
- $work_order->dateTimeStart = $request->start;
- $work_order->dateTimeEnd = $request->end;
- $work_order->contractor_id = $request->vendor;
- $work_order->installer_id = '';
- $work_order->onu = '';
- $work_order->router = '';
- $work_order->need_phone = '';
- $work_order->no_phone = '';
- $work_order->pppoe_username = '';
- $work_order->pppoe_password = '';
- $work_order->docket_id = '';
- $work_order->remarks_custservice = '';
- $work_order->remarks_installer = '';
- $work_order->status = $status;
- $work_order->created_by = $request->created_by;
-
- $form->workorder()->save($work_order);
-
- return 'success';
-
- }else{
-
- $wod->dateTimeStart = $request->start;
- $wod->dateTimeEnd = $request->end;
- $wod->contractor_id = $request->vendor;
- $wod->save();
- }
-
- }else{
- return 'false';
- }
- }
-
- public function rescheduleWorkOrder(Request $request){
-
- $wod = WorkOrder::where('wo',$request->wo)->first();
- if(!empty($wod)){
-
- $wod->dateTimeStart = $request->start;
- $wod->dateTimeEnd = $request->end;
- $wod->contractor_id = $request->vendor;
- $wod->status = 'Pending Contractor';
- $wod->save();
- return 'success';
-
- }else{
- return 'false';
- }
- }
-
- public function cancelCreateWorkOrder(Request $request){
- $wod = WorkOrder::where('wo',$request->wo)->first();
- if(!empty($wod)){
- $wod->delete();
- return 'true';
- }else{
- return 'false';
- }
- }
-
- public function deleteWorkOrder(Request $request){
- $wod = WorkOrder::where('wo',$request->id)->first();
- if(!empty($wod)){
- $wod->delete();
- $form = Form::where('_id',$wod->_id)->first();
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = 9;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = 'Delete Work Order';
- $formH->desc = 'This work order for this customer already been deleted!';
- $form->formstatus()->save($formH);
-
- return 'true';
- }else{
- return 'false';
- }
- }
-
- public function checkExistingWorkOrder(Request $request)
- {
- $data = array();
- $wod = WorkOrder::where('wo',$request->wo)->first();
- if(!empty($wod)){
-
- array_push($data, array(
- 'result' => 'yes',
- ));
-
- }else{
-
- $subscriber = Subscriber::where('subscriber_id',$request->subscriber_id)->first();
- if(!empty($subscriber)){
-
- $form = Form::where('_id',$subscriber->_id)->first();
- $work_order = new WorkOrder;
- $work_order->img_url = '/assets/img/activation_icon_nRead1.png';
- $work_order->wo = $request->wo;
- $work_order->nature_work = '';
- $work_order->sub_category = '';
- $work_order->dateTimeStart = '';
- $work_order->dateTimeEnd = '';
- $work_order->contractor_id = $request->vendor;
- $work_order->installer_id = '';
- $work_order->onu = '';
- $work_order->router = '';
- $work_order->need_phone = '';
- $work_order->no_phone = '';
- $work_order->pppoe_username = '';
- $work_order->pppoe_password = '';
- $work_order->docket_id = '';
- $work_order->remarks_custservice = '';
- $work_order->remarks_installer = '';
- $work_order->status = 'Pending Non Prelaid';
- $form->workorder()->save($work_order);
-
- array_push($data, array(
- 'result' => 'yes',
- ));
- }
- }
-
- return response()->json($data);
- }
-
- public function updateWorkOrderReschedule(Request $request)
- {
- $data = array();
- $wod = WorkOrder::where('wo',$request->wo)->first();
- $form = Form::where('_id',$wod->_id)->first();
- $contractor = Company::where('_id',$wod->contractor_id)->first();
-
- if(!empty($wod)){
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = 4;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = 'Pending Contractor';
- $formH->desc = 'This work order been reassigned to particular contractor ('.$contractor->name.')';
- $form->formstatus()->save($formH);
-
- $this->sendWorkOrders($request->wo);
- array_push($data, array(
- 'result' => 'yes',
- ));
- }else{
- array_push($data, array(
- 'result' => 'no',
- ));
- }
-
- return response()->json($data);
- }
-
- public function createRectification(Request $request)
- {
-
- $su_id = ''; $pathIconF = ''; $pathIconB = '';
-
- $sl = Form::create([
- 'type_service' => 'Rectification',
- 'type_application' => $request->formT,
- 'status_payment' => 'paid',
- 'status_email' => 'verified',
- 'remark_form' => ''
- ]);
-
- if($request->formT == 'R'){
-
- do {
- $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
- } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
-
- $coverage = Coverage::where('_id',$request->buildingsss)->first();
-
- $sdl = new Subscriber();
- $sdl->subscriber_id = $su_id;
- $sdl->name = $request->name;
- $sdl->ic = '';
- $sdl->citizen = '';
- $sdl->gender = '';
- $sdl->race = '';
- $sdl->email = '';
- $sdl->phone1 = $request->phone1;
- $sdl->phone2 = $request->phone2;
- $sdl->unit_no = $request->unit_no;
- $sdl->building_name = $coverage->building_name;
- $sdl->street = $request->street;
- $sdl->postcode = $coverage->postcode;
- $sdl->city = $coverage->city;
- $sdl->state = $coverage->state;
- $sdl->front_ic = '';
- $sdl->back_ic = '';
- $sdl->signature = '';
-
- $packageD = new PackageDetail();
- $packageD->contract = '';
- $packageD->name = $request->package;
- $packageD->montly_fee = '';
- $packageD->voice_fee = '';
- $packageD->deposit = '';
- $packageD->upfront_payment = '';
- $packageD->rfs = '';
-
- $sl->subscriber()->save($sdl);
- $sl->packagedetail()->save($packageD);
-
- $subs = Subscriber::where('subscriber_id',$su_id)->first();
- $form = Form::where('_id',$subs->_id)->first();
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = 12;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = 'New Rectification';
- $formH->desc = 'Rectification form been submitted';
- $form->formstatus()->save($formH);
-
- $wo = '';
- do {
- $wo = 'WO-'.$this->createWorkID(4);
- } while (WorkOrder::where("wo", "=", $wo)->first() instanceof WorkOrder);
-
- return redirect()->to('/customer-service/work-order/add/schedule/rectification/'.$wo.'/'. $su_id);
-
- }else if($request->formT == 'B'){
-
- do {
- $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
- } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
-
- $sdl = new Subscriber();
- $sdl->subscriber_id = $su_id;
- $sdl->company_name = $request->cname;
- $sdl->company_reg = '';
- $sdl->company_num = '';
- $sdl->company_fax = '';
- $sdl->name = $request->name;
- $sdl->ic = '';
- $sdl->designation = '';
- $sdl->email = '';
- $sdl->phone1 = $request->phone1;
- $sdl->phone2 = '';
- $sdl->unit_no = $request->unit_no;
- $sdl->street = $request->caddress;
- $sdl->postcode = '';
- $sdl->city = '';
- $sdl->state = '';
- $sdl->front_ic = '';
- $sdl->back_ic = '';
- $sdl->form24_49 = '';
- $sdl->form9_44 = '';
-
- $packageD = new PackageDetail();
- $packageD->contract = '';
- $packageD->name = $request->package;
- $packageD->montly_fee = '';
- $packageD->voice_fee = 'No';
- $packageD->deposit = '';
- $packageD->upfront_payment = '';
- $packageD->rfs = '';
-
- $sl->subscriber()->save($sdl);
- $sl->packagedetail()->save($packageD);
-
- $subs = Subscriber::where('subscriber_id',$su_id)->first();
- $form = Form::where('_id',$subs->_id)->first();
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = 12;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = 'New Rectification';
- $formH->desc = 'Rectification form been submitted';
- $form->formstatus()->save($formH);
-
- $wo = '';
- do {
- $wo = 'WO-'.$this->createWorkID(4);
- } while (WorkOrder::where("wo", "=", $wo)->first() instanceof WorkOrder);
-
- return redirect()->to('/customer-service/work-order/add/schedule/rectification/'.$wo.'/'. $su_id);
- }
- }
-
- public function createSecuredDevelopement(Request $request)
- {
- $su_id = ''; $pathIconF = ''; $pathIconB = '';
-
- do {
- $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
- } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
-
- $sl = Form::create([
- 'type_service' => $request->app,
- 'type_application' => 'R',
- 'status_payment' => 'paid',
- 'status_email' => 'verified',
- 'remark_form' => ''
- ]);
-
- $building = '-'; $postcode = '-'; $city = '-'; $state = '-';
- $coverage = Coverage::where('_id',$request->buildingssss,'Type','R')->first();
- if(!empty($coverage)){
- $building = $coverage->building_name;
- $postcode = $coverage->postcode;
- $city = $coverage->city;
- $state = $coverage->state;
- }else {
- $building = $request->buildingssss;
- $postcode = '-';
- $city = '-';
- $state = '-';
- }
-
- $sdl = new Subscriber();
- $sdl->subscriber_id = $su_id;
- $sdl->name = $request->name;
- $sdl->ic = '<b>Package Development</b>';
- $sdl->citizen = $request->citizensss;
- $sdl->gender = $request->gender;
- $sdl->race = $request->race;
- $sdl->email = '<b>Package Development</b>';
- $sdl->phone1 = $request->phone1;
- $sdl->phone2 = $request->phone2;
- $sdl->unit_no = $request->unit_no;
- $sdl->building_name = $building;
- $sdl->street = $request->street;
- $sdl->postcode = $postcode;
- $sdl->city = $city;
- $sdl->state = $state;
- $sdl->front_ic = '';
- $sdl->back_ic = '';
- $sdl->signature = '';
-
- $packageD = new PackageDetail();
- $packageD->contract = '24';
- $packageD->name = $request->package;
- $packageD->montly_fee = '';
- $packageD->voice_fee = 'No';
- $packageD->deposit = '';
- $packageD->upfront_payment = '';
- $packageD->rfs = '';
-
- $sl->subscriber()->save($sdl);
- $sl->packagedetail()->save($packageD);
-
- $subs = Subscriber::where('subscriber_id',$su_id)->first();
- $form = Form::where('_id',$subs->_id)->first();
- $formH = new FormStatus;
- $formH->form_id = $form->_id;
- $formH->status_id = 13;
- $formH->date = new \MongoDB\BSON\UTCDateTime(time()*1000);
- $formH->status = 'Secured Development';
- $formH->desc = 'Secured development form been submitted';
- $form->formstatus()->save($formH);
-
- $wo = '';
- do {
- $wo = 'WO-'.$this->createWorkID(4);
- } while (WorkOrder::where("wo", "=", $wo)->first() instanceof WorkOrder);
-
- return redirect()->to('/customer-service/work-order/add/schedule/secured/'.$wo.'/'. $su_id);
-
- }
- }
|