Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TestController.php 40KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. <?php
  2. namespace App\Http\Controllers\DS;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Auth;
  6. use Carbon\Carbon;
  7. use File;
  8. use Validator;
  9. use PDF;
  10. use Config;
  11. Use Mail;
  12. Use App\StaffOld;
  13. Use App\Staff;
  14. Use App\Model\StaffDetail;
  15. Use App\Model\Company;
  16. Use App\Model\OldBusiness;
  17. Use App\Model\OldResidential;
  18. Use App\Model\OldDocket;
  19. Use App\Model\OrderHistory;
  20. use App\Model\OldWorkOrder;
  21. Use App\Model\Subscriber;
  22. Use App\Model\Coverage;
  23. Use App\Model\Form;
  24. Use App\Model\PackageDetail;
  25. Use App\Model\WorkOrder;
  26. Use App\Model\Docket;
  27. Use App\Model\FormStatus;
  28. class TestController extends Controller {
  29. public function sortBy()
  30. {
  31. $i = 0;
  32. $arr = array();
  33. $docket=DocketLaravel::orderBy('created_at', 'desc')->get();
  34. $nested_data = array();
  35. foreach($docket as $a)
  36. {
  37. $customer = Subscriber::where('_id', $a->customer_id)->first();
  38. $business = Business::where('_id', $a->customer_id)->first();
  39. if(!empty($customer))
  40. {
  41. $arr[]=$a;
  42. }
  43. if(!empty($business))
  44. {
  45. $arr[]=$a;
  46. };
  47. }
  48. foreach($arr as $b)
  49. {
  50. $i++; $n1 = '';
  51. $tempContractor = CompanyLaravel::where('_id', $b->contractor_id)->first();
  52. $contractor = $tempContractor->name;
  53. $tempInstaller = StaffDetailLaravel::where('_id', $b->installer_id)->first();
  54. $tempCustomer = Subscriber::where('_id', $b->customer_id)->first();
  55. $tempBusiness = Business::where('_id', $b->customer_id)->first();
  56. if(!empty($tempCustomer))
  57. {
  58. $building = $tempCustomer->building;
  59. }
  60. else
  61. {
  62. $building = $tempBusiness->company_name;
  63. }
  64. if(!empty($tempInstaller))
  65. {
  66. array_push($nested_data, array(
  67. 'index' => $n1.$i,
  68. 'docket_id' => $b->docket_id,
  69. 'work_order_id' => $b->work_order_id,
  70. 'nature_work' => $b->nature_work,
  71. 'contractor_id' => $contractor,
  72. 'installer_name' => $tempInstaller->name,
  73. 'customer_id' => $building,
  74. 'installer_id' => $tempInstaller->phone,
  75. 'end_job' => $b->end_job,
  76. 'rating' => $b->Rating1
  77. ));
  78. }
  79. else
  80. {
  81. array_push($nested_data, array(
  82. 'index' => $n1.$i,
  83. 'docket_id' => $a->docket_id,
  84. 'work_order_id' => $a->work_order_id,
  85. 'nature_work' => $a->nature_work,
  86. 'contractor_id' => $contractor,
  87. 'installer_name' => '',
  88. 'customer_id' => $building,
  89. 'installer_id' => '',
  90. 'end_job' => $a->end_job,
  91. 'rating' => $a->Rating1
  92. ));
  93. }
  94. }
  95. foreach($nested_data as $c)
  96. {
  97. echo $c["end_job"]."<br>";
  98. }
  99. }
  100. function random_code($limit) {
  101. return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
  102. }
  103. //*********************************************************************** Check Work Order & Form *******************************************************/
  104. public function checkAvailableWorkOrder(){
  105. $oldWork = WorkDetail::where('formT','R')->get()->toArray();
  106. $subs = Subscriber::where('dealer','=','')->get();
  107. $a = array();
  108. foreach($subs as $s){
  109. if(array_search($s->wo, array_column($oldWork, 'wo')) !== False) {
  110. $a[] = $s;
  111. }
  112. }
  113. dd($a);
  114. }
  115. //*********************************************************************** Convert Form, Subscribers, Package Form, Work Order *******************************************************/
  116. public function convertFormAndRelation(){
  117. $newCoverage = Form::get()->toArray();
  118. $oldCoverage = OldResidential::all();
  119. $count = count($oldCoverage);
  120. $id = 0; $i = 0;
  121. foreach($oldCoverage as $c){
  122. if(array_search($c->_id, array_column($newCoverage, '_id')) !== False) {
  123. } else {
  124. if($c->dealer == ''){
  125. $sl = Form::create([
  126. '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  127. 'type_service' => $c->type_application,
  128. 'type_application' => 'R',
  129. 'status_payment' => $c->status,
  130. 'status_email' => $c->status1,
  131. 'remark_form' => $c->remarks,
  132. 'dealer_id' => $c->dealer,
  133. 'company_id' => $c->dealer_company,
  134. 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  135. ]);
  136. $su_id = '';
  137. do {
  138. $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  139. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  140. $sdl = new Subscriber();
  141. $sdl->subscriber_id = $su_id;
  142. $sdl->name = $c->name;
  143. $sdl->ic = $c->ic;
  144. $sdl->citizen = $c->citizen;
  145. $sdl->gender = $c->gender;
  146. $sdl->race = $c->race;
  147. $sdl->email = $c->email;
  148. $sdl->phone1 = $c->phone1;
  149. $sdl->phone2 = $c->phone2;
  150. $sdl->unit_no = $c->unit_no;
  151. $sdl->building_name = $c->building;
  152. $sdl->street = $c->street;
  153. $sdl->postcode = $c->postcode;
  154. $sdl->city = $c->city;
  155. $sdl->state = $c->state;
  156. $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  157. $sdl->back_ic = str_replace("data","/document",$c->imageback);
  158. $sdl->signature = str_replace("data","/document",$c->signature);
  159. $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  160. $packageD = new PackageDetail();
  161. $packageD->contract = $c->contract;
  162. $packageD->name = $c->package;
  163. $packageD->montly_fee = '';
  164. $packageD->voice_fee = $c->voice;
  165. $packageD->deposit = '';
  166. $packageD->upfront_payment = '';
  167. $packageD->rfs = $c->rfs;
  168. if($c->wo != ''){
  169. $getWo = OldWorkOrder::all();
  170. foreach($getWo as $w){
  171. if($w->wo == $c->wo){
  172. $woD = new WorkOrder();
  173. $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  174. $woD->wo = $w->wo;
  175. $woD->nature_work = $w->nature_work;
  176. $woD->sub_category = $w->sub_category;
  177. $woD->dateTimeStart = $w->dateTimeStart;
  178. $woD->dateTimeEnd = $w->dateTimeEnd;
  179. $woD->contractor_id = $w->contractor_id;
  180. $woD->installer_id = $w->installer_id;
  181. $woD->onu = $w->onu;
  182. $woD->router = $w->router;
  183. $woD->need_phone = $w->n_phone;
  184. $woD->no_phone = $w->no_phone;
  185. $woD->pppoe_username = $w->pppoe_username;
  186. $woD->pppoe_password = '';
  187. $woD->docket_id = $w->docket;
  188. $woD->remarks_custservice = $w->remarks;
  189. $woD->remarks_installer = $w->remarks_inst;
  190. $woD->status = $w->status;
  191. $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  192. $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  193. $sl->workorder()->save($woD);
  194. }
  195. }
  196. }
  197. $sl->subscriber()->save($sdl);
  198. $sl->packagedetail()->save($packageD);
  199. $i++;
  200. }else {
  201. $sl = new Form();
  202. $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  203. $sl->type_service = $c->type_application;
  204. $sl->type_application = 'R';
  205. $sl->status_payment = $c->status;
  206. $sl->status_email = $c->status1;
  207. $sl->remark_form = $c->remarks;
  208. $sl->dealer_id = $c->dealer;
  209. $sl->company_id = $c->dealer_company;
  210. $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  211. // staff
  212. $staff = Staff::where('_id',$c->dealer)->first();
  213. // dd($c->dealer);
  214. $staff->form()->save($sl);
  215. $su_id = '';
  216. do {
  217. $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  218. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  219. $sdl = new Subscriber();
  220. $sdl->subscriber_id = $su_id;
  221. $sdl->name = $c->name;
  222. $sdl->ic = $c->ic;
  223. $sdl->citizen = $c->citizen;
  224. $sdl->gender = $c->gender;
  225. $sdl->race = $c->race;
  226. $sdl->email = $c->email;
  227. $sdl->phone1 = $c->phone1;
  228. $sdl->phone2 = $c->phone2;
  229. $sdl->unit_no = $c->unit_no;
  230. $sdl->building_name = $c->building;
  231. $sdl->street = $c->street;
  232. $sdl->postcode = $c->postcode;
  233. $sdl->city = $c->city;
  234. $sdl->state = $c->state;
  235. $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  236. $sdl->back_ic = str_replace("data","/document",$c->imageback);
  237. $sdl->signature = str_replace("data","/document",$c->signature);
  238. $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  239. $packageD = new PackageDetail();
  240. $packageD->contract = $c->contract;
  241. $packageD->name = $c->package;
  242. $packageD->montly_fee = '';
  243. $packageD->voice_fee = $c->voice;
  244. $packageD->deposit = '';
  245. $packageD->upfront_payment = '';
  246. $packageD->rfs = $c->rfs;
  247. if($c->wo != ''){
  248. $getWo = OldWorkOrder::all();
  249. foreach($getWo as $w){
  250. if($w->wo == $c->wo){
  251. $woD = new WorkOrder();
  252. $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  253. $woD->wo = $w->wo;
  254. $woD->nature_work = $w->nature_work;
  255. $woD->sub_category = $w->sub_category;
  256. $woD->dateTimeStart = $w->dateTimeStart;
  257. $woD->dateTimeEnd = $w->dateTimeEnd;
  258. $woD->contractor_id = $w->contractor_id;
  259. $woD->installer_id = $w->installer_id;
  260. $woD->onu = $w->onu;
  261. $woD->router = $w->router;
  262. $woD->need_phone = $w->n_phone;
  263. $woD->no_phone = $w->no_phone;
  264. $woD->pppoe_username = $w->pppoe_username;
  265. $woD->pppoe_password = '';
  266. $woD->docket_id = $w->docket;
  267. $woD->remarks_custservice = $w->remarks;
  268. $woD->remarks_installer = $w->remarks_inst;
  269. $woD->status = $w->status;
  270. $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  271. $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  272. $sl->workorder()->save($woD);
  273. }
  274. }
  275. }
  276. $sl->subscriber()->save($sdl);
  277. $sl->packagedetail()->save($packageD);
  278. $id++;
  279. }
  280. }
  281. }
  282. dd('Semua- '.$count. ' -D ' .$id .' -ND '.$i);
  283. }
  284. public function convertFormAndRelationBusiness(){
  285. $newCoverage = Form::get()->toArray();
  286. $oldCoverage = OldBusiness::all();
  287. $count = count($oldCoverage);
  288. $id = 0; $i = 0;
  289. foreach($oldCoverage as $c){
  290. if(array_search($c->_id, array_column($newCoverage, '_id')) !== False) {
  291. } else {
  292. if($c->dealer == ''){
  293. $sl = Form::create([
  294. '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  295. 'type_service' => $c->type_application,
  296. 'type_application' => 'B',
  297. 'status_payment' => $c->status,
  298. 'status_email' => $c->status1,
  299. 'remark_form' => $c->remarks,
  300. 'dealer_id' => $c->dealer,
  301. 'company_id' => $c->dealer_company,
  302. 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  303. ]);
  304. $su_id = '';
  305. do {
  306. $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  307. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  308. $sdl = new Subscriber();
  309. $sdl->subscriber_id = $su_id;
  310. $sdl->company_name = $c->company_name;
  311. $sdl->company_reg = $c->company_reg;
  312. $sdl->company_num = $c->company_num;
  313. $sdl->company_fax = $c->company_fax;
  314. $sdl->name = $c->name;
  315. $sdl->ic = $c->ic;
  316. $sdl->designation = $c->designation;
  317. $sdl->gender = $c->gender;
  318. $sdl->race = $c->race;
  319. $sdl->email = $c->email;
  320. $sdl->phone1 = $c->phone1;
  321. $sdl->phone2 = $c->phone2;
  322. $sdl->unit_no = '';
  323. $sdl->street = $c->address;
  324. $sdl->postcode = $c->postcode;
  325. $sdl->city = $c->city;
  326. $sdl->state = $c->state;
  327. $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  328. $sdl->back_ic = str_replace("data","/document",$c->imageback);
  329. $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  330. $sdl->form9_44 = str_replace("data","/document",$c->formD);
  331. $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  332. $packageD = new PackageDetail();
  333. $packageD->contract = $c->contract;
  334. $packageD->name = $c->package;
  335. $packageD->montly_fee = '';
  336. $packageD->voice_fee = $c->voice;
  337. $packageD->deposit = '';
  338. $packageD->upfront_payment = '';
  339. $packageD->rfs = $c->rfs;
  340. if($c->wo != ''){
  341. $getWo = OldWorkOrder::all();
  342. foreach($getWo as $w){
  343. if($w->wo == $c->wo){
  344. $woD = new WorkOrder();
  345. $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  346. $woD->wo = $w->wo;
  347. $woD->nature_work = $w->nature_work;
  348. $woD->sub_category = $w->sub_category;
  349. $woD->dateTimeStart = $w->dateTimeStart;
  350. $woD->dateTimeEnd = $w->dateTimeEnd;
  351. $woD->contractor_id = $w->contractor_id;
  352. $woD->installer_id = $w->installer_id;
  353. $woD->onu = $w->onu;
  354. $woD->router = $w->router;
  355. $woD->need_phone = $w->n_phone;
  356. $woD->no_phone = $w->no_phone;
  357. $woD->pppoe_username = $w->pppoe_username;
  358. $woD->pppoe_password = '';
  359. $woD->docket_id = $w->docket;
  360. $woD->remarks_custservice = $w->remarks;
  361. $woD->remarks_installer = $w->remarks_inst;
  362. $woD->status = $w->status;
  363. $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  364. $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  365. $sl->workorder()->save($woD);
  366. }
  367. }
  368. }
  369. $sl->subscriber()->save($sdl);
  370. $sl->packagedetail()->save($packageD);
  371. $i++;
  372. }else {
  373. $sl = new Form();
  374. $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  375. $sl->type_service = $c->type_application;
  376. $sl->type_application = 'B';
  377. $sl->status_payment = $c->status;
  378. $sl->status_email = $c->status1;
  379. $sl->remark_form = $c->remarks;
  380. $sl->dealer_id = $c->dealer;
  381. $sl->company_id = $c->dealer_company;
  382. $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  383. // staff
  384. $staff = Staff::where('_id',$c->dealer)->first();
  385. // dd($c->dealer);
  386. $staff->form()->save($sl);
  387. $su_id = '';
  388. do {
  389. $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  390. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  391. $sdl = new Subscriber();
  392. $sdl->subscriber_id = $su_id;
  393. $sdl->company_name = $c->company_name;
  394. $sdl->company_reg = $c->company_reg;
  395. $sdl->company_num = $c->company_num;
  396. $sdl->company_fax = $c->company_fax;
  397. $sdl->name = $c->name;
  398. $sdl->ic = $c->ic;
  399. $sdl->designation = $c->designation;
  400. $sdl->gender = $c->gender;
  401. $sdl->race = $c->race;
  402. $sdl->email = $c->email;
  403. $sdl->phone1 = $c->phone1;
  404. $sdl->phone2 = $c->phone2;
  405. $sdl->unit_no = '';
  406. $sdl->street = $c->address;
  407. $sdl->postcode = $c->postcode;
  408. $sdl->city = $c->city;
  409. $sdl->state = $c->state;
  410. $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  411. $sdl->back_ic = str_replace("data","/document",$c->imageback);
  412. $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  413. $sdl->form9_44 = str_replace("data","/document",$c->formD);
  414. $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  415. $packageD = new PackageDetail();
  416. $packageD->contract = $c->contract;
  417. $packageD->name = $c->package;
  418. $packageD->montly_fee = '';
  419. $packageD->voice_fee = $c->voice;
  420. $packageD->deposit = '';
  421. $packageD->upfront_payment = '';
  422. $packageD->rfs = $c->rfs;
  423. if($c->wo != ''){
  424. $getWo = OldWorkOrder::all();
  425. foreach($getWo as $w){
  426. if($w->wo == $c->wo){
  427. $woD = new WorkOrder();
  428. $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  429. $woD->wo = $w->wo;
  430. $woD->nature_work = $w->nature_work;
  431. $woD->sub_category = $w->sub_category;
  432. $woD->dateTimeStart = $w->dateTimeStart;
  433. $woD->dateTimeEnd = $w->dateTimeEnd;
  434. $woD->contractor_id = $w->contractor_id;
  435. $woD->installer_id = $w->installer_id;
  436. $woD->onu = $w->onu;
  437. $woD->router = $w->router;
  438. $woD->need_phone = $w->n_phone;
  439. $woD->no_phone = $w->no_phone;
  440. $woD->pppoe_username = $w->pppoe_username;
  441. $woD->pppoe_password = '';
  442. $woD->docket_id = $w->docket;
  443. $woD->remarks_custservice = $w->remarks;
  444. $woD->remarks_installer = $w->remarks_inst;
  445. $woD->status = $w->status;
  446. $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  447. $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  448. $sl->workorder()->save($woD);
  449. }
  450. }
  451. }
  452. $sl->subscriber()->save($sdl);
  453. $sl->packagedetail()->save($packageD);
  454. $id++;
  455. }
  456. }
  457. }
  458. dd('Semua- '.$count. ' -D ' .$id .' -ND '.$i);
  459. }
  460. public function staffConvert(){
  461. $old_staff = StaffOld::where('_id','5c74a263ded8f67c660b8b94')->get();
  462. $company = CompanyLaravel::where('_id','5b42b935ee0dc2b707473b76')->first();
  463. $instList = array();
  464. foreach($old_staff as $inst){
  465. $sl = StaffLaravel::create([
  466. '_id' => new \MongoDB\BSON\ObjectId($inst->_id),
  467. 'email' => $inst->email,
  468. 'password' => $inst->password,
  469. 'roles_access' => $inst->position,
  470. 'company_id' => '5b42b935ee0dc2b707473b76',
  471. 'last_login_at' => '',
  472. 'last_login_ip'=> '',
  473. 'created_at' => new \MongoDB\BSON\UTCDateTime($inst->reg_time*1000)
  474. ]);
  475. $sdl = new StaffDetailLaravel();
  476. $sdl->_id = new \MongoDB\BSON\ObjectId($inst->_id);
  477. $sdl->name = $inst->name;
  478. $sdl->ic = $inst->ic;
  479. $sdl->email = $inst->email;
  480. $sdl->phone = $inst->phone;
  481. $sdl->company_id = '5b42b935ee0dc2b707473b76';
  482. $sdl->color = $inst->color;
  483. $sdl->position = $inst->position;
  484. $sdl->password = $inst->password;
  485. $sdl->user_pic = $inst->user_pic;
  486. $sdl->created_at = new \MongoDB\BSON\UTCDateTime($inst->reg_time*1000);
  487. $company->stafflaravel()->save($sl);
  488. $company->save();
  489. $sl->staffdetaillaravel()->save($sdl);
  490. }
  491. dd($old_staff);
  492. }
  493. public function dealerConvert(){
  494. $oldDealer = DealerDetail::get();
  495. $newStaff = StaffLaravel::all()->toArray();
  496. $a = array();
  497. foreach ( $oldDealer as $o ) {
  498. if(array_search($o->_id, array_column($newStaff, '_id')) !== False) {
  499. } else {
  500. $sl = StaffLaravel::create([
  501. '_id' => new \MongoDB\BSON\ObjectId($o->_id),
  502. 'email' => $o->email,
  503. 'password' => $o->password,
  504. 'roles_access' => $o->position,
  505. 'company_id' => $o->company_id,
  506. 'last_login_at' => '',
  507. 'last_login_ip'=> '',
  508. 'created_at' => $o->created_at,
  509. 'updated_at' => $o->updated_at
  510. ]);
  511. $sdl = new StaffDetailLaravel();
  512. $sdl->_id = new \MongoDB\BSON\ObjectId($o->_id);
  513. $sdl->name = $o->name;
  514. $sdl->ic = $o->ic;
  515. $sdl->email = $o->email;
  516. $sdl->phone = $o->phone;
  517. $sdl->company_id = $o->company_id;
  518. $sdl->color = $o->color;
  519. $sdl->position = $o->position;
  520. $sdl->password = $o->password;
  521. $sdl->user_pic = $o->user_pic;
  522. $sdl->created_at = $o->created_at;
  523. $company = CompanyLaravel::where('_id',$o->company_id)->first();
  524. $company->stafflaravel()->save($sl);
  525. $company->save();
  526. $sl->staffdetaillaravel()->save($sdl);
  527. $a[] = $o;
  528. }
  529. }
  530. dd($a);
  531. }
  532. public function test1()
  533. {
  534. // $sub = SubscribersLaravel::where('subscriber_id','CBB-DNC0KQB')->first();
  535. // echo $sub->
  536. // $destinationPathIcon = '/assets/document';
  537. // if(!File::exists(public_path().$destinationPathIcon))
  538. // {
  539. // echo "folder takde woi";
  540. // }
  541. // else
  542. // echo "folder ada";
  543. $sub = SubscribersLaravel::all();
  544. $i=0;
  545. $arr = array();
  546. foreach($sub as $s)
  547. {
  548. if(!empty($s->front_ic))
  549. {
  550. if(strpos($s->form24_49, '/document/business/'.$s->_id) !== false)
  551. {
  552. $sb = SubscribersLaravel::where('subscriber_id', $s->subscriber_id)->first();
  553. // $sb->front_ic = str_replace('/document/business/'.$sb->_id,"/document/".$s->subscriber_id,$sb->front_ic);
  554. // $sb->back_ic = str_replace('/document/business/'.$sb->_id,"/document/".$s->subscriber_id,$sb->back_ic);
  555. // $sb->signature = str_replace('/document/business/'.$sb->_id,"/document/".$s->subscriber_id,$sb->signature);
  556. $sb->form24_49 = str_replace('/document/business/'.$sb->_id,"/document/".$s->subscriber_id,$sb->form24_49);
  557. $sb->form9_44 = str_replace('/document/business/'.$sb->_id,"/document/".$s->subscriber_id,$sb->form9_44);
  558. // $sb->back = "/document/".$s->subscriber_id."/backic.jpeg";
  559. // $sb->save();
  560. $arr[] = $s;
  561. }
  562. }
  563. }
  564. dd($arr);
  565. }
  566. public function updateHistory()
  567. {
  568. $form = Form::all()->toArray();
  569. $oh = OrderHistory::all();
  570. $i = 0;
  571. if(!empty($oh)){
  572. foreach ($oh as $o){
  573. if(array_search($o->_id, array_column($form, '_id')) !== False) {
  574. $fm = Form::where('_id', $o->_id)->first();
  575. if(empty($fm)){}
  576. else
  577. {
  578. foreach($o->details as $d)
  579. {
  580. $stat = new FormStatus();
  581. $stat->form_id = $o->_id;
  582. $stat->status_id = $d['id'];
  583. $stat->date = new \MongoDB\BSON\UTCDateTime($d['date']*1000);
  584. $stat->status = $d['status'];
  585. $stat->desc = $d['desc'];
  586. $stat->created_at = new \MongoDB\BSON\UTCDateTime($d['date']*1000);
  587. $fm->formstatus()->save($stat);
  588. $i++;
  589. }
  590. }
  591. }
  592. }
  593. }
  594. dd($i);
  595. }
  596. public function updateWorkOrder(){
  597. $wo = WorkOrder::all()->toArray();
  598. $oldWork = OldWorkOrder::all();
  599. $i = 0;
  600. foreach($oldWork as $o) {
  601. $curr = WorkOrder::where('wo',$o->wo)->first();
  602. if(!empty($curr)){
  603. $curr->nature_work = $o->nature_work;
  604. $curr->sub_category = $o->sub_category;
  605. $curr->dateTimeStart = $o->dateTimeStart;
  606. $curr->dateTimeEnd = $o->dateTimeEnd;
  607. $curr->contractor_id = $o->contractor_id;
  608. $curr->installer_id = $o->installer_id;
  609. $curr->onu = $o->onu;
  610. $curr->router = $o->router;
  611. $curr->need_phone = $o->n_phone;
  612. $curr->no_phone = $o->no_phone;
  613. $curr->pppoe_username = $o->pppoe_username;
  614. $curr->pppoe_password = '';
  615. $curr->docket_id = $o->docket;
  616. $curr->remarks_custservice = $o->remarks;
  617. $curr->remarks_installer = $o->remarks_inst;
  618. $curr->status = $o->status;
  619. $curr->save();
  620. $i++;
  621. }
  622. }
  623. dd($i);
  624. }
  625. public function updateDocket(){
  626. $i = 0;
  627. $wo = WorkOrder::all();
  628. foreach ($wo as $key => $w) {
  629. if($w->status == 'Completed'){
  630. $latest = Docket::where('work_order_id',$w->wo)->first();
  631. if(empty($latest)){
  632. $doc = OldDocket::where('work_order_id',$w->wo)->first();
  633. if(!empty($doc)){
  634. $i++;
  635. $curr = WorkOrder::where('wo',$doc->work_order_id)->first();
  636. $docket = new Docket();
  637. $docket->work_order_id = $doc->work_order_id;
  638. $docket->docket_id = $doc->docket_id;
  639. $docket->nature_work = $doc->nature_work;
  640. $docket->installer_id = $doc->installer_id;
  641. $docket->end_job = $doc->end_job;
  642. $docket->router_serial_number = $doc->router_serial_number;
  643. $docket->mac_router = $doc->mac_router;
  644. $docket->cable_read = $doc->cable_read;
  645. $docket->condition = $doc->condition;
  646. $docket->Note = $doc->Note;
  647. $docket->Rating1 = $doc->Rating1;
  648. $docket->Rating2 = $doc->Rating2;
  649. $docket->Rating3 = $doc->Rating3;
  650. $docket->customer_signature = $doc->customer_signature;
  651. $curr->docket()->save($docket);
  652. }
  653. }
  654. }
  655. }
  656. dd($i);
  657. }
  658. public function checkResidential(){
  659. // $newCoverage = Form::all();
  660. // $oldCoverage = OldResidential::all()->toArray();
  661. // $i = 0; $j = 0; $empty = array();
  662. // foreach ($newCoverage as $key => $a) {
  663. // if(array_search($a->_id, array_column($oldCoverage, '_id')) !== False) {
  664. // }else {
  665. // $empty[] = $a;
  666. // }
  667. // }
  668. // foreach ($empty as $key => $a) {
  669. // dd($a['_id']);
  670. // }
  671. // if($c->dealer == ''){
  672. // $sl = Form::create([
  673. // '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  674. // 'type_service' => $c->type_application,
  675. // 'type_application' => 'B',
  676. // 'status_payment' => $c->status,
  677. // 'status_email' => $c->status1,
  678. // 'remark_form' => $c->remarks,
  679. // 'dealer_id' => $c->dealer,
  680. // 'company_id' => $c->dealer_company,
  681. // 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  682. // ]);
  683. // $su_id = '';
  684. // do {
  685. // $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  686. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  687. // $sdl = new Subscriber();
  688. // $sdl->subscriber_id = $su_id;
  689. // $sdl->company_name = $c->company_name;
  690. // $sdl->company_reg = $c->company_reg;
  691. // $sdl->company_num = $c->company_num;
  692. // $sdl->company_fax = $c->company_fax;
  693. // $sdl->name = $c->name;
  694. // $sdl->ic = $c->ic;
  695. // $sdl->designation = $c->designation;
  696. // $sdl->gender = $c->gender;
  697. // $sdl->race = $c->race;
  698. // $sdl->email = $c->email;
  699. // $sdl->phone1 = $c->phone1;
  700. // $sdl->phone2 = $c->phone2;
  701. // $sdl->unit_no = '';
  702. // $sdl->street = $c->address;
  703. // $sdl->postcode = $c->postcode;
  704. // $sdl->city = $c->city;
  705. // $sdl->state = $c->state;
  706. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  707. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  708. // $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  709. // $sdl->form9_44 = str_replace("data","/document",$c->formD);
  710. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  711. // $packageD = new PackageDetail();
  712. // $packageD->contract = $c->contract;
  713. // $packageD->name = $c->package;
  714. // $packageD->montly_fee = '';
  715. // $packageD->voice_fee = $c->voice;
  716. // $packageD->deposit = '';
  717. // $packageD->upfront_payment = '';
  718. // $packageD->rfs = $c->rfs;
  719. // if($c->wo != ''){
  720. // $getWo = OldWorkOrder::all();
  721. // foreach($getWo as $w){
  722. // if($w->wo == $c->wo){
  723. // $woD = new WorkOrder();
  724. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  725. // $woD->wo = $w->wo;
  726. // $woD->nature_work = $w->nature_work;
  727. // $woD->sub_category = $w->sub_category;
  728. // $woD->dateTimeStart = $w->dateTimeStart;
  729. // $woD->dateTimeEnd = $w->dateTimeEnd;
  730. // $woD->contractor_id = $w->contractor_id;
  731. // $woD->installer_id = $w->installer_id;
  732. // $woD->onu = $w->onu;
  733. // $woD->router = $w->router;
  734. // $woD->need_phone = $w->n_phone;
  735. // $woD->no_phone = $w->no_phone;
  736. // $woD->pppoe_username = $w->pppoe_username;
  737. // $woD->pppoe_password = '';
  738. // $woD->docket_id = $w->docket;
  739. // $woD->remarks_custservice = $w->remarks;
  740. // $woD->remarks_installer = $w->remarks_inst;
  741. // $woD->status = $w->status;
  742. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  743. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  744. // $sl->workorder()->save($woD);
  745. // }
  746. // }
  747. // }
  748. // $sl->subscriber()->save($sdl);
  749. // $sl->packagedetail()->save($packageD);
  750. // $i++;
  751. // }else {
  752. // $sl = new Form();
  753. // $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  754. // $sl->type_service = $c->type_application;
  755. // $sl->type_application = 'B';
  756. // $sl->status_payment = $c->status;
  757. // $sl->status_email = $c->status1;
  758. // $sl->remark_form = $c->remarks;
  759. // $sl->dealer_id = $c->dealer;
  760. // $sl->company_id = $c->dealer_company;
  761. // $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  762. // // staff
  763. // $staff = Staff::where('_id',$c->dealer)->first();
  764. // // dd($c->dealer);
  765. // $staff->form()->save($sl);
  766. // $su_id = '';
  767. // do {
  768. // $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  769. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  770. // $sdl = new Subscriber();
  771. // $sdl->subscriber_id = $su_id;
  772. // $sdl->company_name = $c->company_name;
  773. // $sdl->company_reg = $c->company_reg;
  774. // $sdl->company_num = $c->company_num;
  775. // $sdl->company_fax = $c->company_fax;
  776. // $sdl->name = $c->name;
  777. // $sdl->ic = $c->ic;
  778. // $sdl->designation = $c->designation;
  779. // $sdl->gender = $c->gender;
  780. // $sdl->race = $c->race;
  781. // $sdl->email = $c->email;
  782. // $sdl->phone1 = $c->phone1;
  783. // $sdl->phone2 = $c->phone2;
  784. // $sdl->unit_no = '';
  785. // $sdl->street = $c->address;
  786. // $sdl->postcode = $c->postcode;
  787. // $sdl->city = $c->city;
  788. // $sdl->state = $c->state;
  789. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  790. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  791. // $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  792. // $sdl->form9_44 = str_replace("data","/document",$c->formD);
  793. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  794. // $packageD = new PackageDetail();
  795. // $packageD->contract = $c->contract;
  796. // $packageD->name = $c->package;
  797. // $packageD->montly_fee = '';
  798. // $packageD->voice_fee = $c->voice;
  799. // $packageD->deposit = '';
  800. // $packageD->upfront_payment = '';
  801. // $packageD->rfs = $c->rfs;
  802. // if($c->wo != ''){
  803. // $getWo = OldWorkOrder::all();
  804. // foreach($getWo as $w){
  805. // if($w->wo == $c->wo){
  806. // $woD = new WorkOrder();
  807. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  808. // $woD->wo = $w->wo;
  809. // $woD->nature_work = $w->nature_work;
  810. // $woD->sub_category = $w->sub_category;
  811. // $woD->dateTimeStart = $w->dateTimeStart;
  812. // $woD->dateTimeEnd = $w->dateTimeEnd;
  813. // $woD->contractor_id = $w->contractor_id;
  814. // $woD->installer_id = $w->installer_id;
  815. // $woD->onu = $w->onu;
  816. // $woD->router = $w->router;
  817. // $woD->need_phone = $w->n_phone;
  818. // $woD->no_phone = $w->no_phone;
  819. // $woD->pppoe_username = $w->pppoe_username;
  820. // $woD->pppoe_password = '';
  821. // $woD->docket_id = $w->docket;
  822. // $woD->remarks_custservice = $w->remarks;
  823. // $woD->remarks_installer = $w->remarks_inst;
  824. // $woD->status = $w->status;
  825. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  826. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  827. // $sl->workorder()->save($woD);
  828. // }
  829. // }
  830. // }
  831. // $sl->subscriber()->save($sdl);
  832. // $sl->packagedetail()->save($packageD);
  833. // $id++;
  834. // }
  835. $data = array();
  836. $oldCoverage = OldResidential::all();
  837. foreach($oldCoverage as $c){
  838. $fm = Form::with('Subscriber')->where('_id',$c->_id)->first();
  839. if($fm === null){
  840. $data[] = $c;
  841. // if($c->dealer == ''){
  842. // $sl = Form::create([
  843. // '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  844. // 'type_service' => $c->type_application,
  845. // 'type_application' => 'R',
  846. // 'status_payment' => $c->status,
  847. // 'status_email' => $c->status1,
  848. // 'remark_form' => $c->remarks,
  849. // 'dealer_id' => $c->dealer,
  850. // 'company_id' => $c->dealer_company,
  851. // 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  852. // ]);
  853. // $su_id = '';
  854. // do {
  855. // $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  856. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  857. // $sdl = new Subscriber();
  858. // $sdl->subscriber_id = $su_id;
  859. // $sdl->name = $c->name;
  860. // $sdl->ic = $c->ic;
  861. // $sdl->citizen = $c->citizen;
  862. // $sdl->gender = $c->gender;
  863. // $sdl->race = $c->race;
  864. // $sdl->email = $c->email;
  865. // $sdl->phone1 = $c->phone1;
  866. // $sdl->phone2 = $c->phone2;
  867. // $sdl->unit_no = $c->unit_no;
  868. // $sdl->building_name = $c->building;
  869. // $sdl->street = $c->street;
  870. // $sdl->postcode = $c->postcode;
  871. // $sdl->city = $c->city;
  872. // $sdl->state = $c->state;
  873. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  874. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  875. // $sdl->signature = str_replace("data","/document",$c->signature);
  876. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  877. // $packageD = new PackageDetail();
  878. // $packageD->contract = $c->contract;
  879. // $packageD->name = $c->package;
  880. // $packageD->montly_fee = '';
  881. // $packageD->voice_fee = $c->voice;
  882. // $packageD->deposit = '';
  883. // $packageD->upfront_payment = '';
  884. // $packageD->rfs = $c->rfs;
  885. // if($c->wo != ''){
  886. // $getWo = OldWorkOrder::all();
  887. // foreach($getWo as $w){
  888. // if($w->wo == $c->wo){
  889. // $woD = new WorkOrder();
  890. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  891. // $woD->wo = $w->wo;
  892. // $woD->nature_work = $w->nature_work;
  893. // $woD->sub_category = $w->sub_category;
  894. // $woD->dateTimeStart = $w->dateTimeStart;
  895. // $woD->dateTimeEnd = $w->dateTimeEnd;
  896. // $woD->contractor_id = $w->contractor_id;
  897. // $woD->installer_id = $w->installer_id;
  898. // $woD->onu = $w->onu;
  899. // $woD->router = $w->router;
  900. // $woD->need_phone = $w->n_phone;
  901. // $woD->no_phone = $w->no_phone;
  902. // $woD->pppoe_username = $w->pppoe_username;
  903. // $woD->pppoe_password = '';
  904. // $woD->docket_id = $w->docket;
  905. // $woD->remarks_custservice = $w->remarks;
  906. // $woD->remarks_installer = $w->remarks_inst;
  907. // $woD->status = $w->status;
  908. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  909. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  910. // $sl->workorder()->save($woD);
  911. // }
  912. // }
  913. // }
  914. // $sl->subscriber()->save($sdl);
  915. // $sl->packagedetail()->save($packageD);
  916. // $i++;
  917. // }else {
  918. // $sl = new Form();
  919. // $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  920. // $sl->type_service = $c->type_application;
  921. // $sl->type_application = 'R';
  922. // $sl->status_payment = $c->status;
  923. // $sl->status_email = $c->status1;
  924. // $sl->remark_form = $c->remarks;
  925. // $sl->dealer_id = $c->dealer;
  926. // $sl->company_id = $c->dealer_company;
  927. // $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  928. // // staff
  929. // $staff = Staff::where('_id',$c->dealer)->first();
  930. // // dd($c->dealer);
  931. // $staff->form()->save($sl);
  932. // $su_id = '';
  933. // do {
  934. // $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  935. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  936. // $sdl = new Subscriber();
  937. // $sdl->subscriber_id = $su_id;
  938. // $sdl->name = $c->name;
  939. // $sdl->ic = $c->ic;
  940. // $sdl->citizen = $c->citizen;
  941. // $sdl->gender = $c->gender;
  942. // $sdl->race = $c->race;
  943. // $sdl->email = $c->email;
  944. // $sdl->phone1 = $c->phone1;
  945. // $sdl->phone2 = $c->phone2;
  946. // $sdl->unit_no = $c->unit_no;
  947. // $sdl->building_name = $c->building;
  948. // $sdl->street = $c->street;
  949. // $sdl->postcode = $c->postcode;
  950. // $sdl->city = $c->city;
  951. // $sdl->state = $c->state;
  952. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  953. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  954. // $sdl->signature = str_replace("data","/document",$c->signature);
  955. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  956. // $packageD = new PackageDetail();
  957. // $packageD->contract = $c->contract;
  958. // $packageD->name = $c->package;
  959. // $packageD->montly_fee = '';
  960. // $packageD->voice_fee = $c->voice;
  961. // $packageD->deposit = '';
  962. // $packageD->upfront_payment = '';
  963. // $packageD->rfs = $c->rfs;
  964. // if($c->wo != ''){
  965. // $getWo = OldWorkOrder::all();
  966. // foreach($getWo as $w){
  967. // if($w->wo == $c->wo){
  968. // $woD = new WorkOrder();
  969. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  970. // $woD->wo = $w->wo;
  971. // $woD->nature_work = $w->nature_work;
  972. // $woD->sub_category = $w->sub_category;
  973. // $woD->dateTimeStart = $w->dateTimeStart;
  974. // $woD->dateTimeEnd = $w->dateTimeEnd;
  975. // $woD->contractor_id = $w->contractor_id;
  976. // $woD->installer_id = $w->installer_id;
  977. // $woD->onu = $w->onu;
  978. // $woD->router = $w->router;
  979. // $woD->need_phone = $w->n_phone;
  980. // $woD->no_phone = $w->no_phone;
  981. // $woD->pppoe_username = $w->pppoe_username;
  982. // $woD->pppoe_password = '';
  983. // $woD->docket_id = $w->docket;
  984. // $woD->remarks_custservice = $w->remarks;
  985. // $woD->remarks_installer = $w->remarks_inst;
  986. // $woD->status = $w->status;
  987. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  988. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  989. // $sl->workorder()->save($woD);
  990. // }
  991. // }
  992. // }
  993. // $sl->subscriber()->save($sdl);
  994. // $sl->packagedetail()->save($packageD);
  995. // }
  996. }
  997. }
  998. dd($data);
  999. }
  1000. public function subscriberID(){
  1001. $final = array();
  1002. $data = Form::with('PackageDetail','Subscriber')->where('type_service','!=','Rectification')->where('type_application','B')->withTrashed()->get();
  1003. foreach ($data as $key => $d) {
  1004. $created_at = $d->created_at->format('m/Y');
  1005. // if(strpos($created_at,'03/2019') !== false){
  1006. // if(($d->Subscriber->email != '<b>Package Development</b>' || $d->Subscriber->ic != '<b>Package Development</b>') && $d->PackageDetail->name == "10"){
  1007. if($d->PackageDetail->name == '1' && $d->PackageDetail->contract == '12'){
  1008. // if($d->Subscriber->citizen == 'Malaysian'){
  1009. // $d->PackageDetail->montly_fee = '115.54';
  1010. // $d->PackageDetail->deposit = '200';
  1011. // $d->PackageDetail->upfront_payment = '0';
  1012. // $d->PackageDetail->save();
  1013. // }else {
  1014. $d->PackageDetail->montly_fee = '3,708.94';
  1015. $d->PackageDetail->deposit = '3,499';
  1016. $d->PackageDetail->upfront_payment = '300';
  1017. $d->PackageDetail->save();
  1018. // }
  1019. $final[] = $d->_id;
  1020. }
  1021. // if($d->PackageDetail->name == 'R'){
  1022. // $final[] = $d->_id;
  1023. // $d->type_service = 'Rectification';
  1024. // $d->status_payment = 'paid';
  1025. // $d->status_email = 'verified';
  1026. // $d->save();
  1027. // }
  1028. // }
  1029. // }
  1030. // // if(($d->Subscriber->email == '<b>Package Development</b>' || $d->Subscriber->ic == '<b>Package Development</b>') && $d->PackageDetail->contract == ""){
  1031. // // $d->PackageDetail->contract = "24";
  1032. // // $d->PackageDetail->save();
  1033. // // $final[] = $d->_id;
  1034. // // }
  1035. // }
  1036. // if(!empty($d->PackageDetail->voice_fee)){
  1037. // if($d->PackageDetail->voice_fee == 0){
  1038. // $d->PackageDetail->voice_fee = 'No';
  1039. // $d->PackageDetail->save();
  1040. // $final[] = $d->_id;
  1041. // }
  1042. // }
  1043. }
  1044. dd($final);
  1045. }
  1046. public function convertStaffDb()
  1047. {
  1048. // $s = OldResidential::first();
  1049. return $this->subscriberID();
  1050. // return $this->checkResidential();
  1051. // return $this->test2();
  1052. // return $this->updateWorkOrder();
  1053. // return $this->updateDocket();
  1054. // return $this->updateHistory();
  1055. // return $this->staffConvert();
  1056. // return $this->convertFormAndRelation();
  1057. // return $this->convertFormAndRelationBusiness();
  1058. // return $this->dealerConvert();
  1059. // return $this->addWotoExistingForm();
  1060. // $a = array(); $count = 0;
  1061. // $oldDocket = Docket::all();
  1062. // $newWork = WorkOrderLaravel::where('status','Completed')->get()->toArray();
  1063. // $i = 0;
  1064. // foreach ( $oldDocket as $o ) {
  1065. // if(array_search($o->work_order_id, array_column($newWork, 'wo')) !== False) {
  1066. // // $a[] = $o->docket_id.' - '.$o->work_order_id;
  1067. // $a[] = $o->docket_id;
  1068. // $xNw = DocketLaravel::where('work_order_id',$o->work_order_id)->first();
  1069. // if(empty($xNw)){
  1070. // $testDate = $o->end_job;
  1071. // $date = str_replace('/','-',$testDate);
  1072. // $timestamp = strtotime($date);
  1073. // //Convert timestamp to carbon format for created_at
  1074. // $go = Carbon::createFromTimestamp($timestamp).".000Z";
  1075. // $time = Carbon::createFromTimeString($go);
  1076. // $wo = WorkOrderLaravel::where('wo',$o->work_order_id)->first();
  1077. // $do = new DocketLaravel();
  1078. // $do->work_order_id = $o->work_order_id;
  1079. // $do->docket_id = $o->docket_id;
  1080. // $do->nature_work = $o->nature_work;
  1081. // $do->installer_id = $o->installer_id;
  1082. // $do->end_job = $time->toDateTimeString();
  1083. // $do->router_serial_number = $o->router_serial_number;
  1084. // $do->mac_router = $o->mac_router;
  1085. // $do->cable_read = $o->cable_read;
  1086. // $do->condition = $o->condition;
  1087. // $do->Note = $o->Note;
  1088. // $do->Rating1 = $o->Rating1;
  1089. // $do->Rating2 = $o->Rating2;
  1090. // $do->Rating3 = $o->Rating3;
  1091. // $do->customer_signature = $o->customer_signature;
  1092. // $do->created_at= $time;
  1093. // $wo->docketlaravel()->save($do);
  1094. // $i++;
  1095. // }
  1096. // }
  1097. // }
  1098. // // $xNw1 = WorkOrderLaravel::with('FormLaravel')->get();
  1099. // // $fm = FormLaravel::with('WorkOrderLaravel','SubscribersLaravel')->first();
  1100. // // $docket = DocketLaravel::where('work_order_id',$fm->WorkOrderLaravel->wo)->first();
  1101. // // $withoutDuplicates = array_unique($a);
  1102. // // $duplicates = array_diff($a, $withoutDuplicates);
  1103. // // dd(count($newWork) .'-'.$i);
  1104. // $doc = DocketLaravel::all();
  1105. // dd(count($doc));
  1106. }
  1107. }