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.

ProductController.php 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. namespace App\Http\Controllers\v3\Api;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\v3\Api\BaseController;
  5. use Carbon\Carbon;
  6. use App\LatestModel\Staff;
  7. use App\LatestModel\StaffDetail;
  8. use App\LatestModel\Dealer;
  9. use App\LatestModel\DealerDetail;
  10. use App\LatestModel\Module\Form;
  11. use App\LatestModel\Module\FormStatus;
  12. use App\LatestModel\Module\Subscriber;
  13. use App\LatestModel\Module\WorkOrder;
  14. use App\LatestModel\Module\Docket;
  15. use App\LatestModel\Module\PackageDetail;
  16. use App\LatestModel\Module\Company;
  17. use App\LatestModel\Module\Coverage;
  18. use App\LatestModel\Module\Product;
  19. use App\LatestModel\Module\DealerClaim;
  20. use App\LatestModel\Module\Commission;
  21. class ProductController extends BaseController
  22. {
  23. public function getCommissionListR24()
  24. {
  25. $id = Auth::guard('ms')->id();
  26. $user = Staff::find($id);
  27. $email = $user->email;
  28. $marketdetail= Commission::where('contract','24')->where('formT','R')->orderBy('created_by','desc')->get();
  29. $curr = Carbon::now()->getTimestamp();
  30. $i = 0;
  31. $nested_data = array();
  32. if(!empty($marketdetail))
  33. {
  34. foreach ($marketdetail as $a)
  35. {
  36. $i++; $n1 = '';
  37. $reg_time = $a->created_at;
  38. $expiry_date = $reg_time->addDays(3);
  39. $expiry_date = $expiry_date->getTimestamp();
  40. if($curr < $expiry_date) {
  41. $n1 = "New/";
  42. }
  43. array_push($nested_data, array(
  44. 'index' => $n1.$i,
  45. 'formT' => $a->formT,
  46. 'ranges' => $a->ranges,
  47. 'comm' => $a->comm,
  48. 'category' => $a->category,
  49. 'contract' => $a->contract,
  50. 'action' => $a->_id
  51. ));
  52. }
  53. }
  54. return \DataTables::of($nested_data)->make(true);
  55. }
  56. public function getCommissionListR12()
  57. {
  58. $id = Auth::guard('ms')->id();
  59. $user = Staff::find($id);
  60. $email = $user->email;
  61. $marketdetail= Commission::where('contract','12')->where('formT','R')->orderBy('created_by','desc')->get();
  62. $curr = Carbon::now()->getTimestamp();
  63. $i = 0;
  64. $nested_data = array();
  65. if(!empty($marketdetail))
  66. {
  67. foreach ($marketdetail as $a)
  68. {
  69. $i++; $n1 = '';
  70. $reg_time = $a->created_at;
  71. $expiry_date = $reg_time->addDays(3);
  72. $expiry_date = $expiry_date->getTimestamp();
  73. if($curr < $expiry_date) {
  74. $n1 = "New/";
  75. }
  76. array_push($nested_data, array(
  77. 'index' => $n1.$i,
  78. 'formT' => $a->formT,
  79. 'ranges' => $a->ranges,
  80. 'comm' => $a->comm,
  81. 'category' => $a->category,
  82. 'contract' => $a->contract,
  83. 'action' => $a->_id
  84. ));
  85. }
  86. }
  87. return \DataTables::of($nested_data)->make(true);
  88. }
  89. public function getCommissionListB24Low()
  90. {
  91. $id = Auth::guard('ms')->id();
  92. $user = Staff::find($id);
  93. $email = $user->email;
  94. $marketdetail= Commission::where('contract','24')->where('formT','B')->where('packageR','10,30,50,100')->orderBy('created_by','desc')->get();
  95. $curr = Carbon::now()->getTimestamp();
  96. $i = 0;
  97. $nested_data = array();
  98. if(!empty($marketdetail))
  99. {
  100. foreach ($marketdetail as $a)
  101. {
  102. $i++; $n1 = '';
  103. $reg_time = $a->created_at;
  104. $expiry_date = $reg_time->addDays(3);
  105. $expiry_date = $expiry_date->getTimestamp();
  106. if($curr < $expiry_date) {
  107. $n1 = "New/";
  108. }
  109. array_push($nested_data, array(
  110. 'index' => $n1.$i,
  111. 'packageR' => $a->packageR,
  112. 'ranges' => $a->ranges,
  113. 'comm' => $a->comm,
  114. 'category' => $a->category,
  115. 'contract' => $a->contract,
  116. 'action' => $a->_id
  117. ));
  118. }
  119. }
  120. return \DataTables::of($nested_data)->make(true);
  121. }
  122. public function getCommissionListB24High()
  123. {
  124. $id = Auth::guard('ms')->id();
  125. $user = Staff::find($id);
  126. $email = $user->email;
  127. $marketdetail= Commission::where('contract','24')->where('formT','B')->orwhere('packageR','300')->orwhere('packageR','500')->orwhere('packageR','1')->orderBy('created_by','desc')->get();
  128. $curr = Carbon::now()->getTimestamp();
  129. $i = 0;
  130. $nested_data = array();
  131. if(!empty($marketdetail))
  132. {
  133. foreach ($marketdetail as $a)
  134. {
  135. $i++; $n1 = '';
  136. $reg_time = $a->created_at;
  137. $expiry_date = $reg_time->addDays(3);
  138. $expiry_date = $expiry_date->getTimestamp();
  139. if($curr < $expiry_date) {
  140. $n1 = "New/";
  141. }
  142. array_push($nested_data, array(
  143. 'index' => $n1.$i,
  144. 'packageR' => $a->packageR,
  145. 'ranges' => $a->ranges,
  146. 'comm' => $a->comm,
  147. 'category' => $a->category,
  148. 'contract' => $a->contract,
  149. 'action' => $a->_id
  150. ));
  151. }
  152. }
  153. return \DataTables::of($nested_data)->make(true);
  154. }
  155. public function getCommissionListB12Low()
  156. {
  157. $id = Auth::guard('ms')->id();
  158. $user = Staff::find($id);
  159. $email = $user->email;
  160. $marketdetail= Commission::where('contract','12')->where('formT','B')->where('packageR','10,30,50,100')->orderBy('created_by','desc')->get();
  161. $curr = Carbon::now()->getTimestamp();
  162. $i = 0;
  163. $nested_data = array();
  164. if(!empty($marketdetail))
  165. {
  166. foreach ($marketdetail as $a)
  167. {
  168. $i++; $n1 = '';
  169. $reg_time = $a->created_at;
  170. $expiry_date = $reg_time->addDays(3);
  171. $expiry_date = $expiry_date->getTimestamp();
  172. if($curr < $expiry_date) {
  173. $n1 = "New/";
  174. }
  175. array_push($nested_data, array(
  176. 'index' => $n1.$i,
  177. 'packageR' => $a->packageR,
  178. 'ranges' => $a->ranges,
  179. 'comm' => $a->comm,
  180. 'category' => $a->category,
  181. 'contract' => $a->contract,
  182. 'action' => $a->_id
  183. ));
  184. }
  185. }
  186. return \DataTables::of($nested_data)->make(true);
  187. }
  188. //Function to get commission list (1 year)
  189. public function getCommissionListB12High()
  190. {
  191. $id = Auth::guard('ms')->id();
  192. $user = Staff::find($id);
  193. $email = $user->email;
  194. $marketdetail= Commission::where('contract','12')->where('formT','B')->orwhere('packageR','300')->orwhere('packageR','500')->orwhere('packageR','1')->orderBy('created_by','desc')->get();
  195. $curr = Carbon::now()->getTimestamp();
  196. $i = 0;
  197. $nested_data = array();
  198. if(!empty($marketdetail))
  199. {
  200. foreach ($marketdetail as $a)
  201. {
  202. $i++; $n1 = '';
  203. $reg_time = $a->created_at;
  204. $expiry_date = $reg_time->addDays(3);
  205. $expiry_date = $expiry_date->getTimestamp();
  206. if($curr < $expiry_date) {
  207. $n1 = "New/";
  208. }
  209. array_push($nested_data, array(
  210. 'index' => $n1.$i,
  211. 'packageR' => $a->packageR,
  212. 'ranges' => $a->ranges,
  213. 'comm' => $a->comm,
  214. 'category' => $a->category,
  215. 'contract' => $a->contract,
  216. 'action' => $a->_id
  217. ));
  218. }
  219. }
  220. return \DataTables::of($nested_data)->make(true);
  221. }
  222. }