Guest User

Untitled

a guest
Oct 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. <apex:page standardController="Payroll_Authorization__c" sidebar="false" doctype="html-5.0" standardStylesheets="false" extensions="PayrollAuthorization_extn" applyBodyTag="true" lightningStylesheets="true">
  2. <head>
  3. <meta charset="utf-8"/>
  4. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  5. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  7. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  8. <style>
  9. .form-control {
  10. padding: 6px !important;
  11. }
  12. .btn-info {
  13. color: #fff!important;
  14. background-color: #5bc0de !important;
  15. border-color: #46b8da !important;
  16. background-image: none !important;
  17. padding: 8px 20px !important;
  18. }
  19. .table>thead>tr>th{
  20. vertical-align: top !important;
  21. text-align: left !important;
  22. }
  23. .table>tbody>tr>td{
  24. vertical-align: top !important;
  25. text-align: left !important;
  26. }
  27. .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
  28. padding: 4px !important;
  29. }
  30. .list-group-item {
  31. padding: 6px 15px !important;
  32. }
  33. </style>
  34. <script>
  35.  
  36. function calctotal(){
  37. alert ("caltotal" + {!PayrollDistributionList.size});
  38. var tempRowTotal=0;
  39. var percenttotal= 0;
  40. for(var i=1; <b>i<={!PayrollDistributionList.size};i++ </b>){
  41.  
  42. tempRowTotal = ($('.wh'+i).val()!= null && $('.wh'+i).val() != '')?parseFloat($('.wh'+i).val()):0.0;
  43. percenttotal += tempRowTotal;
  44.  
  45. }
  46. return percenttotal;
  47. }
  48.  
  49. function calcRow(){
  50. alert ("calrow");
  51.  
  52. var tempRowTotal=0;
  53. var percenttotal= 0;
  54. percenttotal= calctotal();
  55. for(var i=1; i<={!PayrollDistributionList.size};i++ ){
  56. tempRowTotal = ($('.wh'+i).val()!= null && $('.wh'+i).val() != '')?parseFloat($('.wh'+i).val()):0.0;
  57. $('.wp' + i).text(((tempRowTotal * 100)/percenttotal).toFixed(2)+'%');
  58. $('.percenttotal').text(percenttotal.toFixed(2)+'%');
  59. }
  60. }
  61.  
  62. $(document).ready(function(){
  63. {
  64. calcRow();
  65. }
  66.  
  67. });
  68. </script>
  69. </head>
  70. <body>
  71. <apex:form >
  72. <apex:pageBlock title="Payroll Distribution" id="er" >
  73. <div align="center" draggable="false" style="font-size:13px; margin-bottom:4px" >
  74. <apex:commandButton value="Save" action="{!SavePA}" styleclass="btn btn-info" style="" />&nbsp;&nbsp;
  75. <apex:commandButton value="Cancel" action="{!Cancel}" styleclass="btn btn-info" immediate="true"/>
  76. </div>
  77. <div class="container-flud" style="font-size: 11.5px;">
  78. <apex:pageMessages ></apex:pageMessages>
  79. <div class="col-md-12" style="margin-bottom: -15px;">
  80. <ul class="list-group">
  81. <li class="list-group-item row" style="background-color: #702342;color: #fff;padding: 6px 10px;">
  82. <h4 style="margin: 2px 0px;font-size: 12px;font-weight: bolder;">Payroll Authorization</h4>
  83. </li>
  84. </ul>
  85.  
  86. <div class="col-md-12" style="margin-bottom: 15px;">
  87. <ul class="list-group">
  88. <li class="list-group-item row" style="background-color: #702342;color: #fff;padding: 6px 10px;">
  89. <h4 style="margin: 2px 0px;font-size: 12px;font-weight: bolder;">Payroll Distributions</h4>
  90. </li>
  91. </ul>
  92. </div>
  93. <table class="table table-bordered" >
  94.  
  95. <thead>
  96. <tr>
  97. <th>
  98. Program
  99. </th>
  100. <th>
  101. Percentage worked
  102. </th>
  103. <th>
  104. Percentage total
  105. </th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <apex:variable value="{!1}" var="index"/>
  110. <apex:repeat value="{!PayrollDistributionList}" var="pd">
  111. <tr>
  112. <td><apex:inputfield value="{!pd.Program__c}" style="Width: 50%"/></td>
  113. <td ><apex:inputfield value="{!pd.Program_Percent__c}" styleClass="wh{!index}" onkeyup="calcRow()"/> </td>
  114. <td Class="wp{!index}">
  115. 0%
  116. </td>
  117. </tr>
  118. <apex:variable value="{!index+1}" var="index"/>
  119.  
  120. </apex:repeat>
  121. </tbody>
  122. <tfoot> <tr>
  123. <th>
  124. </th>
  125. <th class="percenttotal">
  126. 0.0%
  127. </th>
  128. <th>
  129. 100.00%
  130. </th>
  131. </tr></tfoot>
  132. </table>
  133. </div>
  134. </div>
  135. <apex:commandButton action="{!addRow}" value="Add Program" immediate="true" reRender="er"/>
  136. </apex:pageBlock>
  137. </apex:form>
  138.  
  139. </body>
  140. </apex:page>
  141.  
  142. public with sharing class PayrollAuthorization_extn {
  143.  
  144. public list <PA_Distribution__c> PayrollDistributionList {get; set;}
  145. public Payroll_Authorization__c PA;
  146.  
  147.  
  148. public PayrollAuthorization_extn(ApexPages.StandardController controller) {
  149.  
  150. PA = (Payroll_Authorization__c)controller.getRecord();
  151. PayrollDistributionList = [Select Id, Name, Program__r.Name, Program_Percent__c
  152. From PA_Distribution__c
  153. Where Payroll_Authorization__r.id =: controller.getId()];
  154.  
  155. }
  156.  
  157. public void addRow(){
  158. PayrollDistributionList.add(new PA_Distribution__c( Payroll_Authorization__c = PA.id));
  159. }
  160.  
  161. public void SavePA (){
  162. upsert PA;
  163. upsert PayrollDistributionList;
  164. }
  165.  
  166.  
  167. }
Add Comment
Please, Sign In to add comment