init
This commit is contained in:
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\AdvertiserModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class AdvertiserController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $advertiser;
|
||||
public function __construct()
|
||||
{
|
||||
$this->advertiser = model(AdvertiserModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('/events/advertiser/advertiser');
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->advertiser->getAdvertisers($arg);
|
||||
$list = $result['data'];
|
||||
for ($i = 0; $i < count($list); $i++) {
|
||||
if($list[$i]['is_stop']){
|
||||
$list[$i]['is_stop'] = '사용중지';
|
||||
}else{
|
||||
$list[$i]['is_stop'] = '사용중';
|
||||
}
|
||||
|
||||
if($list[$i]['interlock_url']){
|
||||
$list[$i]['interlock_url'] = 'O';
|
||||
}
|
||||
|
||||
if($list[$i]['agreement_url']){
|
||||
$list[$i]['agreement_url_exist'] = 'O';
|
||||
}
|
||||
|
||||
$list[$i]['remain_balance'] = ($list[$i]['sum_price'] == ($list[$i]['remain_balance'] * -1)) ? "" : $list[$i]['remain_balance'];
|
||||
|
||||
if($list[$i]['sum_price']){
|
||||
$list[$i]['sum_price'] = number_format($list[$i]['sum_price']);
|
||||
}
|
||||
|
||||
if($list[$i]['remain_balance']){
|
||||
$list[$i]['remain_balance'] = number_format($list[$i]['remain_balance']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result = [
|
||||
'data' => $list,
|
||||
'recordsTotal' => $result['allCount'],
|
||||
'recordsFiltered' => $result['allCount'],
|
||||
'draw' => intval($arg['draw']),
|
||||
];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdvertiser()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$adv = $this->advertiser->getAdvertiser($arg);
|
||||
$ow = $this->advertiser->getOverwatchByAdvertiser($arg);
|
||||
$wl = $this->advertiser->getMedia($arg);
|
||||
|
||||
$result = [
|
||||
'advertiser' => $adv,
|
||||
'ow' => $ow,
|
||||
'wl' => $wl
|
||||
];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getCompanies()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$stx = $this->request->getGet('stx');
|
||||
$result = $this->advertiser->getCompanies($stx);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function createAdv()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = [
|
||||
'name' => $arg['name'],
|
||||
'agent' => $arg['agent'],
|
||||
'username' => auth()->user()->username,
|
||||
'homepage_url' => $arg['homepage_url'],
|
||||
'interlock_url' => $arg['interlock_url'],
|
||||
'agreement_url' => $arg['agreement_url'],
|
||||
'account_balance' => empty($arg['account_balance'])?0:$arg['account_balance'],
|
||||
'is_stop' => $arg['is_stop']
|
||||
];
|
||||
if(!empty($arg['company_id'])) {
|
||||
$data['company_seq'] = $arg['company_id'];
|
||||
}
|
||||
$data['ea_datetime'] = date('Y-m-d H:i:s');
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'name' => 'required|is_unique[event_advertiser.name]',
|
||||
// 'company_seq' => 'required|is_unique[event_advertiser.company_seq]',
|
||||
];
|
||||
$validationMessages = [
|
||||
/*
|
||||
'company_seq' => [
|
||||
'required' => '광고주 연결은 필수 입력 사항입니다.',
|
||||
'is_unique' => '이미 등록된 소속 광고주입니다.'
|
||||
],
|
||||
*/
|
||||
'name' => [
|
||||
'required' => '광고주명은 필수 입력 사항입니다.',
|
||||
'is_unique' => '이미 등록된 광고주입니다.'
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
/*
|
||||
$company = $this->advertiser->getCompanies($arg['name'])[0];
|
||||
if(empty($company['id']) || $company['id'] != $arg['company_id']) {
|
||||
$error = ['advertiser' => '소속 광고주와 입력한 광고주가 일치하지 않습니다.'];
|
||||
return $this->failValidationErrors($error);
|
||||
}
|
||||
|
||||
if(empty($arg['company_id'])){
|
||||
$advertiser = $this->advertiser->getAdvertiserByName($data);
|
||||
if(empty($advertiser)){
|
||||
$error = ['advertiser' => '광고주명에 해당하는 소속 광고주가 존재하지 않습니다.'];
|
||||
return $this->failValidationErrors($error);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$result = $this->advertiser->createAdv($data);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAdv()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'put'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
// 'name' => 'required',
|
||||
];
|
||||
|
||||
if($arg['sms_alert']){
|
||||
$validationRules['contact.0'] = 'required';
|
||||
}
|
||||
|
||||
$validationMessages = [
|
||||
'contact.0' => [
|
||||
'required' => '연락처는 필수 입력 사항입니다.'
|
||||
],
|
||||
];
|
||||
if(count($validationRules)) {
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($arg)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'agent' => $arg['agent'],
|
||||
'username' => auth()->user()->username,
|
||||
'homepage_url' => $arg['homepage_url'],
|
||||
'interlock_url' => $arg['interlock_url'],
|
||||
'agreement_url' => $arg['agreement_url'],
|
||||
'account_balance' => $arg['account_balance'],
|
||||
'is_stop' => $arg['is_stop'],
|
||||
];
|
||||
if(!empty($arg['company_id'])) {
|
||||
$data['company_seq'] = $arg['company_id'];
|
||||
}
|
||||
if(isset($arg['name'])) $data['name'] = $arg['name'];
|
||||
$data['ea_datetime'] = date('Y-m-d H:i:s');
|
||||
$result = $this->advertiser->updateAdv($data, $arg['seq']);
|
||||
|
||||
// OVERWATCH
|
||||
$db = \Config\Database::connect();
|
||||
$builder = $db->table('event_overwatch');
|
||||
$ow = $this->advertiser->getOverwatchByAdvertiser($arg['seq']);
|
||||
$contact = implode(';',$arg['contact']);
|
||||
// INSERT / UPDATE / DELETE
|
||||
if($arg['sms_alert'] && !$ow){
|
||||
$overwatch = [
|
||||
'advertiser' => $arg['seq'],
|
||||
'contact' => $contact,
|
||||
'watch_list' => $arg['watch_list'],
|
||||
'username' => auth()->user()->username
|
||||
];
|
||||
$overwatch['eo_datetime'] = date('Y-m-d H:i:s');
|
||||
$builder->insert($overwatch);
|
||||
}else if($arg['sms_alert'] && $ow){
|
||||
$builder->set('contact', $contact);
|
||||
$builder->set('watch_list', $arg['watch_list']);
|
||||
$builder->set('watch_all', $arg['watch_all']);
|
||||
$builder->where('seq', $ow['seq']);
|
||||
$builder->update();
|
||||
}else if(!$arg['sms_alert'] && $ow){
|
||||
$builder->where('seq', $ow['seq']);
|
||||
$builder->delete();
|
||||
}
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function evtOverwatch(){
|
||||
$result = $this->advertiser->evtOverwatch();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\BlackListModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use DateTime;
|
||||
|
||||
class BlackListController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $blacklist;
|
||||
public function __construct()
|
||||
{
|
||||
$this->blacklist = model(BlackListModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('/events/blacklist/blacklist');
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->blacklist->getBlackLists($arg);
|
||||
$list = $result['data'];
|
||||
|
||||
$result = [
|
||||
'data' => $list,
|
||||
'recordsTotal' => $result['allCount'],
|
||||
'recordsFiltered' => $result['allCount'],
|
||||
'draw' => intval($arg['draw']),
|
||||
];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlackList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$data = $this->request->getGet();
|
||||
$result = $this->blacklist->getBlacklist($data['seq']);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function createBlackList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$arg = $this->request->getRawInput();
|
||||
|
||||
//유효성 검사 start
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'data' => 'required|is_unique[event_blacklist.data]',
|
||||
];
|
||||
$validationMessages = [
|
||||
'data' => [
|
||||
'required' => '전화번호/아이피를 입력해주세요.',
|
||||
'is_unique' => '이미 존재하는 전화번호/아이피입니다.'
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($arg)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
//유효성 검사 end
|
||||
|
||||
$data = [
|
||||
'data' => preg_replace("/[^0-9.]/", "", $arg['data']),
|
||||
'memo' => $arg['memo'],
|
||||
];
|
||||
|
||||
$result = $this->blacklist->createBlackList($data);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteBlackList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'delete'){
|
||||
$data = $this->request->getRawInput();
|
||||
$result = $this->blacklist->deleteBlackList($data['seq']);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\ChangeModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class ChangeController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $change;
|
||||
public function __construct()
|
||||
{
|
||||
$this->change = model(ChangeModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('/events/change/change');
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->change->getChanges($arg);
|
||||
$list = $result['data'];
|
||||
|
||||
$result = [
|
||||
'data' => $list,
|
||||
'recordsTotal' => $result['allCount'],
|
||||
'recordsFiltered' => $result['allCount'],
|
||||
'draw' => intval($arg['draw']),
|
||||
];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getChange()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->change->getChange($arg['id']);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function createChange()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = [
|
||||
'id' => $arg['id'],
|
||||
'name' => $arg['name'],
|
||||
'token' => $arg['token'],
|
||||
];
|
||||
$data['ec_datetime'] = date('Y-m-d H:i:s');
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'id' => 'required|is_unique[event_conversion.id]',
|
||||
'token' => 'required'
|
||||
];
|
||||
$validationMessages = [
|
||||
'id' => [
|
||||
'required' => '전환ID는 필수 입력 사항입니다.',
|
||||
'is_unique' => '이미 등록된 아이디입니다.'
|
||||
],
|
||||
'token' => [
|
||||
'required' => 'Access Token은 필수 입력 사항입니다.',
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$result = $this->change->createChange($data);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function updateChange()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'put'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = [
|
||||
'old_id' => $arg['old_id'],
|
||||
'id' => $arg['id'],
|
||||
'name' => $arg['name'],
|
||||
'token' => $arg['token'],
|
||||
];
|
||||
$data['ec_datetime'] = date('Y-m-d H:i:s');
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'id' => 'required',
|
||||
'token' => 'required'
|
||||
];
|
||||
if($data['old_id'] != $data['id']){
|
||||
$validationRules['id'] = 'required|is_unique[event_conversion.id]';
|
||||
}
|
||||
$validationMessages = [
|
||||
'id' => [
|
||||
'required' => '전환ID는 필수 입력 사항입니다.',
|
||||
'is_unique' => '이미 등록된 아이디입니다.'
|
||||
],
|
||||
'token' => [
|
||||
'required' => 'Access Token은 필수 입력 사항입니다.',
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$result = $this->change->updateChange($data);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\AdvertiserModel;
|
||||
use App\Models\EventManage\EventModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class EventController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $event, $advertiser;
|
||||
public function __construct()
|
||||
{
|
||||
$this->event = model(EventModel::class);
|
||||
$this->advertiser = model(AdvertiserModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('events/event/event');
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->event->getInformation($arg);
|
||||
$ads = $this->event->getEnabledAds();
|
||||
if(empty($ads)){$ads = [];}
|
||||
foreach ($result['data'] as &$data) {
|
||||
if($data['is_stop']){
|
||||
$data['is_stop'] = 'X';
|
||||
}else{
|
||||
$data['is_stop'] = 'O';
|
||||
}
|
||||
|
||||
if($data['interlock']){
|
||||
$data['interlock'] = 'O';
|
||||
}else{
|
||||
$data['interlock'] = '';
|
||||
}
|
||||
|
||||
if($data['lead']){
|
||||
$lead_array = array("0" => $data['title'], "1" => "잠재고객", "2" => "엑셀업로드", "3" => "API 수신", "4" => "카카오 비즈폼");
|
||||
$data['title'] = $lead_array[$data['lead']];
|
||||
if($data['lead'] == 3)
|
||||
$data['title'] .= "<p class='desc'>[{$data['partner_event_seq']}]</p>";
|
||||
}
|
||||
|
||||
if(preg_match('/(카카오|GDN|페이스북|잠재|유튜브)/', $data['media_name'])) {
|
||||
$is_enabledAds = false;
|
||||
$data['config'] = 'disabled';
|
||||
if(in_array($data['seq'], $ads)){
|
||||
$is_enabledAds = true;
|
||||
}
|
||||
if($is_enabledAds) {
|
||||
$data['config'] = 'enabled';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$data['impressions']){
|
||||
$data['impressions'] = 0;
|
||||
}
|
||||
|
||||
$data['hash_no'] = $this->makeHash($data['seq']);
|
||||
$url = env('app.eventURL');
|
||||
if($data['another_url'])
|
||||
$url = env('app.newEventURL');
|
||||
$data['event_url'] = $url.$data['hash_no'];
|
||||
$data['db_price'] = number_format($data['db_price']);
|
||||
}
|
||||
|
||||
$result = [
|
||||
'data' => $result['data'],
|
||||
'recordsTotal' => $result['allCount'],
|
||||
'recordsFiltered' => $result['allCount'],
|
||||
'draw' => intval($arg['draw']),
|
||||
];
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getAdv()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->event->getAdv($arg['stx']);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getMedia()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->event->getMedia($arg['stx']);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function createEvent()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = $this->setArg($arg);
|
||||
|
||||
$data['advertiser'] = $arg['advertiser'];
|
||||
$data['keyword'] = $arg['keyword'];
|
||||
$data['ei_datetime'] = date('Y-m-d H:i:s');
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'advertiser' => 'required',
|
||||
'media' => 'required',
|
||||
];
|
||||
$validationMessages = [
|
||||
'advertiser' => [
|
||||
'required' => '광고주가 입력되지 않았습니다.',
|
||||
],
|
||||
'media' => [
|
||||
'required' => '매체가 입력되지 않았습니다.',
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$adData = [
|
||||
'seq' => $arg['advertiser']
|
||||
];
|
||||
$advertiser = $this->advertiser->getAdvertiser($adData);
|
||||
if(empty($advertiser['company_seq']) || $advertiser['company_seq'] == 0){
|
||||
$error = ['advertiser' => '소속이 지정되지 않은 광고주입니다.'];
|
||||
return $this->failValidationErrors($error);
|
||||
}
|
||||
|
||||
$result = $this->event->createEvent($data);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function updateEvent()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'put'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = $this->setArg($arg);
|
||||
$data['keyword'] = $arg['keyword'];
|
||||
$data['ei_updatetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'media' => 'required',
|
||||
];
|
||||
$validationMessages = [
|
||||
'media' => [
|
||||
'required' => '매체가 입력되지 않았습니다.',
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$result = $this->event->updateEvent($data, $arg['seq']);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function copyEvent()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$data = $this->request->getRawInput();
|
||||
if(empty($data['seq'])){
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
$result = $this->event->copyEvent($data['seq']);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEvent()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'delete'){
|
||||
$data = $this->request->getRawInput();
|
||||
if(empty($data['seq'])){
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
$url = "https://event.hotblood.co.kr/filecheck/".$data['seq'];
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if (!$response) {
|
||||
$result = $this->event->deleteEvent($data['seq']);
|
||||
return $this->respond($result);
|
||||
} else {
|
||||
$result = $this->event->deleteEvent($data['seq']);
|
||||
return $this->respond($result);
|
||||
return $this->fail("삭제할 수 없는 이벤트입니다.");
|
||||
}
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getEvent()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$seq = $this->request->getGet('seq');
|
||||
$result = $this->event->getEvent($seq);
|
||||
$result['keywords'] = explode(',', $result['keywords']);
|
||||
$result['hash_no'] = $this->makeHash($result['seq']);
|
||||
$url = env('app.eventURL');
|
||||
if($result['another_url'])
|
||||
$url = env('app.newEventURL');
|
||||
$result['event_url'] = $url.$result['hash_no'];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getEventImpressions()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$seq = $this->request->getGet('seq');
|
||||
$result = $this->event->getEventImpressions($seq);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
private function setArg($arg){
|
||||
$data = [
|
||||
'media' => $arg['media'],
|
||||
'description' => $arg['description'],
|
||||
'db_price' => (integer)$arg['db_price'] ?? 0,
|
||||
'interlock' => (integer)$arg['interlock'] ?? 0,
|
||||
'partner_id' => $arg['partner_id'],
|
||||
'partner_name' => $arg['partner_name'],
|
||||
'paper_code' => $arg['paper_code'],
|
||||
'paper_name' => $arg['paper_name'],
|
||||
'lead' => (integer)$arg['lead'],
|
||||
'creative_id' => (integer)$arg['creative_id'] ?? 0,
|
||||
'bizform_apikey' => $arg['bizform_apikey'],
|
||||
'is_stop' => (integer)$arg['is_stop'] ?? 0,
|
||||
'custom' => $arg['custom'],
|
||||
'title' => $arg['title'],
|
||||
'subtitle' => $arg['subtitle'],
|
||||
'object' => $arg['object'],
|
||||
'object_items' => $arg['object_items'],
|
||||
'pixel_id' => trim($arg['pixel_id']),
|
||||
'view_script' => $arg['view_script'],
|
||||
'done_script' => $arg['done_script'],
|
||||
'check_gender' => $arg['check_gender'],
|
||||
'check_age_min' => (integer)$arg['check_age_min'] ?? 0,
|
||||
'check_age_max' => (integer)$arg['check_age_max'] ?? 0,
|
||||
'duplicate_term' => (integer)$arg['duplicate_term'] ?? 0,
|
||||
'check_phone' => $arg['check_phone'],
|
||||
'check_name' => $arg['check_name'],
|
||||
'duplicate_precheck' => (integer)$arg['duplicate_precheck'] ?? 0,
|
||||
'no_hash' => isset($arg['no_hash']) ? (integer)$arg['no_hash'] : 0,
|
||||
'another_url' => isset($arg['another_url']) ? (integer)$arg['another_url'] : 0,
|
||||
'username' => auth()->user()->nickname ?? '',
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function makeHash($uid) {
|
||||
$ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
$s_id = str_split($uid);
|
||||
$make_hash = [0,0];
|
||||
for($i=0; $i<count($s_id); $i++) $make_hash[0] += $s_id[$i]*($i+$s_id[count($s_id)-1]);
|
||||
for($i=0; $i<count($s_id); $i++) $make_hash[1] += $s_id[$i]*($i+$s_id[0]);
|
||||
$make_hash = array_map(function($v) use($ab){$chksum = ($v % 26); return $ab[$chksum];}, $make_hash);
|
||||
$hash = implode("", $make_hash);
|
||||
$result = $hash.$uid;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\ExcelModel;
|
||||
use Config\Services;
|
||||
|
||||
class ExcelController extends BaseController
|
||||
{
|
||||
protected $excel;
|
||||
public function __construct()
|
||||
{
|
||||
$this->excel = model(ExcelModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('events/excelUpload/excel', [
|
||||
'validation' => Services::validation(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
if(strtolower($this->request->getMethod()) === 'post'){
|
||||
$validated = $this->validate([
|
||||
'upload_file' => [
|
||||
'uploaded[upload_file]',
|
||||
'ext_in[upload_file,csv]',
|
||||
'max_size[upload_file, 4096]',
|
||||
],
|
||||
],
|
||||
[
|
||||
'upload_file' => [
|
||||
'uploaded' => '업로드 오류가 발생하였습니다.',
|
||||
'ext_in' => 'csv 파일만 업로드 가능합니다.',
|
||||
'max_size' => '파일 크기는 4MB를 초과할 수 없습니다.'
|
||||
]
|
||||
|
||||
]);
|
||||
|
||||
if (!$validated) {
|
||||
return view('events/excelUpload/excel', [
|
||||
'validation' => $this->validator
|
||||
]);
|
||||
}
|
||||
|
||||
$file = $this->request->getFile('upload_file');
|
||||
$filePath = $file->getPathname();
|
||||
$row = 1; //줄수 초기화
|
||||
$idx = 0; //배열 인덱스
|
||||
$fp = fopen($filePath, "r");
|
||||
while (($data = fgetcsv($fp, 1000, ",")) !== false) { //csv파일열기
|
||||
if ($row == 1) {
|
||||
$row += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
$excel[$idx]['reg_date'] = iconv("EUC-KR", "UTF-8", $data[1]);
|
||||
$excel[$idx]['name'] = preg_replace("/[#\&\+%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>\[\]\{\}]/i", "", iconv("EUC-KR", "UTF-8", $data[2]));
|
||||
$excel[$idx]['phone'] = strtr(iconv("EUC-KR", "UTF-8", $data[3]), array("+82 " => "0", "-" => "")); // 전화번호에서 국제번호 및 하이픈 제거
|
||||
$excel[$idx]['add1'] = iconv("EUC-KR", "UTF-8", $data[4]); //나이 또는 생년월일
|
||||
$excel[$idx]['add2'] = iconv("EUC-KR", "UTF-8", $data[5]);
|
||||
$excel[$idx]['add3'] = iconv("EUC-KR", "UTF-8", $data[6]);
|
||||
$excel[$idx]['add4'] = iconv("EUC-KR", "UTF-8", $data[7]);
|
||||
$excel[$idx]['add5'] = iconv("EUC-KR", "UTF-8", $data[8]);
|
||||
$excel[$idx]['branch'] = iconv("EUC-KR", "UTF-8", $data[9]);
|
||||
$excel[$idx]['age'] = iconv("EUC-KR", "UTF-8", $data[10]);
|
||||
$excel[$idx]['partner_name'] = iconv("EUC-KR", "UTF-8", $data[11]); //파트너명
|
||||
$excel[$idx]['partner_id'] = iconv("EUC-KR", "UTF-8", $data[12]); //파트너아이디
|
||||
$excel[$idx]['hospital_name'] = iconv("EUC-KR", "UTF-8", $data[13]); //코드명
|
||||
$excel[$idx]['counsel_memo'] = iconv("EUC-KR", "UTF-8", $data[14]); //지면명
|
||||
$excel[$idx]['paper_code'] = iconv("EUC-KR", "UTF-8", $data[13]); //코드명
|
||||
$excel[$idx]['paper_name'] = iconv("EUC-KR", "UTF-8", $data[14]); //지면명
|
||||
$excel[$idx]['event_seq'] = iconv("EUC-KR", "UTF-8", $data[15]); //랜딩번호
|
||||
$excel[$idx]['site'] = iconv("EUC-KR", "UTF-8", $data[16]); //사이트
|
||||
|
||||
if ($excel[$idx]['name'] && $excel[$idx]['phone']) {
|
||||
$status_check = $this->excel->status_check($excel[$idx]['name'], $excel[$idx]['phone'], $excel[$idx]['event_seq']);
|
||||
$excel[$idx]['status'] = $status_check['status'];
|
||||
$excel[$idx]['status_memo'] = $status_check['status_memo'];
|
||||
}
|
||||
|
||||
$idx++;
|
||||
}
|
||||
session()->setFlashdata('success', 'Success! image uploaded.');
|
||||
return redirect()->to(site_url('/events/exelUpload/exel'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\EventManage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EventManage\MediaModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
class MediaController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
protected $media;
|
||||
public function __construct()
|
||||
{
|
||||
$this->media = model(MediaModel::class);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view('/events/media/media');
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->media->getMedias($arg);
|
||||
$list = $result['data'];
|
||||
|
||||
$result = [
|
||||
'data' => $list,
|
||||
'recordsTotal' => $result['allCount'],
|
||||
'recordsFiltered' => $result['allCount'],
|
||||
'draw' => intval($arg['draw']),
|
||||
];
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function getMedia()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'get'){
|
||||
$arg = $this->request->getGet();
|
||||
$result = $this->media->getMedia($arg);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function createMedia()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'post'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = [
|
||||
'media' => $arg['media'],
|
||||
'target' => $arg['target'],
|
||||
];
|
||||
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'media' => 'required|is_unique[event_media.media]',
|
||||
];
|
||||
$validationMessages = [
|
||||
'media' => [
|
||||
'required' => '매체명은 필수 입력 사항입니다.',
|
||||
'is_unique' => '이미 등록된 매체입니다.'
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$result = $this->media->createMedia($data);
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMedia()
|
||||
{
|
||||
if($this->request->isAJAX() && strtolower($this->request->getMethod()) === 'put'){
|
||||
$arg = $this->request->getRawInput();
|
||||
$data = [
|
||||
'media' => $arg['media'],
|
||||
'target' => $arg['target'],
|
||||
];
|
||||
|
||||
$validation = \Config\Services::validation();
|
||||
$validationRules = [
|
||||
'media' => 'required',
|
||||
];
|
||||
$validationMessages = [
|
||||
'media' => [
|
||||
'required' => '매체명은 필수 입력 사항입니다.',
|
||||
],
|
||||
];
|
||||
$validation->setRules($validationRules, $validationMessages);
|
||||
if (!$validation->run($data)) {
|
||||
$errors = $validation->getErrors();
|
||||
return $this->failValidationErrors($errors);
|
||||
}
|
||||
|
||||
$result = $this->media->updateMedia($data, $arg['seq']);
|
||||
|
||||
return $this->respond($result);
|
||||
}else{
|
||||
return $this->fail("잘못된 요청");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user