SHARE
TWEET

Untitled

a guest Jun 19th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {{extend 'layout_iFrame.html'}}
  2.  
  3. <!-- show PCA Schedule -->
  4. <h2>Member's PCA Schedule ({{=memberName}})</h2>
  5. <p>
  6. Total Scheduled Hours: <strong>{{=totalScheduledHours}}</strong>
  7. </p>
  8. <table>
  9.     <!-- header row -->
  10.     <thead>
  11.     <tr style="border: 3px solid blue;">
  12.         {{for weekDayRec in db(db.WeekDays.id>0).select():}}
  13.             <td style = "border: 3px solid blue;"><strong>{{=weekDayRec.Val}}</Strong></td>
  14.         {{pass}}
  15.     </tr>
  16.     <tr>
  17.         {{for tot in minTotals:}}
  18.             <td style = "border: 3px solid blue;">Hrs: {{=tot}}</td>
  19.         {{pass}}
  20.     </tr>
  21.     </thead>
  22.     <tbody>
  23.     <tr>
  24.         {{for col in range(0, 7):}}
  25.             <td style = "border: 1px solid green;" id = "timeblock_add_id_{{=str(col+1)}}">
  26.                 <div id = "timeblock_add_div_id_{{=str(col+1)}}">
  27.                 <p style = "text-align: center">{{=A(IMG(_src=URL(r=request,c='static',f='addnew.gif'),_alt="Add New Schedule Block"),_href="javascript:BeginTBAdd(%s)" % str(col+1))}}</p>
  28.                 </div>
  29.             </td>
  30.         {{pass}}
  31.     </tr>
  32. {{for row in range(0, maxBlocks):}}
  33.     <tr>
  34.         {{for col in range(0, 7):}}
  35.             {{if blockTable[col][row] != None:}}
  36.                 {{if blockTable[col][row].PCA_ID != 0:}}
  37.                     {{pcaName = db.PCAs[blockTable[col][row].PCA_ID].FirstName + " " + db.PCAs[blockTable[col][row].PCA_ID].LastName}}
  38.                 {{else:}}
  39.                     {{pcaName = "Unknown - Import Error!"}}
  40.                 {{pass}}
  41.                 <td style = "border: 3px solid green; background-color: {{='#%02X%02X%02X' % colors[blockTable[col][row].PCA_ID]}};">
  42.                 <div id = "block_table_td_{{=str(blockTable[col][row].id)}}">
  43.                     <!--{{=A(pcaName,_href=URL(r=request,c="PCAs", f='ViewPCA?PCAID=%s'%str(blockTable[col][row].PCA_ID)))}}<br>-->
  44.                     {{=pcaName}}<br>
  45.                     {{=blockTable[col][row].BlockStart.strftime("%I:%M %p")}}<br>
  46.                     {{=blockTable[col][row].BlockEnd.strftime("%I:%M %p")}}<br>
  47.                     {{=A(IMG(_src=URL(r=request,c='static',f='edit.gif'),_alt="Edit Schedule Block"),_href="javascript:BeginTBEdit(%s)" % blockTable[col][row].id)}}<br>
  48.                     {{=A(IMG(_src=URL(r=request,c='static',f='delete.gif'),_alt="Delete Schedule Block"),_href="javascript:BeginDeleteEdit(%s)" % blockTable[col][row].id)}}
  49.                 </div>
  50.                 </td>
  51.             {{else:}}
  52.                 <td style = "border: 1px solid green;">
  53.                 </td>
  54.             {{pass}}
  55.  
  56.         {{pass}}
  57.     </tr>
  58. {{pass}}
  59.     </tbody>
  60. </table>
  61.  
  62. <script>
  63. var old_td_html = "";
  64. var tbID = "";
  65. var editingTB = false;
  66. var mID = {{=mID}}
  67. var lastSelected_timeblock_td = "#timeblock_td_0";
  68. var newDay = 1;
  69.  
  70. function confirmDelete1()
  71. {
  72.     if(editingTB == true)
  73.     {
  74.         window.alert("Cannot delete time blocks when another block is being edited.");
  75.         return false;
  76.     }
  77.  
  78.     return confirm("Do you really want to Delete this time block?");
  79. };
  80.  
  81.  
  82.  
  83. function checkTBForm()
  84. {
  85.     //window.alert("You are here 2");
  86.     var PCAID = $("#tbEditForm_PCAID").val();
  87.     var Sta = $("#tbEditForm_BlockStart").val();
  88.     var End = $("#tbEditForm_BlockEnd").val();
  89.     var accepted = false;
  90.     var message = "";
  91.     //window.alert("You are here 3");
  92.  
  93.     function check1(data)
  94.     {
  95.         //window.alert("You are here 1");
  96.         accepted = data.Accepted;
  97.         message = data.Message;
  98.         //window.alert("Message:" + message);
  99.     }
  100.  
  101.     ///jQuery.getJSON('validateTimeblockEditForm.json',{mID: mID, Sta: Sta, End: End}, check1);
  102.  
  103.     $.ajax({
  104.         type: 'GET',
  105.         url: 'validateMemberTimeblockEditForm.json',
  106.         dataType: 'json',
  107.         success: check1,
  108.         data: {blockID: tbID, PCAID: PCAID, mID: mID, Sta: Sta, End: End},
  109.         async: false
  110.     });
  111.  
  112.     //window.alert("You are here 4");
  113.  
  114.     if(accepted!=true)
  115.     {
  116.         window.alert("Message:" + message);
  117.         return false;
  118.     }
  119.     //window.alert("accepted " + accepted);
  120.     //window.alert(message);
  121.     return true;
  122. };
  123.  
  124.  
  125. function BeginTBEdit(blockID)
  126. {
  127.     if(editingTB == true)
  128.     {
  129.         window.alert("Only one time block may be edited at a time.");
  130.         return false;
  131.     }
  132.     //window.alert("You are here 1 - blockID:" + blockID);
  133.     // request values from the server to fill the form fields
  134.     jQuery.getJSON('getMemberTimeblockEditForm.json',{blockID: blockID}, FillEditBlock);
  135.     //window.alert("You are here 2");
  136.     editingTB = true
  137. };
  138.  
  139.  
  140. function BeginDeleteEdit(blockID)
  141. {
  142.     result = confirmDelete1()
  143.     if(result == true)
  144.     {
  145.         jQuery.getJSON('deleteMemberTimeblock.json',{blockID: blockID}, function(){return true;});
  146.         location.reload(true);
  147.     }
  148. };
  149.  
  150. function FillEditBlock(data)
  151. {
  152.  
  153.     tbID = data.tbID
  154.     old_td_html = $("#block_table_td_" + data.tbID).html();
  155.     //window.alert(data);
  156.     $("#block_table_td_" + data.tbID).html(data.tbEditForm);
  157.  
  158.     // rewire form on submit event
  159.     $('#tbEditForm').attr("onSubmit", "return checkTBForm()")
  160.     //window.alert("You are here 4");
  161. };
  162.  
  163.  
  164. function CancelTBEdit()
  165. {
  166.     location.reload(true);
  167. };
  168.  
  169.  
  170. function CancelTBAdd()
  171. {
  172.     location.reload(true);
  173. };
  174.  
  175. function checkTBAddForm()
  176. {
  177.     //window.alert("You are here 2");
  178.     var PCAID = $("#tbAddForm_PCAID").val();
  179.     var Sta = $("#tbAddForm_BlockStart").val();
  180.     var End = $("#tbAddForm_BlockEnd").val();
  181.     var Sunday = $("#tbAddForm_Sunday:checked").val();
  182.     var Monday = $("#tbAddForm_Monday:checked").val();
  183.     var Tuesday = $("#tbAddForm_Tuesday:checked").val();
  184.     var Wednesday = $("#tbAddForm_Wednesday:checked").val();
  185.     var Thursday = $("#tbAddForm_Thursday:checked").val();
  186.     var Friday = $("#tbAddForm_Friday:checked").val();
  187.     var Saturday = $("#tbAddForm_Saturday:checked").val();
  188.     var Day = newDay
  189.     var accepted = false;
  190.     var message = "";
  191.     //window.alert("You are here 3");
  192.  
  193.     function check1(data)
  194.     {
  195.         //window.alert("You are here 1");
  196.         accepted = data.Accepted;
  197.         message = data.Message;
  198.         //window.alert("Message:" + message);
  199.     }
  200.  
  201.     //jQuery.getJSON('validateTimeblockAddForm.json',{mID: mID, Sta: Sta, End: End}, check1);
  202.  
  203.     $.ajax({
  204.         type: 'GET',
  205.         url: 'validateMemberTimeblockAddForm.json',
  206.         dataType: 'json',
  207.         success: check1,
  208.         data: {PCAID: PCAID, mID: mID, Sta: Sta, End: End, Day: Day, Sunday: Sunday, Monday: Monday, Tuesday: Tuesday, Wednesday: Wednesday, Thursday: Thursday, Friday: Friday, Saturday: Saturday},
  209.         async: false
  210.     });
  211.  
  212.     //window.alert("You are here 4");
  213.  
  214.     if(accepted!=true)
  215.     {
  216.         window.alert("Message: " + message);
  217.         return false;
  218.     }
  219.     //window.alert("accepted " + accepted);
  220.     //window.alert(message);
  221.     return true;
  222. };
  223.  
  224.  
  225. function FillAddBlock(data)
  226. {
  227.     //window.alert("You are here 1");
  228.     day = data.day
  229.     newDay = day
  230.     //window.alert("#timeblock_add_div_id_" + day);
  231.     old_td_html = $("#timeblock_add_div_id_" + day).html();
  232.     //window.alert(data);
  233.     $("#timeblock_add_div_id_" + day).html(data.tbAddForm);
  234.  
  235.     // rewire form on submit event
  236.     $('#tbAddForm').attr("onSubmit", "return checkTBAddForm()")
  237.  
  238. };
  239.  
  240.  
  241. function BeginTBAdd(day)
  242. {
  243.     //window.alert("You are here 1 - blah ");
  244.     if(editingTB == true)
  245.     {
  246.         window.alert("Cannot add a new time block while another is being edited.");
  247.         return false;
  248.     }
  249.     //window.alert("You are here 2 - blah");
  250.     //window.alert("day=" + day)
  251.     jQuery.getJSON('getMemberTimeblockAddForm.json',{day: day}, FillAddBlock);
  252.     //window.alert("You are here 3 - blah");
  253.     editingTB = true
  254. };
  255.  
  256.  
  257.  
  258. jQuery(document).ready(function()
  259. {
  260. });
  261.  
  262. </script>
RAW Paste Data
Top