|
|
@@ -156,11 +156,12 @@ class ActivityController extends Controller
|
|
|
$spreadsheet = $reader->load($inputFileName);
|
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
|
$highestRow = $worksheet->getHighestDataRow();
|
|
|
-
|
|
|
+ date_default_timezone_set('Asia/Taipei');
|
|
|
if ($option == 'prize') {
|
|
|
if ($worksheet->getCell([1, 1])->getValue() == '獎品') {
|
|
|
- DB::table('prizes')->where('activity_id', '=', $activity_id)->delete();
|
|
|
- date_default_timezone_set('Asia/Taipei');
|
|
|
+ if(DB::table('prizes')->where('activity_id', '=', $activity_id)->exists()){
|
|
|
+ DB::table('prizes')->where('activity_id', '=', $activity_id)->delete();
|
|
|
+ }
|
|
|
for ($row = 2; $row <= $highestRow; $row++) {
|
|
|
DB::table('prizes')->insert([
|
|
|
'activity_id' => $activity_id,
|
|
|
@@ -177,8 +178,9 @@ class ActivityController extends Controller
|
|
|
}
|
|
|
} else if ($option == 'guest') {
|
|
|
if ($worksheet->getCell([1, 1])->getValue() == '來賓編號') {
|
|
|
- DB::table('check_ins')->where('activity_id', '=', $activity_id)->where('region', '=', '來賓')->delete();
|
|
|
- date_default_timezone_set('Asia/Taipei');
|
|
|
+ if(DB::table('check_ins')->where('activity_id', '=', $activity_id)->where('region', '=', '來賓')->exists()){
|
|
|
+ DB::table('check_ins')->where('activity_id', '=', $activity_id)->where('region', '=', '來賓')->delete();
|
|
|
+ }
|
|
|
for ($row = 2; $row <= $highestRow; $row++) {
|
|
|
DB::table('check_ins')->insert([
|
|
|
'user_id' => $worksheet->getCell([1, $row])->getValue(),
|
|
|
@@ -186,6 +188,7 @@ class ActivityController extends Controller
|
|
|
'department_id' => 'guest',
|
|
|
'region' => '來賓',
|
|
|
'is_checked_in' => false,
|
|
|
+ 'is_awarded' => false,
|
|
|
'activity_id' => $activity_id,
|
|
|
'created_at' => now(),
|
|
|
'updated_at' => now(),
|