m.create.html.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /**
  3. * The create 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. <?php if(!helper::isAjaxRequest()):?>
  14. <?php include "../../common/view/m.header.html.php";?>
  15. <?php endif;?>
  16. <div class='heading divider'>
  17. <div class='title'><i class='icon icon-plus'></i> <strong><?php echo $lang->overtime->create;?></strong></div>
  18. <?php if(helper::isAjaxRequest()):?>
  19. <nav class='nav'><a data-dismiss='display'><i class='icon-remove muted'></i></a></nav>
  20. <?php endif;?>
  21. </div>
  22. <form class='content box' id='createOvertimeForm' data-form-refresh='#page' method='post' action='<?php echo $this->createLink('overtime', 'create');?>'>
  23. <div class='control'>
  24. <label><?php echo $lang->overtime->type;?></label>
  25. <?php foreach($lang->overtime->typeList as $key => $type):?>
  26. <div class='radio inline-block'>
  27. <input type='radio' name='type' value="<?php echo $key;?>">
  28. <label for="type"><?php echo $type;?></label>
  29. </div>
  30. <?php endforeach;?>
  31. </div>
  32. <div class='row'>
  33. <div class='cell-6'>
  34. <div class='control'>
  35. <label for='begin'><?php echo $lang->overtime->begin;?></label>
  36. <input type='date' class='input' id='begin' name='begin' placeholder='<?php echo $lang->required;?>'>
  37. </div>
  38. </div>
  39. <div class='cell-6'>
  40. <div class='control'>
  41. <label for='start'><?php echo $lang->overtime->start;?></label>
  42. <input type='time' class='input' id='start' value='<?php echo $config->attend->signInLimit;?>' name='start' placeholder='<?php echo $lang->required;?>'>
  43. </div>
  44. </div>
  45. </div>
  46. <div class='row'>
  47. <div class='cell-6'>
  48. <div class='control'>
  49. <label for='end'><?php echo $lang->overtime->end;?></label>
  50. <input type='date' class='input' id='end' name='end' placeholder='<?php echo $lang->required;?>'>
  51. </div>
  52. </div>
  53. <div class='cell-6'>
  54. <div class='control'>
  55. <label for='finish'><?php echo $lang->overtime->finish;?></label>
  56. <input type='time' class='input' id='finish' value='<?php echo $config->attend->signOutLimit;?>' name='finish' placeholder='<?php echo $lang->required;?>'>
  57. </div>
  58. </div>
  59. </div>
  60. <div class='control'>
  61. <label for='hours'><?php echo $lang->overtime->hours;?></label>
  62. <?php echo html::input('hours', '', "class='input' placeholder='{$lang->required}'");?>
  63. </div>
  64. <div class='control'>
  65. <label for='desc'><?php echo $lang->overtime->desc;?></label>
  66. <?php echo html::textarea('desc', '', "rows='5' class='textarea'");?>
  67. </div>
  68. </form>
  69. <div class='footer has-padding'>
  70. <button type='button' data-submit='#createOvertimeForm' class='btn primary'><?php echo $lang->save;?></button>
  71. </div>
  72. <script>
  73. $(function()
  74. {
  75. $('#createOvertimeForm').modalForm({onResult: true}).listenScroll({container: 'parent'});
  76. $('[name=type], #begin, #start, #end, #finish').on('change', function()
  77. {
  78. var type = $('input[name=type]:checked').val();
  79. var begin = $('#begin').val();
  80. var end = $('#end').val();
  81. var start = $('#start').val();
  82. var finish = $('#finish').val();
  83. if(!begin || !end || !start || !finish) return false;
  84. begin = begin.replace(/-/g, '/');
  85. end = end.replace(/-/g, '/');
  86. var hours = 0;
  87. var workingHours = <?php echo $config->attend->workingHours;?>;
  88. var beginTime = Date.parse(new Date(begin + ' ' + start));
  89. var endTime = Date.parse(new Date(end + ' ' + finish));
  90. if(beginTime > endTime) return false;
  91. if(begin == end)
  92. {
  93. hours = Math.round((endTime - beginTime)/(3600*1000)*100)/100;
  94. if(type == 'compensate' && hours > workingHours) hours = parseFloat(workingHours);
  95. }
  96. else
  97. {
  98. var signOut = <?php echo json_encode($config->attend->signOutLimit);?>;
  99. var signIn = <?php echo json_encode($config->attend->signInLimit);?>;
  100. var signOutTime = Date.parse(new Date(begin + ' ' + signOut));
  101. var signInTime = Date.parse(new Date(end + ' ' + signIn));
  102. var hoursStart = 0;
  103. var hoursEnd = 0;
  104. var hoursContent = 0;
  105. if(beginTime < signOutTime)
  106. {
  107. hoursStart = Math.round((signOutTime - beginTime)/(3600*1000)*100)/100;
  108. }
  109. else
  110. {
  111. hoursStart = Math.round((Date.parse(new Date(begin + ' 23:59:60')) - beginTime)/(3600*1000)*100)/100;
  112. }
  113. if(type == 'compensate' && hoursStart > workingHours) hoursStart = parseFloat(workingHours);
  114. if(endTime > signInTime)
  115. {
  116. hoursEnd = Math.round((endTime - signInTime)/(3600*1000)*100)/100;
  117. }
  118. else
  119. {
  120. hoursEnd = Math.round((endTime - Date.parse(new Date(end)))/(3600*1000)*100)/100;
  121. }
  122. if(type == 'compensate' && hoursEnd > workingHours) hoursEnd = parseFloat(workingHours);
  123. var dayHours = Math.round((Date.parse(new Date(begin + ' ' + signOut)) - Date.parse(new Date(begin + ' ' + signIn)))/(3600*1000)*100)/100;
  124. if(type == 'compensate' && dayHours > workingHours) dayHours = workingHours;
  125. var days = Math.floor((Date.parse(new Date(end)) - Date.parse(new Date(begin)))/(24*3600*1000));
  126. if(days > 1) hoursContent = (days - 1) * dayHours;
  127. hours = hoursStart + hoursEnd + hoursContent;
  128. }
  129. $('#hours').val(hours);
  130. });
  131. });
  132. </script>
  133. <?php if(!helper::isAjaxRequest()):?>
  134. <?php include "../../common/view/m.footer.html.php";?>
  135. <?php endif;?>