Commit 39f3f1b9 by Phạm Văn Đoan

fixbug thiếu data để xử lý

parent bc1a2192
...@@ -11,6 +11,8 @@ include FCPATH . "/application/third_party/PHPExcel.php"; ...@@ -11,6 +11,8 @@ include FCPATH . "/application/third_party/PHPExcel.php";
class CmsRanking extends CI_Controller class CmsRanking extends CI_Controller
{ {
protected $overlap_ranking_list = 'backend/cmsSetting/overlapRanking';
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
...@@ -414,6 +416,9 @@ class CmsRanking extends CI_Controller ...@@ -414,6 +416,9 @@ class CmsRanking extends CI_Controller
*/ */
public function reportOverlappingAjax() public function reportOverlappingAjax()
{ {
$time = $this->input->post('time');
$scope = $this->input->post('scope');
//
$keep_ranking = $this->input->post('keep_ranking'); $keep_ranking = $this->input->post('keep_ranking');
$keep_track_id = $this->input->post('keep_track_id'); $keep_track_id = $this->input->post('keep_track_id');
$keep_track_title = $this->input->post('keep_track_title'); $keep_track_title = $this->input->post('keep_track_title');
...@@ -422,11 +427,38 @@ class CmsRanking extends CI_Controller ...@@ -422,11 +427,38 @@ class CmsRanking extends CI_Controller
$delete_track_id = $this->input->post('delete_track_id'); $delete_track_id = $this->input->post('delete_track_id');
$delete_track_title = $this->input->post('delete_track_title'); $delete_track_title = $this->input->post('delete_track_title');
// //
$scope = $this->input->post('scope'); if ($delete_track_id > 0 && in_array($scope, ['DAILY', 'WEEKLY', 'MONTHLY'])) {
// $date = null;
if ($delete_track_id > 0) { $week = null;
$month = null;
$year = null;
switch ($scope) {
case 'DAILY':
$time = str_replace('/', '-', trim($time));
$date = date('Y-m-d', strtotime($time));
break;
case 'WEEKLY':
$time = explode('-', $time);
if (count($time) == 2) {
$week = trim($time[0]);
$year = trim($time[1]);
}
break;
case 'MONTHLY':
$time = explode('-', $time);
if (count($time) == 2) {
$month = trim($time[0]);
$year = trim($time[1]);
}
break;
default:
}
$data_insert = [ $data_insert = [
'scope' => $scope, 'scope' => $scope,
'date' => $date,
'week' => $week,
'month' => $month,
'year' => $year,
'keep_ranking' => $keep_ranking, 'keep_ranking' => $keep_ranking,
'keep_track_id' => $keep_track_id, 'keep_track_id' => $keep_track_id,
'keep_track_title' => trim($keep_track_title), 'keep_track_title' => trim($keep_track_title),
...@@ -456,8 +488,8 @@ class CmsRanking extends CI_Controller ...@@ -456,8 +488,8 @@ class CmsRanking extends CI_Controller
} }
} else { } else {
echo json_encode([ echo json_encode([
'code' => 400, 'code' => 422,
'message' => 'Không thành công', 'message' => 'Không thành công, lỗi tham số truyền lên',
'data' => null 'data' => null
]); ]);
} }
...@@ -467,13 +499,17 @@ class CmsRanking extends CI_Controller ...@@ -467,13 +499,17 @@ class CmsRanking extends CI_Controller
* Hàm xử lý trùng BXH * Hàm xử lý trùng BXH
* @param $id * @param $id
*/ */
public function processOverlapRanking($id) public function processOverlapRanking($id, $scope)
{ {
if (in_array($scope, ['DAILY', 'WEEKLY', 'MONTHLY'])) {
$overlap = $this->report_violation_model->getById($id, 0); $overlap = $this->report_violation_model->getById($id, 0);
if (isset($overlap[0])) { if (isset($overlap[0])) {
print_r($overlap); print_r($overlap);
} else { } else {
redirect(base_url($this->overlap_ranking_list));
}
} else {
redirect(base_url($this->overlap_ranking_list));
} }
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<tr> <tr>
<th style="text-align: center">STT</th> <th style="text-align: center">STT</th>
<th style="text-align: center">Nguồn BXH</th> <th style="text-align: center">Nguồn BXH</th>
<th style="text-align: center">Thời gian</th>
<th style="text-align: center">Ranking - Bài hát đúng - ID</th> <th style="text-align: center">Ranking - Bài hát đúng - ID</th>
<th style="text-align: center">Ranking - Bài hát trùng / muốn gỡ bỏ - ID</th> <th style="text-align: center">Ranking - Bài hát trùng / muốn gỡ bỏ - ID</th>
<th style="text-align: center">Trạng thái</th> <th style="text-align: center">Trạng thái</th>
...@@ -15,6 +16,11 @@ ...@@ -15,6 +16,11 @@
<tr> <tr>
<td style="text-align: center"><?php echo ($key+1+$offset); ?></td> <td style="text-align: center"><?php echo ($key+1+$offset); ?></td>
<td style="text-align: center"><?php echo $data['scope']; ?></td> <td style="text-align: center"><?php echo $data['scope']; ?></td>
<td style="text-align: center">
<?php echo ($data['scope'] == 'DAILY' && !empty($data['date'])) ? date('d/m/Y', strtotime($data['date'])) : '' ; ?>
<?php echo ($data['scope'] == 'WEEKLY') ? $data['week'] . '/' . $data['year'] : '' ; ?>
<?php echo ($data['scope'] == 'MONTHLY') ? $data['month'] . '/' . $data['year'] : '' ; ?>
</td>
<td style="text-align: left"> <td style="text-align: left">
<?php echo $data['keep_track_title']; ?> <?php echo $data['keep_track_title']; ?>
</td> </td>
...@@ -26,7 +32,7 @@ ...@@ -26,7 +32,7 @@
</td> </td>
<td style="text-align: center"> <td style="text-align: center">
<?php if($data['status'] == 0): ?> <?php if($data['status'] == 0): ?>
<a href="<?php echo base_url('backend/cmsRanking/processOverlapRanking/'.$data['id']); ?>" title="Xử lý xóa trùng"> <a href="<?php echo base_url('backend/cmsRanking/processOverlapRanking/'.$data['id'].'/'.$data['scope']); ?>" title="Xử lý xóa trùng">
<i class="ace-icon fa fa-trash bigger-130 color-red"></i> <i class="ace-icon fa fa-trash bigger-130 color-red"></i>
</a> </a>
<?php endif; ?> <?php endif; ?>
......
...@@ -56,14 +56,14 @@ ...@@ -56,14 +56,14 @@
url: '<?php echo base_url("backend/cmsRanking/reportOverlappingAjax"); ?>', url: '<?php echo base_url("backend/cmsRanking/reportOverlappingAjax"); ?>',
data: { data: {
csrf_name: '<?php echo $this->security->get_csrf_hash(); ?>', csrf_name: '<?php echo $this->security->get_csrf_hash(); ?>',
fByName: ($("#input-date-picker").val()) ? $("#input-date-picker").val() : null, time: ($("#input-date-picker").val()) ? $("#input-date-picker").val() : null,
scope: '<?php echo (isset($tags) ? $tags : 'DAILY')?>',
keep_ranking: keep_ranking, keep_ranking: keep_ranking,
keep_track_id: keep_track_id, keep_track_id: keep_track_id,
keep_track_title: (keep_track_title) ? keep_track_title.trim() : keep_track_title, keep_track_title: (keep_track_title) ? keep_track_title.trim() : keep_track_title,
delete_ranking: delete_ranking, delete_ranking: delete_ranking,
delete_track_id: delete_track_id, delete_track_id: delete_track_id,
delete_track_title: (delete_track_title) ? delete_track_title.trim() : delete_track_title, delete_track_title: (delete_track_title) ? delete_track_title.trim() : delete_track_title,
scope: '<?php echo (isset($tags) ? $tags : 'DAILY')?>'
}, },
dataType: "JSON", dataType: "JSON",
cache: false, cache: false,
...@@ -73,7 +73,9 @@ ...@@ -73,7 +73,9 @@
// //
} else {} } else {}
}, },
error: function () {} error: function () {
$('#modal-overlapping-ranking').modal('hide');
}
}); });
} else { } else {
alert('Hai bài hát phải khác nhau!') alert('Hai bài hát phải khác nhau!')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment