tripal_bulk_loader_base.tpl.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. $node = $variables['node']; ?>
  3. <div class="tripal_bulk_loader-data-block-desc tripal-data-block-desc"></div> <?php
  4. // the $headers array is an array of fields to use as the colum headers.
  5. // additional documentation can be found here
  6. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  7. // This table for the analysis has a vertical header (down the first column)
  8. // so we do not provide headers here, but specify them in the $rows array below.
  9. $headers = [];
  10. // the $rows array contains an array of rows where each row is an array
  11. // of values for each column of the table in that row. Additional documentation
  12. // can be found here:
  13. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  14. $rows = [];
  15. // Name row
  16. $rows[] = [
  17. [
  18. 'data' => 'Job Name',
  19. 'header' => TRUE,
  20. 'width' => '20%',
  21. ],
  22. $node->loader_name,
  23. ];
  24. // Submitted By
  25. $rows[] = [
  26. [
  27. 'data' => 'Submitted By',
  28. 'header' => TRUE,
  29. ],
  30. $node->uid,
  31. ];
  32. // Job Creation Date
  33. $rows[] = [
  34. [
  35. 'data' => 'Job Creation Date',
  36. 'header' => TRUE,
  37. ],
  38. format_date($node->created, 'custom', "F j, Y, g:i a"),
  39. ];
  40. // Last Updated
  41. $rows[] = [
  42. [
  43. 'data' => 'Last Updated',
  44. 'header' => TRUE,
  45. ],
  46. format_date($node->changed, 'custom', "F j, Y, g:i a"),
  47. ];
  48. // Template Name
  49. $rows[] = [
  50. [
  51. 'data' => 'Template Name',
  52. 'header' => TRUE,
  53. ],
  54. $node->template->name,
  55. ];
  56. // Data File
  57. $rows[] = [
  58. [
  59. 'data' => 'Data File',
  60. 'header' => TRUE,
  61. ],
  62. $node->file,
  63. ];
  64. // Job Status
  65. $rows[] = [
  66. [
  67. 'data' => 'Job Status',
  68. 'header' => TRUE,
  69. ],
  70. $node->job_status,
  71. ];
  72. //Job Progress
  73. if (isset($node->job)) {
  74. if (isset($node->job->progress)) {
  75. $rows[] = [
  76. [
  77. 'data' => 'Job Progress',
  78. 'header' => TRUE,
  79. ],
  80. $node->job->progress . '% (' . l('view job', 'admin/tripal/tripal_jobs/view/' . $node->job_id) . ')',
  81. ];
  82. }
  83. }
  84. // the $table array contains the headers and rows array as well as other
  85. // options for controlling the display of the table. Additional
  86. // documentation can be found here:
  87. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  88. $table = [
  89. 'header' => $headers,
  90. 'rows' => $rows,
  91. 'attributes' => [
  92. 'id' => 'tripal_bulk_loader-table-base',
  93. 'class' => 'tripal-data-table',
  94. ],
  95. 'sticky' => FALSE,
  96. 'caption' => '',
  97. 'colgroups' => [],
  98. 'empty' => '',
  99. ];
  100. // once we have our table array structure defined, we call Drupal's theme_table()
  101. // function to generate the table.
  102. print theme_table($table);
  103. // add the "submit" button for adding a loading job to the Tripal jobs management system
  104. $form = drupal_get_form('tripal_bulk_loader_add_loader_job_form', $node);
  105. print drupal_render($form);
  106. // if we have inserted records then load the summary:
  107. if (!empty($node->inserted_records)) {
  108. print '<h3>Loading Summary</h3>';
  109. // the $headers array is an array of fields to use as the colum headers.
  110. // additional documentation can be found here
  111. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  112. $headers = ['Chado Table', 'Number of Records Inserted'];
  113. // the $rows array contains an array of rows where each row is an array
  114. // of values for each column of the table in that row. Additional documentation
  115. // can be found here:
  116. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  117. $rows = [];
  118. $total = 0;
  119. foreach ($node->inserted_records as $r) {
  120. $row = [];
  121. $row[] = $r->table_inserted_into;
  122. $row[] = $r->num_inserted;
  123. $rows[] = $row;
  124. $total = $total + $r->num_inserted;
  125. }
  126. $rows[] = ['<b>TOTAL</b>', '<b>' . $total . '</b>'];
  127. // the $table array contains the headers and rows array as well as other
  128. // options for controlling the display of the table. Additional
  129. // documentation can be found here:
  130. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  131. $table = [
  132. 'header' => $headers,
  133. 'rows' => $rows,
  134. 'attributes' => [],
  135. 'sticky' => FALSE,
  136. 'caption' => '',
  137. 'colgroups' => [],
  138. 'empty' => '',
  139. ];
  140. // once we have our table array structure defined, we call Drupal's theme_table()
  141. // function to generate the table.
  142. print theme_table($table);
  143. } ?>
  144. <br> <?php
  145. // add the form for setting any constants values
  146. $form = drupal_get_form('tripal_bulk_loader_set_constants_form', $node);
  147. print drupal_render($form);
  148. // add in the constant details
  149. print theme('tripal_bulk_loader_template', ['template_id' => $node->template->template_id]);