function globallink_dashboard_active in GlobalLink Connect for Drupal 7.7
Same name and namespace in other branches
- 7.5 globallink_active_submissions.inc \globallink_dashboard_active()
- 7.6 globallink_active_submissions.inc \globallink_dashboard_active()
Form to show all active GlobalLink submissions.
1 string reference to 'globallink_dashboard_active'
- globallink_dashboard_active_submissions_page in ./
globallink_workbench_all_submissions.inc - Builds forms on GlobalLink active submissions dashboard.
File
- ./
globallink_workbench_all_submissions.inc, line 357
Code
function globallink_dashboard_active() {
$module_path = drupal_get_path('module', 'globallink');
drupal_add_css($module_path . '/css/globallink_active_submissions.css');
module_load_include('inc', 'globallink', 'globallink');
module_load_include('inc', 'globallink', 'globallink_node');
module_load_include('inc', 'globallink_entity', 'globallink_entity');
module_load_include('inc', 'globallink_block', 'globallink_block');
module_load_include('inc', 'globallink_fieldable_panels', 'globallink_fieldable_panels');
module_load_include('inc', 'globallink_interface', 'globallink_interface');
module_load_include('inc', 'globallink_menu', 'globallink_menu');
module_load_include('inc', 'globallink_taxonomy', 'globallink_taxonomy');
module_load_include('inc', 'globallink_webform', 'globallink_webform');
module_load_include('inc', 'globallink_beans', 'globallink_beans');
module_load_include('inc', 'globallink_file_entity', 'globallink_file_entity');
module_load_include('inc', 'globallink_commerce', 'globallink_commerce');
module_load_include('inc', 'globallink', 'globallink_settings');
module_load_include('inc', 'globallink', 'gl_ws/gl_ws_receive_translations');
$form = array();
$breadcrumb = array();
$breadcrumb[] = l('Home', '');
$breadcrumb[] = l('Administration', 'admin');
$breadcrumb[] = l('Globallink', 'admin/globallink-translations');
if (arg(3) == '') {
$breadcrumb[] = t('Workbench');
$breadcrumb[] = t('Active Submissions');
}
elseif (arg(3) == 'completed') {
$breadcrumb[] = t('Workbench');
$breadcrumb[] = t('Completed Submissions');
}
// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
$page_count = TPT_PAGER_LIMIT;
if (isset($_SESSION['globallink_node_active_page_count'])) {
$page_count = $_SESSION['globallink_node_active_page_count'][0];
}
$header = array(
'submission' => array(
'field' => 'submission',
'data' => t('Submission Name'),
'width' => '15%',
),
'project_code' => array(
'field' => 'project_name',
'data' => t('Project'),
'width' => '10%',
),
'source_name' => array(
'field' => 'source_lang_name',
'data' => t('Source Language'),
'width' => '12%',
),
'target_name' => array(
'field' => 'sub_target_lang_name',
'data' => t('Target Language'),
'width' => '12%',
),
'status' => array(
'field' => 'status',
'data' => t('Status'),
'width' => '14%',
),
'timestamp' => array(
'field' => 'updated',
'data' => t('Last Updated'),
'width' => '12%',
),
'progress' => array(
'data' => '',
'width' => '15%',
),
'operation' => array(
'data' => 'Operations',
'width' => '112px',
),
);
drupal_add_js('jQuery(document).ready(function() {jQuery("ul.tabs.secondary li").each(function() { console.log(jQuery(this).text());if(!(jQuery(this).text().indexOf("Active") >= 0 || jQuery(this).text().indexOf("Completed") >= 0)) { jQuery(this).css("display", "none"); } }); });', 'inline');
if (arg(3) == 'completed') {
$filter_status = '[completed]';
}
else {
$filter_status = '[active]';
}
if (!empty($_SESSION['globallink_all_receive_filter_status'])) {
$filter_status = $_SESSION['globallink_all_receive_filter_status'];
}
$status_arr = array();
if (arg(3) == '' && $filter_status == '[active]') {
$status_arr = array(
GLOBALLINK_STATUS_TRANSLATION_SENT,
GLOBALLINK_STATUS_TRANSLATION_COMPLETED,
GLOBALLINK_STATUS_TRANSLATION_ERROR,
);
}
elseif ($filter_status == '[completed]') {
$status_arr = array(
GLOBALLINK_STATUS_TRANSLATION_IMPORTED,
GLOBALLINK_STATUS_TRANSLATION_SOURCE_CANCELLED,
);
}
else {
$status_arr = array(
$filter_status,
);
}
$filter_tgt_lang = '';
if (!empty($_SESSION['globallink_all_receive_filter_tgt_lang'])) {
if ($_SESSION['globallink_all_receive_filter_tgt_lang'] != '' && $_SESSION['globallink_all_receive_filter_tgt_lang'] != '[all]') {
$filter_tgt_lang = $_SESSION['globallink_all_receive_filter_tgt_lang'];
}
}
$filter_submission = '';
if (!empty($_SESSION['globallink_all_receive_filter_submission'])) {
$filter_submission = $_SESSION['globallink_all_receive_filter_submission'];
}
$sort_order = isset($_GET['order']) ? $_GET['order'] : '';
$rows = array();
// Handling node submissions
$query_node = db_select('globallink_submission', 'gs')
->extend('PagerDefault')
->limit($page_count)
->extend('TableSort');
$query_node
->condition('gs.status', $status_arr, 'IN');
if (!empty($filter_submission)) {
$query_node
->condition('gs.submission', '%' . db_like($filter_submission) . '%', 'LIKE');
}
if (!empty($filter_tgt_lang)) {
$query_node
->condition('gs.sub_target_lang_code', $filter_tgt_lang, '=');
}
$query_node
->fields('gs');
if ($sort_order == '') {
$query_node
->orderBy('updated', 'DESC');
}
else {
$query_node
->orderByHeader($header);
}
$results_node = $query_node
->execute()
->fetchAll();
$count = 0;
foreach ($results_node as $item) {
$count++;
$total_docs = 0;
$total_active_docs = 0;
$doc_query = db_select('globallink_document', 'gd');
$doc_query
->condition('gd.submission_rid', $item->rid, '=');
$doc_query
->fields('gd');
$doc_results = $doc_query
->execute()
->fetchAll();
foreach ($doc_results as $doc_row) {
if ($doc_row->target_status == GLOBALLINK_STATUS_TRANSLATION_COMPLETED || $doc_row->target_status == GLOBALLINK_STATUS_TRANSLATION_SENT || $doc_row->target_status == GLOBALLINK_STATUS_TRANSLATION_ERROR) {
$total_active_docs++;
}
$total_docs++;
}
$percent_width = 0;
$percent_label = 0;
if ($total_docs != 0) {
$percent_width = 100 - round($total_active_docs / $total_docs * 100, 2);
$percent_label = $percent_width;
}
$w3_class = 'w3-green';
$status = $item->status;
$submission_name = l($item->submission, "admin/globallink-translations/workbench/all/" . $item->rid . "/" . $item->sub_target_lang_code);
if ($item->status == GLOBALLINK_STATUS_TRANSLATION_SOURCE_CANCELLED) {
$w3_class = 'w3-red';
$percent_label = 0;
}
elseif ($item->status == GLOBALLINK_STATUS_TRANSLATION_ERROR) {
$status = $status . ' ' . '<img src="' . $GLOBALS['base_url'] . '/' . $module_path . '/css/exclamation.png"" title="Error" height="14" width="14" style="vertical-align: middle;">';
}
if ($percent_width < 1) {
$progress_html = '<div class="w3-dark-grey" style="margin-left: 10px; margin-right: 10px;"><div class="' . $w3_class . '" style="width:' . $percent_width . '%"><span style="padding-left: 10px;">' . $percent_label . '%</span></div></div>';
}
else {
$progress_html = '<div class="w3-dark-grey" style="margin-left: 10px; margin-right: 10px;"><div class="' . $w3_class . '" style="width:' . $percent_width . '%"><span style="padding-left: 10px;">' . $percent_label . '%</span></div></div>';
}
$sync = '';
$import = '';
$view_variables = array(
'path' => drupal_get_path('module', 'globallink') . '/css/gridview16.png',
'width' => '16px',
'height' => '16px',
'attributes' => array(
'title' => 'View',
'class' => array(
'gl-workbench-row-link',
),
),
);
$view_image_html = theme_image($view_variables);
//$view = '<span style="display:inline-block; width: 16px;"></span>' . l($view_image_html, "admin/globallink-translations/workbench/all/" . $item->rid . "/" . $item->sub_target_lang_code, array('html' => TRUE));
if ($item->status != GLOBALLINK_STATUS_TRANSLATION_IMPORTED && $item->status != GLOBALLINK_STATUS_TRANSLATION_SOURCE_CANCELLED) {
$import_variables = array(
'path' => drupal_get_path('module', 'globallink') . '/css/import-sub16.png',
'width' => '16px',
'height' => '16px',
'attributes' => array(
'title' => 'Import',
'class' => array(
'gl-workbench-row-link',
),
),
);
$import_image_html = theme_image($import_variables);
$import = '<span title="Imports translated content" style="display:inline-block; width: 16px;"></span>' . l('Import', request_path() . '/import/' . $item->rid, array(
'html' => TRUE,
));
$sync_variables = array(
'path' => drupal_get_path('module', 'globallink') . '/css/if_refresh_293697.png',
'width' => '16px',
'height' => '16px',
'attributes' => array(
'title' => 'Sync',
'class' => array(
'gl-workbench-row-link',
),
),
);
$sync_image_html = theme_image($sync_variables);
$sync = '<span title="Gets latest status" style="display:inline-block; width: 16px;"></span>' . l('Sync', request_path() . '/sync/' . $item->rid, array(
'html' => TRUE,
));
}
elseif ($item->status == GLOBALLINK_STATUS_TRANSLATION_IMPORTED) {
$import_variables = array(
'path' => drupal_get_path('module', 'globallink') . '/css/import-sub16.png',
'width' => '16px',
'height' => '16px',
'attributes' => array(
'title' => 'Re-Import',
'class' => array(
'gl-workbench-row-link',
),
),
);
$import_image_html = theme_image($import_variables);
$import = '<span title="Imports translated content" style="display:inline-block; width: 16px;"></span>' . l('Re - Import', request_path() . '/import/' . $item->rid, array(
'html' => TRUE,
));
//$sync_variables = array('path' => drupal_get_path('module', 'globallink') . '/css/archive16.png', 'width' => '16px', 'height' => '16px', 'attributes' => array('title' => 'Archive', 'class' => array('gl-workbench-row-link')));
//$sync_image_html = theme_image($sync_variables);
$sync = '<span title="Gets latest status" style="display:inline-block; width: 16px;"></span>';
}
$link = '<div style="text-align: left;">' . $sync . $import . '</div>';
$rows[$item->rid] = array(
'submission' => $submission_name,
'project_code' => $item->project_name,
'source_name' => $item->source_lang_name,
'target_name' => $item->sub_target_lang_name,
'status' => $status,
'timestamp' => format_date($item->updated, 'custom', 'Y-m-d H:i:s'),
'progress' => $progress_html,
//'<progress value="' . $active_count . '" max="' . $total_docs . '"><span>' . $active_count . '</span> of ' . $total_docs . '</progress>',//$active_count . ' of ' . $total_docs . ' Ready for Import',
'operation' => $link,
);
}
drupal_add_js("\n (function(\$) {\n \$(function() {\n \$('.progressbar').each(function() { \n var val = \$(this).attr('rel');\n \$(this).progressbar({ value: parseInt(val) });\n });\n });\n })(jQuery);", 'inline');
if (arg(3) == 'completed') {
$form['submit_pull_all_submission'] = array(
'#type' => 'submit',
'#value' => t('Archive All'),
'#prefix' => '<div class="form-operations">',
'#suffix' => '</div>',
'#attributes' => array(
'title' => t('Sync Status'),
'class' => array(
'globallink-edit-submit-pull-all-submission',
),
),
);
$form['submit_import_all_submission'] = array(
'#type' => 'submit',
'#value' => t('Re-Import All'),
'#prefix' => '<div class="form-operations">',
'#suffix' => '</div>',
'#attributes' => array(
'title' => t('Import Translations'),
'class' => array(
'globallink-edit-submit-import-all-submission',
),
),
);
}
else {
$form['submit_pull_all_submission'] = array(
'#type' => 'submit',
'#value' => t('Sync All'),
'#prefix' => '<div class="form-operations">',
'#suffix' => '</div>',
'#attributes' => array(
'title' => t('Sync Status'),
'class' => array(
'globallink-edit-submit-pull-all-submission',
),
),
);
$form['submit_import_all_submission'] = array(
'#type' => 'submit',
'#value' => t('Import All'),
'#prefix' => '<div class="form-operations">',
'#suffix' => '</div>',
'#attributes' => array(
'title' => t('Import Translations'),
'class' => array(
'globallink-edit-submit-import-all-submission',
),
),
);
}
$form['table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No items available'),
'#attributes' => array(),
);
$form['pager'] = array(
'#markup' => theme('pager'),
);
return $form;
}