3131 <?php
3232 foreach ($ schedule as $ saveId => $ data )
3333 {
34+
3435 $ day_format = "<strong>%s</strong> %s - %s " ;
3536 ?>
3637 <tr>
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 ' ];?>
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>
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(){
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: {
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