You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestController.php 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  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->modem_sn = $doc->modem_sn;
  645. $docket->type_testing = $doc->type_testing;
  646. $docket->cable_read = $doc->cable_read;
  647. $docket->condition = $doc->condition;
  648. $docket->Note = $doc->Note;
  649. $docket->Rating1 = $doc->Rating1;
  650. $docket->Rating2 = $doc->Rating2;
  651. $docket->Rating3 = $doc->Rating3;
  652. $docket->customer_signature = $doc->customer_signature;
  653. $curr->docket()->save($docket);
  654. }
  655. }
  656. }
  657. }
  658. dd($i);
  659. }
  660. public function checkResidential(){
  661. // $newCoverage = Form::all();
  662. // $oldCoverage = OldResidential::all()->toArray();
  663. // $i = 0; $j = 0; $empty = array();
  664. // foreach ($newCoverage as $key => $a) {
  665. // if(array_search($a->_id, array_column($oldCoverage, '_id')) !== False) {
  666. // }else {
  667. // $empty[] = $a;
  668. // }
  669. // }
  670. // foreach ($empty as $key => $a) {
  671. // dd($a['_id']);
  672. // }
  673. // if($c->dealer == ''){
  674. // $sl = Form::create([
  675. // '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  676. // 'type_service' => $c->type_application,
  677. // 'type_application' => 'B',
  678. // 'status_payment' => $c->status,
  679. // 'status_email' => $c->status1,
  680. // 'remark_form' => $c->remarks,
  681. // 'dealer_id' => $c->dealer,
  682. // 'company_id' => $c->dealer_company,
  683. // 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  684. // ]);
  685. // $su_id = '';
  686. // do {
  687. // $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  688. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  689. // $sdl = new Subscriber();
  690. // $sdl->subscriber_id = $su_id;
  691. // $sdl->company_name = $c->company_name;
  692. // $sdl->company_reg = $c->company_reg;
  693. // $sdl->company_num = $c->company_num;
  694. // $sdl->company_fax = $c->company_fax;
  695. // $sdl->name = $c->name;
  696. // $sdl->ic = $c->ic;
  697. // $sdl->designation = $c->designation;
  698. // $sdl->gender = $c->gender;
  699. // $sdl->race = $c->race;
  700. // $sdl->email = $c->email;
  701. // $sdl->phone1 = $c->phone1;
  702. // $sdl->phone2 = $c->phone2;
  703. // $sdl->unit_no = '';
  704. // $sdl->street = $c->address;
  705. // $sdl->postcode = $c->postcode;
  706. // $sdl->city = $c->city;
  707. // $sdl->state = $c->state;
  708. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  709. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  710. // $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  711. // $sdl->form9_44 = str_replace("data","/document",$c->formD);
  712. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  713. // $packageD = new PackageDetail();
  714. // $packageD->contract = $c->contract;
  715. // $packageD->name = $c->package;
  716. // $packageD->montly_fee = '';
  717. // $packageD->voice_fee = $c->voice;
  718. // $packageD->deposit = '';
  719. // $packageD->upfront_payment = '';
  720. // $packageD->rfs = $c->rfs;
  721. // if($c->wo != ''){
  722. // $getWo = OldWorkOrder::all();
  723. // foreach($getWo as $w){
  724. // if($w->wo == $c->wo){
  725. // $woD = new WorkOrder();
  726. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  727. // $woD->wo = $w->wo;
  728. // $woD->nature_work = $w->nature_work;
  729. // $woD->sub_category = $w->sub_category;
  730. // $woD->dateTimeStart = $w->dateTimeStart;
  731. // $woD->dateTimeEnd = $w->dateTimeEnd;
  732. // $woD->contractor_id = $w->contractor_id;
  733. // $woD->installer_id = $w->installer_id;
  734. // $woD->onu = $w->onu;
  735. // $woD->router = $w->router;
  736. // $woD->need_phone = $w->n_phone;
  737. // $woD->no_phone = $w->no_phone;
  738. // $woD->pppoe_username = $w->pppoe_username;
  739. // $woD->pppoe_password = '';
  740. // $woD->docket_id = $w->docket;
  741. // $woD->remarks_custservice = $w->remarks;
  742. // $woD->remarks_installer = $w->remarks_inst;
  743. // $woD->status = $w->status;
  744. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  745. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  746. // $sl->workorder()->save($woD);
  747. // }
  748. // }
  749. // }
  750. // $sl->subscriber()->save($sdl);
  751. // $sl->packagedetail()->save($packageD);
  752. // $i++;
  753. // }else {
  754. // $sl = new Form();
  755. // $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  756. // $sl->type_service = $c->type_application;
  757. // $sl->type_application = 'B';
  758. // $sl->status_payment = $c->status;
  759. // $sl->status_email = $c->status1;
  760. // $sl->remark_form = $c->remarks;
  761. // $sl->dealer_id = $c->dealer;
  762. // $sl->company_id = $c->dealer_company;
  763. // $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  764. // // staff
  765. // $staff = Staff::where('_id',$c->dealer)->first();
  766. // // dd($c->dealer);
  767. // $staff->form()->save($sl);
  768. // $su_id = '';
  769. // do {
  770. // $su_id = strtoupper('CBB-'.$this->random_code(6).'B');
  771. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  772. // $sdl = new Subscriber();
  773. // $sdl->subscriber_id = $su_id;
  774. // $sdl->company_name = $c->company_name;
  775. // $sdl->company_reg = $c->company_reg;
  776. // $sdl->company_num = $c->company_num;
  777. // $sdl->company_fax = $c->company_fax;
  778. // $sdl->name = $c->name;
  779. // $sdl->ic = $c->ic;
  780. // $sdl->designation = $c->designation;
  781. // $sdl->gender = $c->gender;
  782. // $sdl->race = $c->race;
  783. // $sdl->email = $c->email;
  784. // $sdl->phone1 = $c->phone1;
  785. // $sdl->phone2 = $c->phone2;
  786. // $sdl->unit_no = '';
  787. // $sdl->street = $c->address;
  788. // $sdl->postcode = $c->postcode;
  789. // $sdl->city = $c->city;
  790. // $sdl->state = $c->state;
  791. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  792. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  793. // $sdl->form24_49 = str_replace("data","/document",$c->formA_B);
  794. // $sdl->form9_44 = str_replace("data","/document",$c->formD);
  795. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  796. // $packageD = new PackageDetail();
  797. // $packageD->contract = $c->contract;
  798. // $packageD->name = $c->package;
  799. // $packageD->montly_fee = '';
  800. // $packageD->voice_fee = $c->voice;
  801. // $packageD->deposit = '';
  802. // $packageD->upfront_payment = '';
  803. // $packageD->rfs = $c->rfs;
  804. // if($c->wo != ''){
  805. // $getWo = OldWorkOrder::all();
  806. // foreach($getWo as $w){
  807. // if($w->wo == $c->wo){
  808. // $woD = new WorkOrder();
  809. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  810. // $woD->wo = $w->wo;
  811. // $woD->nature_work = $w->nature_work;
  812. // $woD->sub_category = $w->sub_category;
  813. // $woD->dateTimeStart = $w->dateTimeStart;
  814. // $woD->dateTimeEnd = $w->dateTimeEnd;
  815. // $woD->contractor_id = $w->contractor_id;
  816. // $woD->installer_id = $w->installer_id;
  817. // $woD->onu = $w->onu;
  818. // $woD->router = $w->router;
  819. // $woD->need_phone = $w->n_phone;
  820. // $woD->no_phone = $w->no_phone;
  821. // $woD->pppoe_username = $w->pppoe_username;
  822. // $woD->pppoe_password = '';
  823. // $woD->docket_id = $w->docket;
  824. // $woD->remarks_custservice = $w->remarks;
  825. // $woD->remarks_installer = $w->remarks_inst;
  826. // $woD->status = $w->status;
  827. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  828. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  829. // $sl->workorder()->save($woD);
  830. // }
  831. // }
  832. // }
  833. // $sl->subscriber()->save($sdl);
  834. // $sl->packagedetail()->save($packageD);
  835. // $id++;
  836. // }
  837. $data = array();
  838. $oldCoverage = OldResidential::all();
  839. foreach($oldCoverage as $c){
  840. $fm = Form::with('Subscriber')->where('_id',$c->_id)->first();
  841. if($fm === null){
  842. $data[] = $c;
  843. // if($c->dealer == ''){
  844. // $sl = Form::create([
  845. // '_id' => new \MongoDB\BSON\ObjectId($c->_id),
  846. // 'type_service' => $c->type_application,
  847. // 'type_application' => 'R',
  848. // 'status_payment' => $c->status,
  849. // 'status_email' => $c->status1,
  850. // 'remark_form' => $c->remarks,
  851. // 'dealer_id' => $c->dealer,
  852. // 'company_id' => $c->dealer_company,
  853. // 'created_at' => new \MongoDB\BSON\UTCDateTime($c->reg_time*1000)
  854. // ]);
  855. // $su_id = '';
  856. // do {
  857. // $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  858. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  859. // $sdl = new Subscriber();
  860. // $sdl->subscriber_id = $su_id;
  861. // $sdl->name = $c->name;
  862. // $sdl->ic = $c->ic;
  863. // $sdl->citizen = $c->citizen;
  864. // $sdl->gender = $c->gender;
  865. // $sdl->race = $c->race;
  866. // $sdl->email = $c->email;
  867. // $sdl->phone1 = $c->phone1;
  868. // $sdl->phone2 = $c->phone2;
  869. // $sdl->unit_no = $c->unit_no;
  870. // $sdl->building_name = $c->building;
  871. // $sdl->street = $c->street;
  872. // $sdl->postcode = $c->postcode;
  873. // $sdl->city = $c->city;
  874. // $sdl->state = $c->state;
  875. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  876. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  877. // $sdl->signature = str_replace("data","/document",$c->signature);
  878. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  879. // $packageD = new PackageDetail();
  880. // $packageD->contract = $c->contract;
  881. // $packageD->name = $c->package;
  882. // $packageD->montly_fee = '';
  883. // $packageD->voice_fee = $c->voice;
  884. // $packageD->deposit = '';
  885. // $packageD->upfront_payment = '';
  886. // $packageD->rfs = $c->rfs;
  887. // if($c->wo != ''){
  888. // $getWo = OldWorkOrder::all();
  889. // foreach($getWo as $w){
  890. // if($w->wo == $c->wo){
  891. // $woD = new WorkOrder();
  892. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  893. // $woD->wo = $w->wo;
  894. // $woD->nature_work = $w->nature_work;
  895. // $woD->sub_category = $w->sub_category;
  896. // $woD->dateTimeStart = $w->dateTimeStart;
  897. // $woD->dateTimeEnd = $w->dateTimeEnd;
  898. // $woD->contractor_id = $w->contractor_id;
  899. // $woD->installer_id = $w->installer_id;
  900. // $woD->onu = $w->onu;
  901. // $woD->router = $w->router;
  902. // $woD->need_phone = $w->n_phone;
  903. // $woD->no_phone = $w->no_phone;
  904. // $woD->pppoe_username = $w->pppoe_username;
  905. // $woD->pppoe_password = '';
  906. // $woD->docket_id = $w->docket;
  907. // $woD->remarks_custservice = $w->remarks;
  908. // $woD->remarks_installer = $w->remarks_inst;
  909. // $woD->status = $w->status;
  910. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  911. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  912. // $sl->workorder()->save($woD);
  913. // }
  914. // }
  915. // }
  916. // $sl->subscriber()->save($sdl);
  917. // $sl->packagedetail()->save($packageD);
  918. // $i++;
  919. // }else {
  920. // $sl = new Form();
  921. // $sl->_id = new \MongoDB\BSON\ObjectId($c->_id);
  922. // $sl->type_service = $c->type_application;
  923. // $sl->type_application = 'R';
  924. // $sl->status_payment = $c->status;
  925. // $sl->status_email = $c->status1;
  926. // $sl->remark_form = $c->remarks;
  927. // $sl->dealer_id = $c->dealer;
  928. // $sl->company_id = $c->dealer_company;
  929. // $sl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  930. // // staff
  931. // $staff = Staff::where('_id',$c->dealer)->first();
  932. // // dd($c->dealer);
  933. // $staff->form()->save($sl);
  934. // $su_id = '';
  935. // do {
  936. // $su_id = strtoupper('CBB-'.$this->random_code(6).'R');
  937. // } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  938. // $sdl = new Subscriber();
  939. // $sdl->subscriber_id = $su_id;
  940. // $sdl->name = $c->name;
  941. // $sdl->ic = $c->ic;
  942. // $sdl->citizen = $c->citizen;
  943. // $sdl->gender = $c->gender;
  944. // $sdl->race = $c->race;
  945. // $sdl->email = $c->email;
  946. // $sdl->phone1 = $c->phone1;
  947. // $sdl->phone2 = $c->phone2;
  948. // $sdl->unit_no = $c->unit_no;
  949. // $sdl->building_name = $c->building;
  950. // $sdl->street = $c->street;
  951. // $sdl->postcode = $c->postcode;
  952. // $sdl->city = $c->city;
  953. // $sdl->state = $c->state;
  954. // $sdl->front_ic = str_replace("data","/document",$c->imagefront);
  955. // $sdl->back_ic = str_replace("data","/document",$c->imageback);
  956. // $sdl->signature = str_replace("data","/document",$c->signature);
  957. // $sdl->created_at = new \MongoDB\BSON\UTCDateTime($c->reg_time*1000);
  958. // $packageD = new PackageDetail();
  959. // $packageD->contract = $c->contract;
  960. // $packageD->name = $c->package;
  961. // $packageD->montly_fee = '';
  962. // $packageD->voice_fee = $c->voice;
  963. // $packageD->deposit = '';
  964. // $packageD->upfront_payment = '';
  965. // $packageD->rfs = $c->rfs;
  966. // if($c->wo != ''){
  967. // $getWo = OldWorkOrder::all();
  968. // foreach($getWo as $w){
  969. // if($w->wo == $c->wo){
  970. // $woD = new WorkOrder();
  971. // $woD->img_url = '/assets/img/activation_icon_nRead1.png';
  972. // $woD->wo = $w->wo;
  973. // $woD->nature_work = $w->nature_work;
  974. // $woD->sub_category = $w->sub_category;
  975. // $woD->dateTimeStart = $w->dateTimeStart;
  976. // $woD->dateTimeEnd = $w->dateTimeEnd;
  977. // $woD->contractor_id = $w->contractor_id;
  978. // $woD->installer_id = $w->installer_id;
  979. // $woD->onu = $w->onu;
  980. // $woD->router = $w->router;
  981. // $woD->need_phone = $w->n_phone;
  982. // $woD->no_phone = $w->no_phone;
  983. // $woD->pppoe_username = $w->pppoe_username;
  984. // $woD->pppoe_password = '';
  985. // $woD->docket_id = $w->docket;
  986. // $woD->remarks_custservice = $w->remarks;
  987. // $woD->remarks_installer = $w->remarks_inst;
  988. // $woD->status = $w->status;
  989. // $woD->created_by = str_replace(array( 'ObjectId(', ')' ), '', $w->created_by);
  990. // $woD->created_at = new \MongoDB\BSON\UTCDateTime($w->reg_time*1000);
  991. // $sl->workorder()->save($woD);
  992. // }
  993. // }
  994. // }
  995. // $sl->subscriber()->save($sdl);
  996. // $sl->packagedetail()->save($packageD);
  997. // }
  998. }
  999. }
  1000. dd($data);
  1001. }
  1002. public function subscriberID(){
  1003. $final = array();
  1004. $data = Form::with('PackageDetail','Subscriber')->where('type_service','!=','Rectification')->where('type_application','B')->withTrashed()->get();
  1005. foreach ($data as $key => $d) {
  1006. $created_at = $d->created_at->format('m/Y');
  1007. // if(strpos($created_at,'03/2019') !== false){
  1008. // if(($d->Subscriber->email != '<b>Package Development</b>' || $d->Subscriber->ic != '<b>Package Development</b>') && $d->PackageDetail->name == "10"){
  1009. if($d->PackageDetail->name == '1' && $d->PackageDetail->contract == '12'){
  1010. // if($d->Subscriber->citizen == 'Malaysian'){
  1011. // $d->PackageDetail->montly_fee = '115.54';
  1012. // $d->PackageDetail->deposit = '200';
  1013. // $d->PackageDetail->upfront_payment = '0';
  1014. // $d->PackageDetail->save();
  1015. // }else {
  1016. $d->PackageDetail->montly_fee = '3,708.94';
  1017. $d->PackageDetail->deposit = '3,499';
  1018. $d->PackageDetail->upfront_payment = '300';
  1019. $d->PackageDetail->save();
  1020. // }
  1021. $final[] = $d->_id;
  1022. }
  1023. // if($d->PackageDetail->name == 'R'){
  1024. // $final[] = $d->_id;
  1025. // $d->type_service = 'Rectification';
  1026. // $d->status_payment = 'paid';
  1027. // $d->status_email = 'verified';
  1028. // $d->save();
  1029. // }
  1030. // }
  1031. // }
  1032. // // if(($d->Subscriber->email == '<b>Package Development</b>' || $d->Subscriber->ic == '<b>Package Development</b>') && $d->PackageDetail->contract == ""){
  1033. // // $d->PackageDetail->contract = "24";
  1034. // // $d->PackageDetail->save();
  1035. // // $final[] = $d->_id;
  1036. // // }
  1037. // }
  1038. // if(!empty($d->PackageDetail->voice_fee)){
  1039. // if($d->PackageDetail->voice_fee == 0){
  1040. // $d->PackageDetail->voice_fee = 'No';
  1041. // $d->PackageDetail->save();
  1042. // $final[] = $d->_id;
  1043. // }
  1044. // }
  1045. }
  1046. dd($final);
  1047. }
  1048. public function convertStaffDb()
  1049. {
  1050. // $s = OldResidential::first();
  1051. return $this->subscriberID();
  1052. // return $this->checkResidential();
  1053. // return $this->test2();
  1054. // return $this->updateWorkOrder();
  1055. // return $this->updateDocket();
  1056. // return $this->updateHistory();
  1057. // return $this->staffConvert();
  1058. // return $this->convertFormAndRelation();
  1059. // return $this->convertFormAndRelationBusiness();
  1060. // return $this->dealerConvert();
  1061. // return $this->addWotoExistingForm();
  1062. // $a = array(); $count = 0;
  1063. // $oldDocket = Docket::all();
  1064. // $newWork = WorkOrderLaravel::where('status','Completed')->get()->toArray();
  1065. // $i = 0;
  1066. // foreach ( $oldDocket as $o ) {
  1067. // if(array_search($o->work_order_id, array_column($newWork, 'wo')) !== False) {
  1068. // // $a[] = $o->docket_id.' - '.$o->work_order_id;
  1069. // $a[] = $o->docket_id;
  1070. // $xNw = DocketLaravel::where('work_order_id',$o->work_order_id)->first();
  1071. // if(empty($xNw)){
  1072. // $testDate = $o->end_job;
  1073. // $date = str_replace('/','-',$testDate);
  1074. // $timestamp = strtotime($date);
  1075. // //Convert timestamp to carbon format for created_at
  1076. // $go = Carbon::createFromTimestamp($timestamp).".000Z";
  1077. // $time = Carbon::createFromTimeString($go);
  1078. // $wo = WorkOrderLaravel::where('wo',$o->work_order_id)->first();
  1079. // $do = new DocketLaravel();
  1080. // $do->work_order_id = $o->work_order_id;
  1081. // $do->docket_id = $o->docket_id;
  1082. // $do->nature_work = $o->nature_work;
  1083. // $do->installer_id = $o->installer_id;
  1084. // $do->end_job = $time->toDateTimeString();
  1085. // $do->router_serial_number = $o->router_serial_number;
  1086. // $do->mac_router = $o->mac_router;
  1087. // $do->cable_read = $o->cable_read;
  1088. // $do->condition = $o->condition;
  1089. // $do->Note = $o->Note;
  1090. // $do->Rating1 = $o->Rating1;
  1091. // $do->Rating2 = $o->Rating2;
  1092. // $do->Rating3 = $o->Rating3;
  1093. // $do->customer_signature = $o->customer_signature;
  1094. // $do->created_at= $time;
  1095. // $wo->docketlaravel()->save($do);
  1096. // $i++;
  1097. // }
  1098. // }
  1099. // }
  1100. // // $xNw1 = WorkOrderLaravel::with('FormLaravel')->get();
  1101. // // $fm = FormLaravel::with('WorkOrderLaravel','SubscribersLaravel')->first();
  1102. // // $docket = DocketLaravel::where('work_order_id',$fm->WorkOrderLaravel->wo)->first();
  1103. // // $withoutDuplicates = array_unique($a);
  1104. // // $duplicates = array_diff($a, $withoutDuplicates);
  1105. // // dd(count($newWork) .'-'.$i);
  1106. // $doc = DocketLaravel::all();
  1107. // dd(count($doc));
  1108. }
  1109. }