Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.77 KB | None | 0 0
  1. <?php namespace App\Http\Controllers;
  2.  
  3. use Session;
  4. use Request;
  5. use DB;
  6. use CRUDBooster;
  7.  
  8.  
  9. use App\Models\AreaModel;
  10. use App\Models\UserModel;
  11. use App\Models\OwnerModel;
  12. use App\Models\UserOwnerModel;
  13.  
  14.  
  15. class AdminCpiMstOwnerController extends \crocodicstudio\crudbooster\controllers\CBController {
  16.  
  17. public function cbInit() {
  18.  
  19. # START CONFIGURATION DO NOT REMOVE THIS LINE
  20. $this->title_field = "name";
  21. $this->limit = "10";
  22. $this->orderby = "id,desc";
  23. $this->global_privilege = false;
  24. $this->button_table_action = true;
  25. $this->button_bulk_action = false;
  26. $this->button_action_style = "button_icon";
  27. $this->button_add = true;
  28. $this->button_edit = true;
  29. $this->button_delete = true;
  30. $this->button_detail = true;
  31. $this->button_show = false;
  32. $this->button_filter = false;
  33. $this->button_import = false;
  34. $this->button_export = false;
  35. $this->table = "cpi_mst_owner";
  36. # END CONFIGURATION DO NOT REMOVE THIS LINE
  37.  
  38. # START COLUMNS DO NOT REMOVE THIS LINE
  39. $this->col = [];
  40. $this->col[] = ["label"=>"Owner","name"=>"owner_name"];
  41. $this->col[] = ["label"=>"Technical Support", "name"=>"employee_id", "callback_php"=>'$this->technical_support($row->id)'];
  42. $this->col[] = ["label"=>"Email","name"=>"email"];
  43. $this->col[] = ["label"=>"No HP","name"=>"phone_number"];
  44.  
  45.  
  46. # END COLUMNS DO NOT REMOVE THIS LINE
  47.  
  48. # START FORM DO NOT REMOVE THIS LINE
  49. $this->form = [];
  50. $this->form[] = ['label'=>'Owner','name'=>'owner_name','type'=>'text','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
  51. $this->form[] = ['label'=>'Technical Support','name'=>'employee_ids[]','type'=>'select2','validation'=>'required|integer|min:0','width'=>'col-sm-10','datatable'=>'cpi_mst_employee,name'];
  52. $this->form[] = ['label'=>'Email','name'=>'email','type'=>'email','validation'=>'required|string|min:3|max:70','width'=>'col-sm-10'];
  53. $this->form[] = ['label'=>'No HP','name'=>'phone_number','type'=>'number','validation'=>'required|numeric','width'=>'col-sm-10'];
  54. # END FORM DO NOT REMOVE THIS LINE
  55.  
  56. # OLD START FORM
  57. //$this->form = [];
  58. //$this->form[] = ["label"=>"Name","name"=>"name","type"=>"text","required"=>TRUE,"validation"=>"required|string|min:3|max:70","placeholder"=>"You can only enter the letter only"];
  59. //$this->form[] = ["label"=>"Address","name"=>"address","type"=>"text","required"=>TRUE,"validation"=>"required|min:1|max:255"];
  60. //$this->form[] = ["label"=>"Phone Number","name"=>"phone_number","type"=>"number","required"=>TRUE,"validation"=>"required|numeric","placeholder"=>"You can only enter the number only"];
  61. //$this->form[] = ["label"=>"Created By","name"=>"created_by","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
  62. //$this->form[] = ["label"=>"Updated By","name"=>"updated_by","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
  63. //$this->form[] = ["label"=>"Deleted","name"=>"deleted","type"=>"number","required"=>TRUE,"validation"=>"required|integer|min:0"];
  64. # OLD END FORM
  65.  
  66. /*
  67. | ----------------------------------------------------------------------
  68. | Sub Module
  69. | ----------------------------------------------------------------------
  70. | @label = Label of action
  71. | @path = Path of sub module
  72. | @foreign_key = foreign key of sub table/module
  73. | @button_color = Bootstrap Class (primary,success,warning,danger)
  74. | @button_icon = Font Awesome Class
  75. | @parent_columns = Sparate with comma, e.g : name,created_at
  76. |
  77. */
  78. $this->sub_module = array();
  79.  
  80.  
  81. /*
  82. | ----------------------------------------------------------------------
  83. | Add More Action Button / Menu
  84. | ----------------------------------------------------------------------
  85. | @label = Label of action
  86. | @url = Target URL, you can use field alias. e.g : [id], [name], [title], etc
  87. | @icon = Font awesome class icon. e.g : fa fa-bars
  88. | @color = Default is primary. (primary, warning, succecss, info)
  89. | @showIf = If condition when action show. Use field alias. e.g : [id] == 1
  90. |
  91. */
  92. $this->addaction = array();
  93.  
  94.  
  95. /*
  96. | ----------------------------------------------------------------------
  97. | Add More Button Selected
  98. | ----------------------------------------------------------------------
  99. | @label = Label of action
  100. | @icon = Icon from fontawesome
  101. | @name = Name of button
  102. | Then about the action, you should code at actionButtonSelected method
  103. |
  104. */
  105. $this->button_selected = array();
  106.  
  107.  
  108. /*
  109. | ----------------------------------------------------------------------
  110. | Add alert message to this module at overheader
  111. | ----------------------------------------------------------------------
  112. | @message = Text of message
  113. | @type = warning,success,danger,info
  114. |
  115. */
  116. $this->alert = array();
  117.  
  118.  
  119.  
  120. /*
  121. | ----------------------------------------------------------------------
  122. | Add more button to header button
  123. | ----------------------------------------------------------------------
  124. | @label = Name of button
  125. | @url = URL Target
  126. | @icon = Icon from Awesome.
  127. |
  128. */
  129. $this->index_button = array();
  130.  
  131.  
  132.  
  133. /*
  134. | ----------------------------------------------------------------------
  135. | Customize Table Row Color
  136. | ----------------------------------------------------------------------
  137. | @condition = If condition. You may use field alias. E.g : [id] == 1
  138. | @color = Default is none. You can use bootstrap success,info,warning,danger,primary.
  139. |
  140. */
  141. $this->table_row_color = array();
  142.  
  143.  
  144. /*
  145. | ----------------------------------------------------------------------
  146. | You may use this bellow array to add statistic at dashboard
  147. | ----------------------------------------------------------------------
  148. | @label, @count, @icon, @color
  149. |
  150. */
  151. $this->index_statistic = array();
  152.  
  153.  
  154.  
  155. /*
  156. | ----------------------------------------------------------------------
  157. | Add javascript at body
  158. | ----------------------------------------------------------------------
  159. | javascript code in the variable
  160. | $this->script_js = "function() { ... }";
  161. |
  162. */
  163. $this->script_js = "";
  164.  
  165.  
  166. /*
  167. | ----------------------------------------------------------------------
  168. | Include HTML Code before index table
  169. | ----------------------------------------------------------------------
  170. | html code to display it before index table
  171. | $this->pre_index_html = "<p>test</p>";
  172. |
  173. */
  174. $this->pre_index_html = null;
  175.  
  176.  
  177.  
  178. /*
  179. | ----------------------------------------------------------------------
  180. | Include HTML Code after index table
  181. | ----------------------------------------------------------------------
  182. | html code to display it after index table
  183. | $this->post_index_html = "<p>test</p>";
  184. |
  185. */
  186. $this->post_index_html = null;
  187.  
  188.  
  189.  
  190. /*
  191. | ----------------------------------------------------------------------
  192. | Include Javascript File
  193. | ----------------------------------------------------------------------
  194. | URL of your javascript each array
  195. | $this->load_js[] = asset("myfile.js");
  196. |
  197. */
  198. $this->load_js = [
  199. asset("js/owner-form.js")
  200. ];
  201.  
  202.  
  203.  
  204. /*
  205. | ----------------------------------------------------------------------
  206. | Add css style at body
  207. | ----------------------------------------------------------------------
  208. | css code in the variable
  209. | $this->style_css = ".style{....}";
  210. |
  211. */
  212. $this->style_css = NULL;
  213.  
  214.  
  215.  
  216. /*
  217. | ----------------------------------------------------------------------
  218. | Include css File
  219. | ----------------------------------------------------------------------
  220. | URL of your css each array
  221. | $this->load_css[] = asset("myfile.css");
  222. |
  223. */
  224. $this->load_css = array();
  225.  
  226.  
  227. }
  228.  
  229.  
  230. /*
  231. | ----------------------------------------------------------------------
  232. | Hook for button selected
  233. | ----------------------------------------------------------------------
  234. | @id_selected = the id selected
  235. | @button_name = the name of button
  236. |
  237. */
  238. public function actionButtonSelected($id_selected,$button_name) {
  239. //Your code here
  240.  
  241. }
  242.  
  243.  
  244. /*
  245. | ----------------------------------------------------------------------
  246. | Hook for manipulate query of index result
  247. | ----------------------------------------------------------------------
  248. | @query = current sql query
  249. |
  250. */
  251. public function hook_query_index(&$query) {
  252. //Your code here
  253.  
  254. }
  255.  
  256. /*
  257. | ----------------------------------------------------------------------
  258. | Hook for manipulate row of index table html
  259. | ----------------------------------------------------------------------
  260. |
  261. */
  262. public function hook_row_index($column_index,&$column_value) {
  263. //Your code here
  264. }
  265.  
  266. /*
  267. | ----------------------------------------------------------------------
  268. | Hook for manipulate data input before add data is execute
  269. | ----------------------------------------------------------------------
  270. | @arr
  271. |
  272. */
  273. public function hook_before_add(&$postdata) {
  274. //Your code here
  275.  
  276. }
  277.  
  278. /*
  279. | ----------------------------------------------------------------------
  280. | Hook for execute command after add public static function called
  281. | ----------------------------------------------------------------------
  282. | @id = last insert id
  283. |
  284. */
  285. public function hook_after_add($id) {
  286. //Your code here
  287.  
  288. }
  289.  
  290. /*
  291. | ----------------------------------------------------------------------
  292. | Hook for manipulate data input before update data is execute
  293. | ----------------------------------------------------------------------
  294. | @postdata = input post data
  295. | @id = current id
  296. |
  297. */
  298. public function hook_before_edit(&$postdata,$id) {
  299. //Your code here
  300.  
  301. }
  302.  
  303. /*
  304. | ----------------------------------------------------------------------
  305. | Hook for execute command after edit public static function called
  306. | ----------------------------------------------------------------------
  307. | @id = current id
  308. |
  309. */
  310. public function hook_after_edit($id) {
  311. //Your code here
  312.  
  313. }
  314.  
  315. /*
  316. | ----------------------------------------------------------------------
  317. | Hook for execute command before delete public static function called
  318. | ----------------------------------------------------------------------
  319. | @id = current id
  320. |
  321. */
  322. public function hook_before_delete($id) {
  323. //Your code here
  324.  
  325. }
  326.  
  327. /*
  328. | ----------------------------------------------------------------------
  329. | Hook for execute command after delete public static function called
  330. | ----------------------------------------------------------------------
  331. | @id = current id
  332. |
  333. */
  334. public function hook_after_delete($id) {
  335. //Your code here
  336.  
  337. }
  338.  
  339. //By the way, you can still create your own method in here... :)
  340. public function postAddSave(){
  341. dd(Request::all());
  342. try{
  343. $owner = OwnerModel::create([
  344. 'owner_name' => Request::get('owner_name'),
  345. // 'area_id' => Request::get('area_id'),
  346. 'employee_id' => Request::get('employee_id'),
  347. // 'city_id' => Request::get('city_id'),
  348. 'request_id' => Request::get('request_id'),
  349. // 'address' => Request::get('address'),
  350. 'email' => Request::get('email'),
  351. 'phone_number' => Request::get('phone_number'),
  352. 'created_at' => Request::get('created_at'),
  353. 'created_by' => Request::get('created_by'),
  354. 'updated_at' => Request::get('updated_at'),
  355. 'updated_by' => Request::get('updated_by'),
  356.  
  357. ])->id;
  358. foreach (Request::get('employee_id') as $employee_id) {
  359. UserOwnerModel::create([
  360. 'owner_id'=> $owner,
  361. 'employee_id'=> $employee_id
  362. ]);
  363. }
  364. return redirect('/admin/cpi_mst_owner?m=6');
  365. } catch (\Exception $e){
  366. return redirect()->back();
  367. }
  368. }
  369.  
  370. public function technical_support($id){
  371. // $owner = OwnerModel::find($id);
  372. // $ts = UserModel::find($owner->request_by)->name;
  373. // // dd($ts);
  374. // return $ts;
  375. }
  376.  
  377. // public function area($id){
  378. // $area= AreaModel::find($id)->name;
  379.  
  380. // return $area;
  381. // }
  382.  
  383. // public function city($id){
  384. // $ct= CityModel::find($id)->name_city;
  385. // return $ct;
  386.  
  387. // }
  388.  
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement