113 lines
5.1 KiB
PHP
113 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\LambdaRequest;
|
|
use DB;
|
|
|
|
class BannerController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware('auth');
|
|
$this->_service = 'wall';
|
|
$this->_module = 'wallbanner';
|
|
$this->_viewname = 'banner';
|
|
$this->_title = 'Banner';
|
|
$this->_base_url = '/banner';
|
|
}
|
|
|
|
protected function get_list_fields(){
|
|
return [
|
|
'actions' => ['title' => 'Actions', 'buttons' => [ 'edit', 'delete' ] ],
|
|
'media_url' => ['title' => 'Media', 'type' => 'image'],
|
|
'title' => ['title' => 'Title', 'type' => 'text'],
|
|
'status' => ['title' => 'Status', 'type' => 'select'],
|
|
|
|
];
|
|
}
|
|
|
|
protected function get_form_fields($type, $values){
|
|
$channels = $this->getlambda('get', 'ums', 'channel', 'dropdown');
|
|
$channels_dd = [];
|
|
foreach($channels->data->items as $channel){
|
|
$channels_dd[$channel->id] = $channel->name;
|
|
}
|
|
$groups = $this->getlambda('get', 'ums', 'group', 'dropdown');
|
|
$groups_dd = [];
|
|
foreach($groups->data->items as $group){
|
|
$groups_dd[$group->id] = $group->name;
|
|
}
|
|
$roles = $this->getlambda('get', 'ums', 'roles', 'dropdown');
|
|
$roles_dd = [];
|
|
foreach($roles->data->items as $role){
|
|
$roles_dd[$role->id] = $role->name;
|
|
}
|
|
$forms = $this->getlambda('get', 'form', 'formentity', 'dropdown');
|
|
$forms_dd = [];
|
|
foreach($forms->data->items as $form){
|
|
$forms_dd[$form->id] = $form->title;
|
|
}
|
|
|
|
// $forms = $this->getlambda('get', 'form', 'survey', 'dropdown');
|
|
// foreach($forms->data->items as $form){
|
|
// $forms_dd[$form->id] = $form->title . ' (Survey)';
|
|
// }
|
|
|
|
// $quizs = $this->getlambda('get', 'form', 'quiz', 'dropdown');
|
|
// foreach($quizs->data->items as $form){
|
|
// $forms_dd[$form->id] = $form->name . ' (Quiz)';
|
|
// }
|
|
|
|
return [
|
|
'title' => ['title' => 'Title', 'type' => 'text', 'required' => true],
|
|
'channels' => ['title' => 'Channels', 'type' => 'multiselect', 'required' => true, 'values' => $channels_dd ],
|
|
'groups' => ['title' => 'Groups', 'type' => 'multiselect', 'required' => true, 'values' => $groups_dd ],
|
|
'roles' => ['title' => 'Roles', 'type' => 'multiselect', 'required' => true, 'values' => $roles_dd ],
|
|
|
|
'scheduled' => ['title' => 'Scheduled', 'type' => 'yesno', 'required' => true],
|
|
'position' => ['title' => 'Position', 'type' => 'select', 'required' => true, 'values' => ['default' => 'Default', 'below_stats' => 'Below Stats', 'below_stats_buttons' => 'Below Stats Buttons', 'popup' => 'Pop Up']],
|
|
|
|
'schedule_start_date' => ['title' => 'Schedule start date', 'type' => 'date'],
|
|
'schedule_end_date' => ['title' => 'Schedule end date', 'type' => 'date'],
|
|
'media_url' => ['title' => 'Banner Image', 'type' => 'image', 'required' => true],
|
|
'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled']],
|
|
|
|
'has_cta' => ['title' => 'Has CTA', 'type' => 'yesno', 'required' => true, 'fullwidth' => true],
|
|
'target_type' => ['title' => 'Target Type', 'type' => 'select', 'values' => ['internal_action' => 'Internal Action', 'form' => 'Web Form', 'doctorlist' => 'Doctor List', 'external' => 'External Webpage', 'external_with_token' => 'External Webpage with Token'] ],
|
|
'form_id' => ['title' => 'Form', 'type' => 'select', 'values' => $forms_dd ],
|
|
'external_url' => ['title' => 'External Url / Internal Action', 'type' => 'text'],
|
|
|
|
];
|
|
}
|
|
|
|
protected function _beforesave($type, $request) {
|
|
$data = $request->except('_token');
|
|
// if($type == 'edit') {
|
|
// $values->channels = explode('#', $values->channels);
|
|
// }
|
|
if( $request->file('media_url') ) {
|
|
$data['media_url'] = $this->_uploadMedia($request, 'media_url', 'banners');
|
|
}
|
|
$data['groups'] = implode('#', $data['groups']);
|
|
$data['roles'] = implode('#', $data['roles']);
|
|
$data['form_id'] = isset($data['form_id']) ? $data['form_id'] : 'none';
|
|
$data['target_type'] = isset($data['target_type']) ? $data['target_type'] : '.';
|
|
$data['form_id'] = isset($data['form_id']) ? $data['form_id'] : '.';
|
|
$data['external_url'] = isset($data['external_url']) ? $data['external_url'] : '.';
|
|
//echo '<pre>'; print_r($data); exit;
|
|
return $data;
|
|
}
|
|
|
|
protected function _beforeform($type, $values) {
|
|
if($type == 'edit') {
|
|
$values->channels = explode('#', $values->channels);
|
|
$values->groups = !isset($values->groups) ? '' : $values->groups;
|
|
$values->roles = !isset($values->roles) ? '' : $values->roles;
|
|
$values->groups = explode('#', $values->groups);
|
|
$values->roles = explode('#', $values->roles);
|
|
}
|
|
return $values;
|
|
}
|
|
}
|