m.edit.html.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * The edit 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. <div class='heading divider'>
  14. <div class='title'><i class='icon icon-plus'></i> <strong><?php echo $lang->leave->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='editLeaveForm' data-form-refresh='#page' method='post' action='<?php echo $this->createLink('leave', 'edit', "leaveID={$leave->id}");?>'>
  18. <div class='control'>
  19. <label><?php echo $lang->leave->type;?></label>
  20. <?php foreach($lang->leave->typeList as $key => $type):?>
  21. <?php $checked = $leave->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->leave->begin;?></label>
  32. <input type='date' class='input' id='begin' name='begin' value="<?php echo $leave->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->leave->start;?></label>
  38. <input type='time' class='input' id='start' name='start' value="<?php echo $leave->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->leave->end;?></label>
  46. <input type='date' class='input' id='end' name='end' value="<?php echo $leave->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->leave->finish;?></label>
  52. <input type='time' class='input' id='finish' value="<?php echo $leave->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->leave->hours;?></label>
  58. <?php echo html::input('hours', $leave->hours, "class='input' placeholder='{$lang->required}'");?>
  59. </div>
  60. <div class='control'>
  61. <label for='desc'><?php echo $lang->leave->desc;?></label>
  62. <?php echo html::textarea('desc', $leave->desc, "rows='3' class='textarea'");?>
  63. </div>
  64. </form>
  65. <div class='footer has-padding'>
  66. <button type='button' data-submit='#editLeaveForm' class='btn primary'><?php echo $lang->save;?></button>
  67. </div>
  68. <script>
  69. $(function()
  70. {
  71. $('#editLeaveForm').modalForm().listenScroll({container: 'parent'});
  72. $('#begin, #start, #end, #finish').on('change', function()
  73. {
  74. var begin = $('#begin').val();
  75. var end = $('#end').val();
  76. var start = $('#start').val();
  77. var finish = $('#finish').val();
  78. if(!begin || !end || !start || !finish) return false;
  79. begin = begin.replace(/-/g, '/');
  80. end = end.replace(/-/g, '/');
  81. var hours = 0;
  82. var beginTime = Date.parse(new Date(begin + ' ' + start));
  83. var endTime = Date.parse(new Date(end + ' ' + finish));
  84. var workingHours = <?php echo $config->attend->workingHours;?>;
  85. if(beginTime > endTime) return false;
  86. if(begin == end)
  87. {
  88. hours = Math.round((endTime - beginTime)/(3600*1000)*100)/100;
  89. if(hours > workingHours) hours = parseFloat(workingHours);
  90. }
  91. else
  92. {
  93. var signOut = <?php echo json_encode($config->attend->signOutLimit);?>;
  94. var signIn = <?php echo json_encode($config->attend->signInLimit);?>;
  95. var signOutTime = Date.parse(new Date(begin + ' ' + signOut));
  96. var signInTime = Date.parse(new Date(end + ' ' + signIn));
  97. var hoursStart = 0;
  98. var hoursEnd = 0;
  99. var hoursContent = 0;
  100. if(beginTime < signOutTime) hoursStart = Math.round((signOutTime - beginTime)/(3600*1000)*100)/100;
  101. if(hoursStart > workingHours) hoursStart = parseFloat(workingHours);
  102. if(endTime > signInTime) hoursEnd = Math.round((endTime - signInTime)/(3600*1000)*100)/100;
  103. if(hoursEnd > workingHours) hoursEnd = parseFloat(workingHours);
  104. var days = Math.floor((Date.parse(new Date(end)) - Date.parse(new Date(begin)))/(24*3600*1000));
  105. if(days > 1) hoursContent = (days - 1) * workingHours;
  106. hours = hoursStart + hoursEnd + hoursContent;
  107. }
  108. $('#hours').val(hours);
  109. });
  110. });
  111. </script>