2222class OpportunitiesController extends Controller
2323{
2424 public $ show_action = true ;
25- public $ view_col = 'name ' ;
26- public $ listing_cols = ['id ' , 'name ' , 'organization ' , 'sales_stage ' , 'lead_source ' , 'expected_close_date ' , 'amount ' , 'assigned_to ' , 'contact ' ];
27-
28- public function __construct () {
29- // Field Access of Listing Columns
30- if (\Dwij \Laraadmin \Helpers \LAHelper::laravel_ver () == 5.3 ) {
31- $ this ->middleware (function ($ request , $ next ) {
32- $ this ->listing_cols = ModuleFields::listingColumnAccessScan ('Opportunities ' , $ this ->listing_cols );
33- return $ next ($ request );
34- });
35- } else {
36- $ this ->listing_cols = ModuleFields::listingColumnAccessScan ('Opportunities ' , $ this ->listing_cols );
37- }
38- }
3925
4026 /**
4127 * Display a listing of the Opportunities.
@@ -49,7 +35,7 @@ public function index()
4935 if (Module::hasAccess ($ module ->id )) {
5036 return View ('la.opportunities.index ' , [
5137 'show_actions ' => $ this ->show_action ,
52- 'listing_cols ' => $ this -> listing_cols ,
38+ 'listing_cols ' => Module:: getListingColumns ( ' Opportunities ' ) ,
5339 'module ' => $ module
5440 ]);
5541 } else {
@@ -111,7 +97,7 @@ public function show($id)
11197
11298 return view ('la.opportunities.show ' , [
11399 'module ' => $ module ,
114- 'view_col ' => $ this ->view_col ,
100+ 'view_col ' => $ module ->view_col ,
115101 'no_header ' => true ,
116102 'no_padding ' => "no-padding "
117103 ])->with ('opportunity ' , $ opportunity );
@@ -143,7 +129,7 @@ public function edit($id)
143129
144130 return view ('la.opportunities.edit ' , [
145131 'module ' => $ module ,
146- 'view_col ' => $ this ->view_col ,
132+ 'view_col ' => $ module ->view_col ,
147133 ])->with ('opportunity ' , $ opportunity );
148134 } else {
149135 return view ('errors.404 ' , [
@@ -207,25 +193,28 @@ public function destroy($id)
207193 *
208194 * @return
209195 */
210- public function dtajax (Request $ request )
196+ public function dtajax (Request $ request )
211197 {
198+ $ module = Module::get ('Opportunities ' );
199+ $ listing_cols = Module::getListingColumns ('Opportunities ' );
200+
212201 if (isset ($ request ->filter_column )) {
213- $ values = DB ::table ('opportunities ' )->select ($ this -> listing_cols )->whereNull ('deleted_at ' )->where ($ request ->filter_column , $ request ->filter_column_value );
202+ $ values = DB ::table ('opportunities ' )->select ($ listing_cols )->whereNull ('deleted_at ' )->where ($ request ->filter_column , $ request ->filter_column_value );
214203 } else {
215- $ values = DB ::table ('opportunities ' )->select ($ this -> listing_cols )->whereNull ('deleted_at ' );
204+ $ values = DB ::table ('opportunities ' )->select ($ listing_cols )->whereNull ('deleted_at ' );
216205 }
217206 $ out = Datatables::of ($ values )->make ();
218207 $ data = $ out ->getData ();
219208
220209 $ fields_popup = ModuleFields::getModuleFields ('Opportunities ' );
221210
222211 for ($ i =0 ; $ i < count ($ data ->data ); $ i ++) {
223- for ($ j =0 ; $ j < count ($ this -> listing_cols ); $ j ++) {
224- $ col = $ this -> listing_cols [$ j ];
212+ for ($ j =0 ; $ j < count ($ listing_cols ); $ j ++) {
213+ $ col = $ listing_cols [$ j ];
225214 if ($ fields_popup [$ col ] != null && starts_with ($ fields_popup [$ col ]->popup_vals , "@ " )) {
226215 $ data ->data [$ i ][$ j ] = ModuleFields::getFieldValue ($ fields_popup [$ col ], $ data ->data [$ i ][$ j ]);
227216 }
228- if ($ col == $ this ->view_col ) {
217+ if ($ col == $ module ->view_col ) {
229218 $ data ->data [$ i ][$ j ] = '<a href=" ' .url (config ('laraadmin.adminRoute ' ) . '/opportunities/ ' .$ data ->data [$ i ][0 ]).'"> ' .$ data ->data [$ i ][$ j ].'</a> ' ;
230219 }
231220 // else if($col == "author") {
0 commit comments