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

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