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.

BusinessController.php 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <?php
  2. namespace App\Http\Controllers\Form;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Auth;
  6. use App\Mail\CustomerBInvoice;
  7. use App\Jobs\SendCustomerInvoiceB;
  8. use Carbon\Carbon;
  9. use Validator;
  10. use File;
  11. use App\Model\Coverage;
  12. use App\Model\Product;
  13. use App\Model\Form;
  14. use App\Model\Subscriber;
  15. use App\Model\PackageDetail;
  16. use App\Model\FormStatus;
  17. use App\Staff;
  18. use App\Model\StaffDetail;
  19. class BusinessController extends Controller
  20. {
  21. public function successSubmit()
  22. {
  23. return view('sales.form.after_submit_form');
  24. }
  25. public function successVerified()
  26. {
  27. return view('sales.form.success_verify');
  28. }
  29. public function sendInvoice($subscriber_id)
  30. {
  31. $subscriber = Subscriber::with('Form')->where('subscriber_id', $subscriber_id)->first();
  32. $form = Form::with('Subscriber', 'PackageDetail')->where('_id', $subscriber->_id)->first();
  33. $product = Product::where('speed', $form->PackageDetail->name)->where('formT', $form->type_application)->first();
  34. SendCustomerInvoiceB::dispatch($form, $product, $form->Subscriber->email);
  35. return $form->_id;
  36. }
  37. function random_code($limit)
  38. {
  39. return substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, $limit);
  40. }
  41. public function viewFormAddress($package)
  42. {
  43. $dealer_id = '';
  44. $coverage = Coverage::where('Type', 'B')->groupBy('building_name')->orderBy('building_name')->get();
  45. // dd($coverage);
  46. return view('sales.form.business_address', compact('coverage', 'package', 'dealer_id'));
  47. }
  48. public function viewFormApplication(Request $request)
  49. {
  50. $data = array();
  51. $coverage = Coverage::where('building_name', $request->coverage)->where('street', $request->street)->get();
  52. array_push($data, array(
  53. 'coverage' => $coverage[0]['_id'],
  54. 'unit' => $request->unit,
  55. 'street' => $request->street,
  56. 'package' => $request->package
  57. ));
  58. return view('sales.form.business_application_information', compact('data'));
  59. }
  60. public function viewFormPackage(Request $request)
  61. {
  62. $data = array();
  63. array_push($data, array(
  64. 'coverage' => $request->coverage,
  65. 'unit' => $request->unit,
  66. 'street' => $request->street,
  67. 'package' => $request->package,
  68. 'application' => $request->application,
  69. 'company_name' => $request->company_name,
  70. 'company_register' => $request->company_register,
  71. 'company_number' => $request->company_number,
  72. 'company_fax' => $request->company_fax,
  73. 'full_name' => $request->full_name,
  74. 'nric_passport' => $request->nric_passport,
  75. 'designation' => $request->designation,
  76. 'contact_primary' => $request->contact_primary,
  77. 'contact_secondary' => $request->contact_secondary,
  78. 'email' => $request->email,
  79. ));
  80. $pg = $request->package;
  81. $coverage = Coverage::where('_id', $request->coverage)->first();
  82. $city = $coverage->city;
  83. return view('sales.form.business_package', compact('data', 'pg', 'city'));
  84. }
  85. public function viewFormPreview(Request $request)
  86. {
  87. $data = array();
  88. $coverage = Coverage::where('_id', $request->coverage)->first();
  89. $product = Product::where('formT', 'B')->where('package_name', $request->package)->first();
  90. $otc = 0.0;
  91. $total_monthly = 0;
  92. $gst = '';
  93. $promo_st = '';
  94. $voice = "No";
  95. if ($request->voice == "Yes") {
  96. $voice = $request->voice;
  97. $voice_price = 20;
  98. } else {
  99. $voice = "No";
  100. $voice_price = 0;
  101. }
  102. $ip_fee = 0;
  103. $ip_tax = 0;
  104. if ($request->ip == "1 Fixed IP RM200/1P/Month") {
  105. $ip_fee = 200;
  106. $ip_tax = number_format((floatval($ip_fee) * 1.06), 2);
  107. } elseif ($request->ip == "5 Fixed IP RM400/1P/Month") {
  108. $ip_fee = 400;
  109. $ip_tax = number_format((floatval($ip_fee) * 1.06), 2);
  110. }
  111. if ($request->package != "1Gbps" && $request->subscription == '24') {
  112. $promo_price = number_format(floatval($product->retail_price) - 10);
  113. $promo_st = number_format(floatval($promo_price) * 1.06, 2);
  114. $total_monthly = number_format($promo_st + ($voice_price * 1.06) + $ip_tax, 2);
  115. } else if ($request->package == "1Gbps") {
  116. if ($request->subscription == '24' && $coverage->city == 'CYBERJAYA') {
  117. $gst = 1058.94;
  118. $total_monthly = 1058.94;
  119. } else {
  120. $gst = 3708.94;
  121. $total_monthly = 3708.94;
  122. }
  123. } else {
  124. $gst = number_format(floatval($product->retail_price) * 1.06, 2);
  125. $total_monthly = number_format($gst + ($voice_price * 1.06) + $ip_tax, 2);
  126. }
  127. if ($request->subscription == '12' && $voice == 'No') {
  128. if ($request->package != '50Mbps') {
  129. $otc = 400;
  130. } else {
  131. $otc = 300;
  132. }
  133. $deposit = $product->deposit;
  134. } else if ($request->subscription == '12' && $voice == 'Yes') {
  135. $otc = 300 + 100;
  136. $deposit = $product->deposit;
  137. } else {
  138. $otc = 0.0;
  139. $deposit = $product->deposit;
  140. }
  141. $otc_st = number_format(floatval($otc) * 1.06, 2);
  142. $upfront_total = number_format(floatval($otc_st) + $deposit, 2);
  143. $total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit + $ip_tax, 2);
  144. array_push($data, array(
  145. 'coverage' => $request->coverage,
  146. 'unit' => $request->unit,
  147. 'street' => $request->street,
  148. 'package' => $request->package,
  149. 'application' => $request->application,
  150. 'company_name' => $request->company_name,
  151. 'company_register' => $request->company_register,
  152. 'company_number' => $request->company_number,
  153. 'company_fax' => $request->company_fax,
  154. 'full_name' => $request->full_name,
  155. 'nric_passport' => $request->nric_passport,
  156. 'designation' => $request->designation,
  157. 'contact_primary' => $request->contact_primary,
  158. 'contact_secondary' => $request->contact_secondary,
  159. 'email' => $request->email,
  160. 'subscription' => $request->subscription,
  161. 'billing' => $request->billing,
  162. 'voice' => $voice,
  163. 'ip' => $request->ip,
  164. 'ip_fee' => $ip_fee,
  165. 'ip_tax' => $ip_tax,
  166. 'thedate' => $request->thedate,
  167. ));
  168. return view('sales.form.business_preview', compact('data', 'coverage', 'product', 'deposit', 'otc', 'otc_st', 'gst', 'promo_price', 'promo_st', 'total_monthly', 'upfront_total'));
  169. }
  170. public function storeFormData(Request $request)
  171. {
  172. $su_id = '';
  173. $pathIconF = '';
  174. $pathIconB = '';
  175. $pathForm9 = '';
  176. do {
  177. $su_id = strtoupper('CBB-' . $this->random_code(6) . 'B');
  178. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  179. $destinationPath = 'document/' . $su_id;
  180. // create folder/dir if not exist
  181. if (!File::exists(public_path() . '/' . $destinationPath)) {
  182. File::makeDirectory(public_path() . '/' . $destinationPath, 0777, true);
  183. }
  184. if ($request->hasfile('front_ic')) {
  185. $icon = $request->file('front_ic');
  186. $icon->move($destinationPath, 'frontic.' . $icon->getClientOriginalExtension());
  187. $pathIconF = '/' . $destinationPath . '/frontic.' . $icon->getClientOriginalExtension();
  188. }
  189. if ($request->hasfile('back_ic')) {
  190. $icon = $request->file('back_ic');
  191. $icon->move($destinationPath, 'backic.' . $icon->getClientOriginalExtension());
  192. $pathIconB = '/' . $destinationPath . '/backic.' . $icon->getClientOriginalExtension();
  193. }
  194. if ($request->hasfile('form9')) {
  195. $icon = $request->file('form9');
  196. $icon->move($destinationPath, 'formD.' . $icon->getClientOriginalExtension());
  197. $pathForm9 = '/' . $destinationPath . '/formD.' . $icon->getClientOriginalExtension();
  198. }
  199. if ($pathForm9 != '' && $pathIconB != '' && $pathIconF != '') {
  200. $coverage = Coverage::where('_id', $request->coverage)->first();
  201. $product = Product::where('formT', 'B')->where('package_name', $request->package)->first();
  202. $sl = Form::create([
  203. 'type_service' => $request->application,
  204. 'type_application' => 'B',
  205. 'project_type' => $coverage->project_type,
  206. 'status_payment' => 'paid',
  207. 'status_email' => 'unverified',
  208. 'customer_category' => 'Allo',
  209. 'remark_form' => ''
  210. ]);
  211. $sdl = new Subscriber();
  212. $sdl->subscriber_id = $su_id;
  213. $sdl->name = $request->full_name;
  214. $sdl->ic = $request->nric_passport;
  215. $sdl->company_name = $request->company_name;
  216. $sdl->company_reg = $request->company_register;
  217. $sdl->company_num = $request->company_number;
  218. $sdl->company_fax = $request->company_fax;
  219. $sdl->designation = $request->designation;
  220. $sdl->email = $request->email;
  221. $sdl->phone1 = $request->contact_primary;
  222. $sdl->phone2 = $request->contact_secondary;
  223. $sdl->unit_no = $request->unit;
  224. $sdl->building_name = $coverage->building_name;
  225. $sdl->street = $request->street;
  226. $sdl->postcode = $coverage->postcode;
  227. $sdl->city = $coverage->city;
  228. $sdl->state = $coverage->state;
  229. $sdl->front_ic = $pathIconF;
  230. $sdl->back_ic = $pathIconB;
  231. $sdl->form9_44 = $pathForm9;
  232. $packageD = new PackageDetail();
  233. $packageD->contract = $request->subscription;
  234. $packageD->name = $product->speed;
  235. if ($request->gst != null) {
  236. $packageD->montly_fee = $request->gst;
  237. } else {
  238. $packageD->montly_fee = $request->promo_st;
  239. }
  240. $packageD->voice_fee = $request->voice;
  241. $packageD->ip = $request->ip;
  242. $packageD->deposit = $request->deposit;
  243. $packageD->upfront_payment = $request->otc;
  244. $packageD->ip_tax = $request->ip_tax;
  245. $packageD->rfs = $request->rfs;
  246. $sl->subscriber()->save($sdl);
  247. $sl->packagedetail()->save($packageD);
  248. $f_id = $this->sendInvoice($su_id);
  249. $stat = new FormStatus();
  250. $stat->form_id = $f_id;
  251. $stat->status_id = 1;
  252. $stat->date = new \MongoDB\BSON\UTCDateTime(time() * 1000);
  253. $stat->status = 'Submitted';
  254. $stat->desc = 'The form already been submit';
  255. $sl->formstatus()->save($stat);
  256. return redirect('http://db.citybroadband.my/business/application-form/success-submit');
  257. }
  258. }
  259. /***
  260. ** Dealer
  261. ***/
  262. public function viewFormAddressD($package, $dealer_id)
  263. {
  264. $coverage = Coverage::where('Type', 'B')->groupBy('building_name')->orderBy('building_name')->get();
  265. return view('sales.form.dealer.business_address', compact('coverage', 'package', 'dealer_id'));
  266. }
  267. public function viewFormApplicationD(Request $request)
  268. {
  269. $data = array();
  270. $coverage = Coverage::where('building_name', $request->coverage)->where('street', $request->street)->get();
  271. array_push($data, array(
  272. 'coverage' => $coverage[0]['_id'],
  273. 'unit' => $request->unit,
  274. 'street' => $request->street,
  275. 'package' => $request->package,
  276. 'dealer_id' => $request->dealer_id,
  277. ));
  278. return view('sales.form.dealer.business_application_information', compact('data'));
  279. }
  280. public function viewFormPackageD(Request $request)
  281. {
  282. $data = array();
  283. array_push($data, array(
  284. 'coverage' => $request->coverage,
  285. 'unit' => $request->unit,
  286. 'street' => $request->street,
  287. 'package' => $request->package,
  288. 'application' => $request->application,
  289. 'company_name' => $request->company_name,
  290. 'company_register' => $request->company_register,
  291. 'company_number' => $request->company_number,
  292. 'company_fax' => $request->company_fax,
  293. 'full_name' => $request->full_name,
  294. 'nric_passport' => $request->nric_passport,
  295. 'ip' => $request->ip,
  296. 'designation' => $request->designation,
  297. 'contact_primary' => $request->contact_primary,
  298. 'contact_secondary' => $request->contact_secondary,
  299. 'email' => $request->email,
  300. 'dealer_id' => $request->dealer_id,
  301. ));
  302. $pg = $request->package;
  303. $coverage = Coverage::where('_id', $request->coverage)->first();
  304. $city = $coverage->city;
  305. return view('sales.form.dealer.business_package', compact('data', 'pg', 'city'));
  306. }
  307. public function viewFormPreviewD(Request $request)
  308. {
  309. $data = array();
  310. $coverage = Coverage::where('_id', $request->coverage)->first();
  311. $product = Product::where('formT', 'B')->where('package_name', $request->package)->first();
  312. $otc = 0.0;
  313. $total_monthly = 0;
  314. $gst = '';
  315. $promo_st = '';
  316. $voice = "No";
  317. if ($request->voice == "Yes") {
  318. $voice = $request->voice;
  319. $voice_price = 20;
  320. } else {
  321. $voice = "No";
  322. $voice_price = 0;
  323. }
  324. $ip_fee = 0;
  325. $ip_tax = 0;
  326. if ($request->ip == "1 Fixed IP RM200/1P/Month") {
  327. $ip_fee = 200;
  328. $ip_tax = number_format((floatval($ip_fee) * 1.06), 2);
  329. } elseif ($request->ip == "5 Fixed IP RM400/1P/Month") {
  330. $ip_fee = 400;
  331. $ip_tax = number_format((floatval($ip_fee) * 1.06), 2);
  332. }
  333. if ($request->package != "1Gbps" && $request->subscription == '24') {
  334. $promo_price = number_format(floatval($product->retail_price) - 10);
  335. $promo_st = number_format(floatval($promo_price) * 1.06, 2);
  336. $total_monthly = number_format($promo_st + ($voice_price * 1.06) + $ip_tax, 2);
  337. } else if ($request->package == "1Gbps") {
  338. if ($request->subscription == '24' && $coverage->city == 'CYBERJAYA') {
  339. $gst = 1058.94;
  340. $total_monthly = 1058.94;
  341. } else {
  342. $gst = 3708.94;
  343. $total_monthly = 3708.94;
  344. }
  345. } else {
  346. $gst = number_format(floatval($product->retail_price) * 1.06, 2);
  347. $total_monthly = number_format($gst + ($voice_price * 1.06) + $ip_tax, 2);
  348. }
  349. if ($request->subscription == '12' && $voice == 'No') {
  350. if ($request->package != '50Mbps') {
  351. $otc = 400;
  352. } else {
  353. $otc = 300;
  354. }
  355. $deposit = $product->deposit;
  356. } else if ($request->subscription == '12' && $voice == 'Yes') {
  357. $otc = 300 + 100;
  358. $deposit = $product->deposit;
  359. } else if ($request->subscription == '12' && $request->package != '50Mbps') {
  360. $otc = 400;
  361. $deposit = $product->deposit;
  362. } else {
  363. $otc = 0.0;
  364. $deposit = $product->deposit;
  365. }
  366. $otc_st = number_format(floatval($otc) * 1.06, 2);
  367. $upfront_total = number_format(floatval($otc_st) + $deposit, 2);
  368. $total = number_format((floatval($product->retail_price) * 1.06) + ($otc * 1.06) + $deposit + $ip_tax, 2);
  369. array_push($data, array(
  370. 'coverage' => $request->coverage,
  371. 'unit' => $request->unit,
  372. 'street' => $request->street,
  373. 'package' => $request->package,
  374. 'application' => $request->application,
  375. 'company_name' => $request->company_name,
  376. 'company_register' => $request->company_register,
  377. 'company_number' => $request->company_number,
  378. 'company_fax' => $request->company_fax,
  379. 'full_name' => $request->full_name,
  380. 'nric_passport' => $request->nric_passport,
  381. 'designation' => $request->designation,
  382. 'contact_primary' => $request->contact_primary,
  383. 'contact_secondary' => $request->contact_secondary,
  384. 'email' => $request->email,
  385. 'subscription' => $request->subscription,
  386. 'billing' => $request->billing,
  387. 'voice' => $voice,
  388. 'ip' => $request->ip,
  389. 'ip_fee' => $ip_fee,
  390. 'ip_tax' => $ip_tax,
  391. 'thedate' => $request->thedate,
  392. 'dealer_id' => $request->dealer_id,
  393. ));
  394. return view('sales.form.dealer.business_preview', compact('data', 'coverage', 'product', 'deposit', 'otc', 'otc_st', 'gst', 'promo_price', 'promo_st', 'total_monthly', 'upfront_total'));
  395. }
  396. public function storeFormDataD(Request $request)
  397. {
  398. $su_id = '';
  399. $pathIconF = '';
  400. $pathIconB = '';
  401. $pathForm9 = '';
  402. $pathPaymentReceipt = '';
  403. $pathSoForm = '';
  404. do {
  405. $su_id = strtoupper('CBB-' . $this->random_code(6) . 'B');
  406. } while (Subscriber::where("subscriber_id", "=", $su_id)->first() instanceof Subscriber);
  407. $destinationPath = 'document/' . $su_id;
  408. // create folder/dir if not exist
  409. if (!File::exists(public_path() . '/' . $destinationPath)) {
  410. File::makeDirectory(public_path() . '/' . $destinationPath, 0777, true);
  411. }
  412. if ($request->hasfile('front_ic')) {
  413. $icon = $request->file('front_ic');
  414. $icon->move($destinationPath, 'frontic.' . $icon->getClientOriginalExtension());
  415. $pathIconF = '/' . $destinationPath . '/frontic.' . $icon->getClientOriginalExtension();
  416. }
  417. if ($request->hasfile('back_ic')) {
  418. $icon = $request->file('back_ic');
  419. $icon->move($destinationPath, 'backic.' . $icon->getClientOriginalExtension());
  420. $pathIconB = '/' . $destinationPath . '/backic.' . $icon->getClientOriginalExtension();
  421. }
  422. if ($request->hasfile('form9')) {
  423. $icon = $request->file('form9');
  424. $icon->move($destinationPath, 'formD.' . $icon->getClientOriginalExtension());
  425. $pathForm9 = '/' . $destinationPath . '/formD.' . $icon->getClientOriginalExtension();
  426. }
  427. if ($request->hasfile('paymentReceipt')) {
  428. $icon = $request->file('paymentReceipt');
  429. $icon->move($destinationPath, 'paymentReceipt.' . $icon->getClientOriginalExtension());
  430. $pathPaymentReceipt = '/' . $destinationPath . '/paymentReceipt.' . $icon->getClientOriginalExtension();
  431. }
  432. if ($request->hasfile('soForm')) {
  433. $icon = $request->file('soForm');
  434. $icon->move($destinationPath, 'soForm.' . $icon->getClientOriginalExtension());
  435. $pathSoForm = '/' . $destinationPath . '/soForm.' . $icon->getClientOriginalExtension();
  436. }
  437. if ($pathForm9 != '' && $pathIconB != '' && $pathIconF != '') {
  438. $staff = Staff::with('StaffDetail')->where('_id', $request->dealer_id)->first();
  439. if (!empty($staff)) {
  440. $coverage = Coverage::where('_id', $request->coverage)->first();
  441. $product = Product::where('formT', 'B')->where('package_name', $request->package)->first();
  442. $sl = new Form();
  443. $sl->type_service = $request->application;
  444. $sl->type_application = 'B';
  445. $sl->project_type = $coverage->project_type;
  446. $sl->status_payment = 'paid';
  447. $sl->status_email = 'unverified';
  448. $sl->customer_category = 'Allo';
  449. $sl->remark_form = '';
  450. $sl->dealer_id = $request->dealer_id;
  451. $sl->company_id = $staff->StaffDetail->company_id;
  452. $staff->form()->save($sl);
  453. $sdl = new Subscriber();
  454. $sdl->subscriber_id = $su_id;
  455. $sdl->name = $request->full_name;
  456. $sdl->ic = $request->nric_passport;
  457. $sdl->company_name = $request->company_name;
  458. $sdl->company_reg = $request->company_register;
  459. $sdl->company_num = $request->company_number;
  460. $sdl->company_fax = $request->company_fax;
  461. $sdl->designation = $request->designation;
  462. $sdl->email = $request->email;
  463. $sdl->phone1 = $request->contact_primary;
  464. $sdl->phone2 = $request->contact_secondary;
  465. $sdl->unit_no = $request->unit;
  466. $sdl->building_name = $coverage->building_name;
  467. $sdl->street = $request->street;
  468. $sdl->postcode = $coverage->postcode;
  469. $sdl->city = $coverage->city;
  470. $sdl->state = $coverage->state;
  471. $sdl->front_ic = $pathIconF;
  472. $sdl->back_ic = $pathIconB;
  473. $sdl->form9_44 = $pathForm9;
  474. $sdl->paymentReceipt = $pathPaymentReceipt;
  475. $sdl->soForm = $pathSoForm;
  476. $packageD = new PackageDetail();
  477. $packageD->contract = $request->subscription;
  478. $packageD->name = $product->speed;
  479. if ($request->gst != null) {
  480. $packageD->montly_fee = $request->gst;
  481. } else {
  482. $packageD->montly_fee = $request->promo_st;
  483. }
  484. $packageD->voice_fee = $request->voice;
  485. $packageD->ip = $request->ip;
  486. $packageD->ip_tax = $request->ip_tax;
  487. $packageD->deposit = $request->deposit;
  488. $packageD->upfront_payment = $request->otc;
  489. $packageD->rfs = $request->rfs;
  490. $sl->subscriber()->save($sdl);
  491. $sl->packagedetail()->save($packageD);
  492. $f_id = $this->sendInvoice($su_id);
  493. $stat = new FormStatus();
  494. $stat->form_id = $f_id;
  495. $stat->status_id = 1;
  496. $stat->date = new \MongoDB\BSON\UTCDateTime(time() * 1000);
  497. $stat->status = 'Submitted';
  498. $stat->desc = 'The form already been submit';
  499. $sl->formstatus()->save($stat);
  500. return redirect('http://db.citybroadband.my/business/application-form/success-submit');
  501. }
  502. }
  503. }
  504. public function verifyEmail($subscriber_id)
  505. {
  506. $subscriber = Subscriber::where('subscriber_id', $subscriber_id)->first();
  507. if (!empty($subscriber)) {
  508. $form = Form::where('_id', $subscriber->_id)->first();
  509. if (!empty($form)) {
  510. if ($form->status_email == 'unverified') {
  511. $form->status_email = 'verified';
  512. $form->save();
  513. $stat = new FormStatus();
  514. $stat->form_id = $form->_id;
  515. $stat->status_id = 2;
  516. $stat->date = new \MongoDB\BSON\UTCDateTime(time() * 1000);
  517. $stat->status = 'Verified';
  518. $stat->desc = 'Email already been verified by customer';
  519. $form->formstatus()->save($stat);
  520. return redirect('http://db.citybroadband.my/business/application-form/success-verified');
  521. }
  522. }
  523. }
  524. }
  525. public function resendEmail($subscriber_id)
  526. {
  527. $f_id = $this->sendInvoice($subscriber_id);
  528. return $f_id;
  529. }
  530. public function checkEmailTemplate($subscriber_id)
  531. {
  532. $subscriber = Subscriber::where('subscriber_id', $subscriber_id)->first();
  533. if (!empty($subscriber)) {
  534. $form = Form::where('_id', $subscriber->_id)->first();
  535. $product = Product::where('speed', $form->PackageDetail->name)->where('formT', $form->type_application)->first();
  536. }
  537. return view('email.invoiceb', compact('form', 'product'));
  538. }
  539. }