Skip to content

Commit 24b035b

Browse files
committed
Merge pull request #153 from SOEN341-W16/dimitri-dropcourse
#152 initial draft for dropping class from a saved schedule
2 parents 16f6fce + 67bc9bb commit 24b035b

File tree

3 files changed

+97
-3
lines changed

3 files changed

+97
-3
lines changed

protected/controllers/SchedulerController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,27 @@ public function actionDeleteSchedule()
300300

301301
}
302302

303+
public function actionDropCourse()
304+
{
305+
$scheduleID = $_POST['scheduleID'];
306+
$sectionID = $_POST['sectionID'];
307+
try
308+
{
309+
$UserSchedule = new UserSchedule();
310+
$UserSchedule->deleteAllByAttributes(array(
311+
'scheduleID' => $scheduleID,
312+
'sectionID' => $sectionID
313+
));
314+
}
315+
catch(Exception $e)
316+
{
317+
318+
throw $e;
319+
echo 0;
320+
}
321+
echo 1;
322+
}
323+
303324
/**
304325
* @throws Exception
305326
*/

protected/runtime/application.log

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11945,3 +11945,19 @@ Stack trace:
1194511945
REQUEST_URI=/index.php?r=course/index
1194611946
HTTP_REFERER=http://www.conuscheduler.localhost/index.php?r=course/view&id=3
1194711947
---
11948+
2016/04/03 00:47:45 [error] [php] Undefined index: courseID (C:\xampp\htdocs\ConUScheduler\protected\controllers\SchedulerController.php:306)
11949+
Stack trace:
11950+
#0 C:\xampp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(133): SchedulerController->runAction()
11951+
#1 C:\xampp\htdocs\ConUScheduler\framework\web\filters\CFilter.php(40): CFilterChain->run()
11952+
#2 C:\xampp\htdocs\ConUScheduler\framework\web\CController.php(1145): CAccessControlFilter->filter()
11953+
#3 C:\xampp\htdocs\ConUScheduler\framework\web\filters\CInlineFilter.php(58): SchedulerController->filterAccessControl()
11954+
#4 C:\xampp\htdocs\ConUScheduler\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter()
11955+
#5 C:\xampp\htdocs\ConUScheduler\framework\web\CController.php(291): CFilterChain->run()
11956+
#6 C:\xampp\htdocs\ConUScheduler\framework\web\CController.php(265): SchedulerController->runActionWithFilters()
11957+
#7 C:\xampp\htdocs\ConUScheduler\framework\web\CWebApplication.php(282): SchedulerController->run()
11958+
#8 C:\xampp\htdocs\ConUScheduler\framework\web\CWebApplication.php(141): CWebApplication->runController()
11959+
#9 C:\xampp\htdocs\ConUScheduler\framework\base\CApplication.php(185): CWebApplication->processRequest()
11960+
#10 C:\xampp\htdocs\ConUScheduler\index.php(13): CWebApplication->run()
11961+
REQUEST_URI=/index.php?r=scheduler/DropCourse
11962+
in C:\xampp\htdocs\ConUScheduler\protected\controllers\SchedulerController.php (306)
11963+
in C:\xampp\htdocs\ConUScheduler\index.php (13)

protected/views/scheduler/saved.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<?php
3232
foreach($schedule as $saveId => $data)
3333
{
34+
3435
$day_format = "<strong>%s</strong> %s - %s";
3536
?>
3637
<tr>
@@ -66,7 +67,7 @@
6667
foreach ($semesterData as $courseID => $courseData)
6768
{
6869
?>
69-
<tr>
70+
<tr id="course_<?php echo $courseData['lecture_id'];?>">
7071

7172
<td>
7273
<?php echo $courseData['course_code']. ' - ' . $courseData['course_description'];?>
@@ -83,14 +84,17 @@
8384
<td>
8485
<?php echo $courseData['credits'];?>
8586
</td>
87+
<td>
88+
<a href="javascript:void(0);" id="dropCourse" data-sectionid="<?php echo $courseData['lecture_id'];?>" data-scheduleid="<?php echo $saveId;?>">Drop</a>
89+
</td>
8690
</tr>
8791

8892
<?php
8993

9094
foreach($courseData['labs'] as $labID => $lab)
9195
{ ?>
9296

93-
<tr>
97+
<tr id="course_<?php echo $courseData['lecture_id'];?>">
9498
<td>
9599
</td>
96100
<td>
@@ -127,6 +131,10 @@
127131
<div id="delete-dialog" title="Delete Schedule" style="display: none;">
128132
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><div id="delete-dialog-notice"></div></p>
129133
</div>
134+
135+
<div id="drop-dialog" title="Drop Course" style="display: none;">
136+
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><div id="drop-dialog-notice"></div></p>
137+
</div>
130138
<script>
131139
$(function(){
132140
$('a#view').on('click',function(){
@@ -152,7 +160,7 @@
152160
$('#delete-dialog-notice').html('Are you sure you want to delete this schedule?');
153161
$('#delete-dialog').dialog({
154162
resizable: false,
155-
height: 200,
163+
height: 120,
156164
width: 400,
157165
modal: true,
158166
buttons: {
@@ -193,5 +201,54 @@
193201
}
194202
});
195203
});
204+
205+
// DROP COURSE
206+
$('a#dropCourse').on('click', function(){
207+
var sectionID = $(this).data('sectionid');
208+
var scheduleID = $(this).data('scheduleid');
209+
var $courseTable = $('tr#course_' + sectionID);
210+
211+
$('#drop-dialog-notice').html('Are you sure you want to drop this course?');
212+
213+
$('#drop-dialog').dialog({
214+
resizable: false,
215+
height: 200,
216+
width: 400,
217+
modal: true,
218+
buttons: {
219+
"Delete": function () {
220+
$('#drop-dialog-notice').html('Deleting...');
221+
$.ajax({
222+
url: "<?php echo Yii::app()->createAbsoluteUrl("scheduler/DropCourse"); ?>",
223+
type: "POST",
224+
cache: false,
225+
data: 'sectionID=' + sectionID + '&scheduleID=' + scheduleID,
226+
success: function (data) {
227+
if (data) {
228+
$('#drop-dialog').dialog('close');
229+
$courseTable.remove();
230+
}
231+
else {
232+
$('#drop-dialog-notice').html(data);
233+
}
234+
235+
},
236+
error: function () {
237+
$("#delete-dialog-notice").html("There was an error saving your schedule...");
238+
}
239+
});
240+
},
241+
Cancel: function () {
242+
$(this).dialog("close");
243+
},
244+
},
245+
close : function()
246+
{
247+
$('#drop-dialog-notice').html("");
248+
}
249+
250+
});
251+
252+
});
196253
});
197254
</script>

0 commit comments

Comments
 (0)