123 lines
6.0 KiB
PHP
123 lines
6.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
use Log;
|
|
|
|
class UserController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'ums';
|
|
$this->_module = 'users';
|
|
$this->_viewname = 'users';
|
|
$this->_title = 'Users';
|
|
$this->_base_url = '/user';
|
|
$this->_listtype = 'ajaxlist';
|
|
}
|
|
|
|
protected function get_list_fields(){
|
|
return [
|
|
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
|
|
'employee_code' => ['title' => 'Employee Code', 'type' => 'text'],
|
|
'firstname' => ['title' => 'Firstname', 'type' => 'text'],
|
|
'lastname' => ['title' => 'Lastname', 'type' => 'text'],
|
|
'email' => ['title' => 'Email', 'type' => 'text'],
|
|
'phone' => ['title' => 'Phone', 'type' => 'text'],
|
|
'designation' => ['title' => 'Designation', 'type' => 'text'],
|
|
'state' => ['title' => 'State', 'type' => 'text'],
|
|
'city' => ['title' => 'City', 'type' => 'text'],
|
|
'status' => ['title' => 'Status', 'type' => 'select'],
|
|
|
|
];
|
|
}
|
|
|
|
protected function get_list_buttons() {
|
|
return [ ['title' => 'Add New', 'link' => $this->_base_url.'/addnew' ], ['title' => 'Import Users', 'link' => $this->_base_url.'/import'] ];
|
|
}
|
|
|
|
protected function get_form_fields($type, $values){
|
|
$domain = LambdaRequest::signedrequest('get', $this->_service, 'domain/get_one');
|
|
$designations_dd = [];
|
|
foreach($domain->data->item->designations as $designation){
|
|
$designations_dd[$designation] = $designation;
|
|
}
|
|
$roles = $this->getlambda('get', 'ums', 'roles', 'dropdown');
|
|
$roles_dd = [];
|
|
foreach($roles->data->items as $role){
|
|
$roles_dd[$role->id] = $role->name;
|
|
}
|
|
$channels = $this->getlambda('get', 'ums', 'channel', 'dropdown');
|
|
$channels_dd = [];
|
|
foreach($channels->data->items as $channel){
|
|
$channels_dd[$channel->id] = $channel->name;
|
|
}
|
|
return [
|
|
'firstname' => ['title' => 'Firstname', 'type' => 'text', 'required' => true],
|
|
'lastname' => ['title' => 'Lastname', 'type' => 'text', 'required' => true],
|
|
'email' => ['title' => 'Email', 'type' => 'email', 'required' => true],
|
|
'phone' => ['title' => 'Phone', 'type' => 'text', 'required' => true],
|
|
'employee_code' => ['title' => 'Employee Code', 'type' => 'text', 'required' => true],
|
|
'designation' => ['title' => 'Designation', 'type' => 'select', 'values' => $designations_dd, 'required' => true],
|
|
'roles' => ['title' => 'Roles', 'type' => 'multiselect', 'required' => true, 'values' => $roles_dd ],
|
|
'channels' => ['title' => 'Channels', 'type' => 'multiselect', 'required' => true, 'values' => $channels_dd ],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
|
|
'state' => ['title' => 'State', 'type' => 'text', 'required' => true],
|
|
'city' => ['title' => 'City', 'type' => 'text', 'required' => true],
|
|
'pincode' => ['title' => 'Pincode', 'type' => 'text', 'required' => true],
|
|
'address' => ['title' => 'Address', 'type' => 'textarea'],
|
|
'avatar' => ['title' => 'Avatar', 'type' => 'image'],
|
|
];
|
|
}
|
|
|
|
protected function get_import_fields($records){
|
|
$domain = LambdaRequest::signedrequest('get', $this->_service, 'domain/get_one');
|
|
$designations_dd = [];
|
|
foreach($domain->data->item->designations as $designation){
|
|
$designations_dd[$designation] = $designation;
|
|
}
|
|
$roles = $this->getlambda('get', 'ums', 'roles', 'dropdown');
|
|
$roles_dd = [];
|
|
foreach($roles->data->items as $role){
|
|
$roles_dd[$role->id] = $role->name;
|
|
}
|
|
$channels = $this->getlambda('get', 'ums', 'channel', 'dropdown');
|
|
$channels_dd = [];
|
|
foreach($channels->data->items as $channel){
|
|
$channels_dd[$channel->id] = $channel->name;
|
|
}
|
|
return [
|
|
//'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
|
|
'employee_code' => ['title' => 'Employee Code', 'type' => 'text', 'required' => true],
|
|
'firstname' => ['title' => 'Firstname', 'type' => 'text', 'required' => true],
|
|
'lastname' => ['title' => 'Lastname', 'type' => 'text'],
|
|
'email' => ['title' => 'Email', 'type' => 'email', 'required' => true],
|
|
'phone' => ['title' => 'Phone', 'type' => 'text'],
|
|
'designation' => ['title' => 'Designation', 'type' => 'text', 'required' => true],
|
|
//'designation' => ['title' => 'Designation', 'type' => 'select', 'values' => $designations_dd, 'required' => true],
|
|
'role' => ['title' => 'Roles', 'type' => 'select', 'required' => true, 'values' => $roles_dd ],
|
|
'channel' => ['title' => 'Channels', 'type' => 'select', 'values' => $channels_dd ],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled'] ],
|
|
'state' => ['title' => 'State', 'type' => 'text'],
|
|
'city' => ['title' => 'City', 'type' => 'text'],
|
|
'pincode' => ['title' => 'Pincode', 'type' => 'text'],
|
|
'address' => ['title' => 'Address', 'type' => 'text'],
|
|
'hierarchy' => ['title' => 'Heirarchy', 'type' => 'text'],
|
|
];
|
|
}
|
|
|
|
public function list(Request $request) {
|
|
$fields = $this->get_list_fields();
|
|
return $this->view($this->_listtype)->with([
|
|
'title' => $this->_title,
|
|
'fields' => $fields,
|
|
'base_url' => $this->_base_url,
|
|
//'items' => $response->data->items,
|
|
'buttons' => $this->get_list_buttons()
|
|
]);
|
|
}
|
|
}
|