m.edit.html.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * The edit mobile view file of overtime module of ZDOO.
  4. *
  5. * @copyright Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @license ZPL (http://zpl.pub/page/zplv12.html)
  7. * @author Tingting Dai <daitingting@xirangit.com>
  8. * @package overtime
  9. * @version $Id
  10. * @link http://www.zdoo.com
  11. */
  12. if($extView = $this->getExtViewFile(__FILE__)){include $extView; return helper::cd();}?>
  13. <div class='heading divider'>
  14. <div class='title'><i class='icon icon-plus'></i> <strong><?php echo $lang->overtime->edit;?></strong></div>
  15. <nav class='nav'><a data-dismiss='display'><i class='icon icon-remove'></i></a></nav>
  16. </div>
  17. <form class='content box' id='editOvertimeForm' data-form-refresh='#page' method='post' action='<?php echo $this->createLink('overtime', 'edit', "id=$overtime->id");?>'>
  18. <div class='control'>
  19. <label><?php echo $lang->overtime->type;?></label>
  20. <?php foreach($lang->overtime->typeList as $key => $type):?>
  21. <?php $checked = $overtime->type == $key ? "checked='checked'" : '';?>
  22. <div class='radio inline-block'>
  23. <input type='radio' name='type' value="<?php echo $key;?>" <?php echo $checked;?>>
  24. <label for="type"><?php echo $type;?></label>
  25. </div>
  26. <?php endforeach;?>
  27. </div>
  28. <div class='row'>
  29. <div class='cell-6'>
  30. <div class='control'>
  31. <label for='begin'><?php echo $lang->overtime->begin;?></label>
  32. <input type='date' class='input' id='begin' name='begin' value="<?php echo $overtime->begin;?>" placeholder='<?php echo $lang->required;?>'>
  33. </div>
  34. </div>
  35. <div class='cell-6'>
  36. <div class='control'>
  37. <label for='start'><?php echo $lang->overtime->start;?></label>
  38. <input type='time' class='input' id='start' value='<?php echo $overtime->start;?>' name='start' placeholder='<?php echo $lang->required;?>'>
  39. </div>
  40. </div>
  41. </div>
  42. <div class='row'>
  43. <div class='cell-6'>
  44. <div class='control'>
  45. <label for='end'><?php echo $lang->overtime->end;?></label>
  46. <input type='date' class='input' id='end' name='end' value="<?php echo $overtime->end;?>" placeholder='<?php echo $lang->required;?>'>
  47. </div>
  48. </div>
  49. <div class='cell-6'>
  50. <div class='control'>
  51. <label for='finish'><?php echo $lang->overtime->finish;?></label>
  52. <input type='time' class='input' id='finish' value='<?php echo $overtime->finish;?>' name='finish' placeholder='<?php echo $lang->required;?>'>
  53. </div>
  54. </div>
  55. </div>
  56. <div class='control'>
  57. <label for='hours'><?php echo $lang->overtime->hours;?></label>
  58. <?php echo html::input('hours', $overtime->hours, "class='input' placeholder='{$lang->required}'");?>
  59. </div>
  60. <div class='control'>
  61. <label for='desc'><?php echo $lang->overtime->desc;?></label>
  62. <?php echo html::textarea('desc', $overtime->desc, "rows='5' class='textarea'");?>
  63. </div>
  64. </form>
  65. <div class='footer has-padding'>
  66. <button type='button' data-submit='#editOvertimeForm' class='btn primary'><?php echo $lang->save;?></button>
  67. </div>
  68. <script>
  69. $(function()
  70. {
  71. $('#editOvertimeForm').modalForm().listenScroll({container: 'parent'});
  72. $('[name=type], #begin, #start, #end, #finish').on('change', function()
  73. {
  74. var type = $('input[name=type]:checked').val();
  75. var begin = $('#begin').val();
  76. var end = $('#end').val();
  77. var start = $('#start').val();
  78. var finish = $('#finish').val();
  79. if(!begin || !end || !start || !finish) return false;
  80. begin = begin.replace(/-/g, '/');
  81. end = end.replace(/-/g, '/');
  82. var hours = 0;
  83. var workingHours = <?php echo $config->attend->workingHours;?>;
  84. var beginTime = Date.parse(new Date(begin + ' ' + start));
  85. var endTime = Date.parse(new Date(end + ' ' + finish));
  86. if(beginTime > endTime) return false;
  87. if(begin == end)
  88. {
  89. hours = Math.round((endTime - beginTime)/(3600*1000)*100)/100;
  90. if(type == 'compensate' && hours > workingHours) hours = parseFloat(workingHours);
  91. }
  92. else
  93. {
  94. var signOut = <?php echo json_encode($config->attend->signOutLimit);?>;
  95. var signIn = <?php echo json_encode($config->attend->signInLimit);?>;
  96. var signOutTime = Date.parse(new Date(begin + ' ' + signOut));
  97. var signInTime = Date.parse(new Date(end + ' ' + signIn));
  98. var hoursStart = 0;
  99. var hoursEnd = 0;
  100. var hoursContent = 0;
  101. if(beginTime < signOutTime)
  102. {
  103. hoursStart = Math.round((signOutTime - beginTime)/(3600*1000)*100)/100;
  104. }
  105. else
  106. {
  107. hoursStart = Math.round((Date.parse(new Date(begin + ' 23:59:60')) - beginTime)/(3600*1000)*100)/100;
  108. }
  109. if(type == 'compensate' && hoursStart > workingHours) hoursStart = parseFloat(workingHours);
  110. if(endTime > signInTime)
  111. {
  112. hoursEnd = Math.round((endTime - signInTime)/(3600*1000)*100)/100;
  113. }
  114. else
  115. {
  116. hoursEnd = Math.round((endTime - Date.parse(new Date(end)))/(3600*1000)*100)/100;
  117. }
  118. if(type == 'compensate' && hoursEnd > workingHours) hoursEnd = parseFloat(workingHours);
  119. var dayHours = Math.round((Date.parse(new Date(begin + ' ' + signOut)) - Date.parse(new Date(begin + ' ' + signIn)))/(3600*1000)*100)/100;
  120. if(type == 'compensate' && dayHours > workingHours) dayHours = workingHours;
  121. var days = Math.floor((Date.parse(new Date(end)) - Date.parse(new Date(begin)))/(24*3600*1000));
  122. if(days > 1) hoursContent = (days - 1) * dayHours;
  123. hours = hoursStart + hoursEnd + hoursContent;
  124. }
  125. $('#hours').val(hours);
  126. });
  127. })
  128. </script>