showimport.html.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php include $app->getModuleRoot() . 'transfer/view/header.html.php';?>
  2. <?php js::set('productID', $productID);?>
  3. <?php js::set('branchModules', $branchModules);?>
  4. <div id="mainContent" class="main-content">
  5. <div class="main-header clearfix">
  6. <h2><?php echo $lang->transfer->import;?></h2>
  7. </div>
  8. <form class='main-form' target='hiddenwin' method='post' id='portform'>
  9. <table class='table table-form' id='showData'>
  10. <thead>
  11. <tr>
  12. <th class='w-70px'> <?php echo $lang->transfer->id?></th>
  13. <?php foreach($fields as $key => $value):?>
  14. <?php if($key == 'stepDesc' or $key == 'stepExpect'):?>
  15. <?php if($key == 'stepExpect') continue;?>
  16. <th class='c-step'>
  17. <table class='w-p100 table-borderless'>
  18. <tr>
  19. <th><?php echo $fields['stepDesc']['title']?></th>
  20. <th><?php echo $fields['stepExpect']['title']?></th>
  21. </tr>
  22. </table>
  23. </th>
  24. <?php elseif($value['control'] != 'hidden'):?>
  25. <th class='c-<?php echo $key?>' id='<?php echo $key;?>'> <?php echo $value['title'];?></th>
  26. <?php endif;?>
  27. <?php endforeach;?>
  28. <?php
  29. if(!empty($appendFields))
  30. {
  31. foreach($appendFields as $field)
  32. {
  33. if(!$field->show) continue;
  34. $width = ($field->width && $field->width != 'auto' ? $field->width . 'px' : 'auto');
  35. $required = strpos(",$field->rules,", ",$notEmptyRule->id,") !== false ? 'required' : '';
  36. echo "<th class='$required' style='width: $width'>$field->name</th>";
  37. }
  38. }
  39. ?>
  40. </tr>
  41. </thead>
  42. <tbody>
  43. </tbody>
  44. <tfoot class='hidden'>
  45. <?php include $app->getModuleRoot() . 'transfer/view/tfoot.html.php';?>
  46. </tfoot>
  47. </table>
  48. <?php if(!$this->session->insert) include $app->getModuleRoot() . 'common/view/noticeimport.html.php';?>
  49. </form>
  50. </div>
  51. <?php include $app->getModuleRoot() . 'transfer/view/footer.html.php';?>
  52. <script>
  53. $('#showData').on('change', '.picker-select', function(e)
  54. {
  55. var id = $(this).attr('id');
  56. var field = $(this).attr('data-field');
  57. var moduleID = $(this).val();
  58. var index = Number(id.replace(/[^\d]/g, " "));
  59. var stroyValue = $('#story' + index).val() == '' ? 0 : $('#story' + index).val();
  60. if(field === 'module')
  61. {
  62. var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=0&moduleID=' + moduleID + '&storyID=' + stroyValue + '&onlyOption=false&status=&limit=0&type=full&hasParent=1&executionID=0&number=' + index);
  63. $.get(storyLink, function(stories)
  64. {
  65. $('#story' + index).next('.picker').remove();
  66. $('#story' + index).replaceWith(stories);
  67. $('#story' + index).picker({chosenMode: true});
  68. $('#story' + index).attr('isInit', true);
  69. $('#story' + index).attr('name', 'story[' + index + ']');
  70. })
  71. }
  72. });
  73. $('#showData').on('mouseover', '.picker', function(e)
  74. {
  75. var myPicker = $(this);
  76. var field = myPicker.prev().attr('data-field');
  77. if(typeof(field) == 'undefined') return;
  78. var name = myPicker.prev().attr('name');
  79. var index = Number(name.replace(/[^\d]/g, " "));
  80. if(field == 'story') $('#module' + index).change();
  81. });
  82. $('#showData').on('change', '[id^=branch]', function(e)
  83. {
  84. var index = $(this).attr('id').replace(/[^0-9]/ig, '');
  85. setImportModules(this.value, productID, index, $('#module' + index).val());
  86. });
  87. function getTbodyLoaded()
  88. {
  89. $('select[id^=branch]').trigger('change');
  90. }
  91. /**
  92. * Set modules.
  93. *
  94. * @param int $branchID
  95. * @param int $productID
  96. * @param int $num
  97. * @param int $val
  98. * @access public
  99. * @return void
  100. */
  101. function setImportModules(branchID, productID, num, val)
  102. {
  103. modules = branchModules[branchID];
  104. if(!modules) modules = '<select id="module' + num + '" name="module[' + num + ']" class="form-control"></select>';
  105. var dataHtml = $(modules).attr('id', 'module' + num).attr('name', 'module[' + num + ']').prop('outerHTML');
  106. $('#module' + num).replaceWith(dataHtml);
  107. $('#module' + num).val(val);
  108. $("#module" + num + "_chosen").remove();
  109. $("#module" + num).next('.picker').remove();
  110. $('#module' + num).picker({chosenMode: true});
  111. $('#module' + num).addClass('picker-select').attr('data-field', 'module').attr('data-index', num).attr('isInit', true);
  112. if(val != $('#module' + num).val()) $('#module' + num).trigger('change');
  113. }
  114. </script>