m.create.html.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * The create mobile view file of leave 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 leave
  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->leave->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='createLeaveForm' data-form-refresh='#page' method='post' action='<?php echo $this->createLink('leave', 'create');?>'>
  23. <div class='control'>
  24. <label><?php echo $lang->leave->type;?></label>
  25. <?php foreach($lang->leave->typeList as $key => $type):?>
  26. <div class='radio inline-block'>
  27. <input type='radio' name='type' <?php if($key == 'affairs') echo "checked='checked'";?> 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->leave->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->leave->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->leave->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->leave->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->leave->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->leave->desc;?></label>
  66. <?php echo html::textarea('desc', '', "rows='3' class='textarea'");?>
  67. </div>
  68. </form>
  69. <div class='footer has-padding'>
  70. <button type='button' data-submit='#createLeaveForm' class='btn primary'><?php echo $lang->save;?></button>
  71. </div>
  72. <script>
  73. $(function()
  74. {
  75. $('#createLeaveForm').modalForm({onResult: true}).listenScroll({container: 'parent'});
  76. $('#begin, #start, #end, #finish').on('change', function()
  77. {
  78. var begin = $('#begin').val();
  79. var end = $('#end').val();
  80. var start = $('#start').val();
  81. var finish = $('#finish').val();
  82. if(!begin || !end || !start || !finish) return false;
  83. begin = begin.replace(/-/g, '/');
  84. end = end.replace(/-/g, '/');
  85. var hours = 0;
  86. var workingHours = <?php echo $config->attend->workingHours;?>;
  87. var beginTime = Date.parse(new Date(begin + ' ' + start));
  88. var endTime = Date.parse(new Date(end + ' ' + finish));
  89. if(beginTime > endTime) return false;
  90. if(begin == end)
  91. {
  92. hours = Math.round((endTime - beginTime)/(3600*1000)*100)/100;
  93. if(hours > workingHours) hours = parseFloat(workingHours);
  94. }
  95. else
  96. {
  97. var signOut = <?php echo json_encode($config->attend->signOutLimit);?>;
  98. var signIn = <?php echo json_encode($config->attend->signInLimit);?>;
  99. var signOutTime = Date.parse(new Date(begin + ' ' + signOut));
  100. var signInTime = Date.parse(new Date(end + ' ' + signIn));
  101. var hoursStart = 0;
  102. var hoursEnd = 0;
  103. var hoursContent = 0;
  104. if(beginTime < signOutTime) hoursStart = Math.round((signOutTime - beginTime)/(3600*1000)*100)/100;
  105. if(hoursStart > workingHours) hoursStart = parseFloat(workingHours);
  106. if(endTime > signInTime) hoursEnd = Math.round((endTime - signInTime)/(3600*1000)*100)/100;
  107. if(hoursEnd > workingHours) hoursEnd = parseFloat(workingHours);
  108. var days = Math.floor((Date.parse(new Date(end)) - Date.parse(new Date(begin)))/(24*3600*1000));
  109. if(days > 1) hoursContent = (days - 1) * workingHours;
  110. hours = hoursStart + hoursEnd + hoursContent;
  111. }
  112. $('#hours').val(hours);
  113. });
  114. });
  115. </script>
  116. <?php if(!helper::isAjaxRequest()):?>
  117. <?php include "../../common/view/m.footer.html.php";?>
  118. <?php endif;?>