Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // **************************************************************************
- // This file is only used for admin_panel.php in the 'views' folder.
- // **************************************************************************
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- // Set paging global for paging revisions
- var paging = '';
- var paging_dsah = '';
- // Hide admin message
- if($("#admin_message").children().length == 0) {
- $("#admin_message").hide();
- }
- // Set timeout if showing admin message
- setTimeout(function() {
- $( "#admin_message" ).slideUp( "slow", function() {
- // Animation complete.
- });
- }, 2000);
- // Date/Time picker
- $( '#date_created' ).datetimepicker({
- dateFormat: "yy-mm-dd",
- timeFormat: "HH:mm:ss"
- });
- // Scroll window to top on page load
- $(window).scrollTop(0);
- // jQuery tabs
- $( "#tabs" ).tabs({
- beforeActivate: function (event, ui) {
- window.location.hash = ui.newPanel.selector;
- }
- });
- // From hashchange plugin (to keep browser history of tabs selection
- // For forward and back
- $.address.change(function(event){
- tab_location = 0;
- // Get tab and set number
- if(window.location.hash == '#tabs-dashboard') tab_location = 0;
- if(window.location.hash == '#tabs-users') tab_location = 1;
- if(window.location.hash == '#tabs-companies') tab_location = 2;
- if(window.location.hash == '#tabs-products') tab_location = 3;
- if(window.location.hash == '#tabs-revisions') tab_location = 4;
- if(window.location.hash == '#tabs-permissions') tab_location = 5;
- if(window.location.hash == '#tabs-prod-fam-lookup') tab_location = 6;
- if(window.location.hash == '#tabs-data-fields') tab_location = 7;
- if(window.location.hash == '#tabs-misc') tab_location = 8;
- // Set active tab
- $("#tabs").tabs( "option", "active", tab_location );
- $(window).scrollTop(0);
- });
- // When the tab is selected update the url with the hash
- $("#tabs").on("tabsactivate", function(event, ui) {
- window.location.hash = ui.newPanel.selector;
- $(window).scrollTop(0);
- });
- // *****************************************************************************
- // Dashboard Tab
- // *****************************************************************************
- // Hide pagination div and pagination date div
- $('.pagination_dash').hide();
- $('#pagination_date').hide();
- $('#pagination_date_dropdown').hide();
- // Get current stats values
- var $cur_market_comp_owners = $('#company_type_owner').html();
- var $cur_market_comp_res_owners = $('#company_type_research_owner').html();
- var $cur_market_comp_res_data = $('#company_type_research_data').html();
- var $cur_issues_cov_environmental = $('#issue_e').html();
- var $cur_issues_cov_social = $('#issue_s').html();
- var $cur_issues_cov_governance = $('#issue_g').html();
- var $cur_issues_cov_combined = $('#issue_esg').html();
- var $cur_primary_aud_investors = $('#pa_investors').html();
- var $cur_primary_aud_consumers = $('#pa_consumers').html();
- var $cur_primary_aud_companies = $('#pa_companies').html();
- var $cur_product_type_rating = $('#pt_rating').html();
- var $cur_product_type_ranking = $('#pt_ranking').html();
- var $cur_product_type_index = $('#pt_index').html();
- $('#show_comp_prod_stats_history').click(function() {
- // If we are clicking to show the history
- if($(this).text() == 'Show History') {
- // Change button text
- $(this).text('Hide History');
- // Show export buttons
- $('#export_stats_current_page').show();
- $('#export_stats_entire_history').show();
- // Show pagination div and pagination dropdown div
- $('.pagination_dash').show();
- $('#pagination_date').show();
- $('#pagination_date_dropdown').show();
- // Need to run ajax to get count needed for pagination
- $.post("<?php echo base_url() . index_page(); ?>admin/count_dash_stats").done(function (data) {
- // Build date dropdown array variable
- var $date_dropdown_dash = [];
- $.each(data.date_dropdown, function(i, v) {
- $.each(v, function(ii, vv) {
- if(ii === 'date')
- $date_dropdown_dash.push(vv);
- });
- });
- // If there are results to paginate
- if(data.count !== 0) {
- // Paginate results
- paging_dash = $(".pagination_dash").paging(data.count, {
- format: "[< - nncn - >]",
- perpage: 1,
- onSelect: function (page) {
- // Declare start and end values
- var $start = this.slice[0];
- var $end = this.slice[1];
- // Populate hidden input with $start value (will be array key of matched data)
- $('#export_stats_current_page_marker').val($start);
- // Fire ajax to get company/product revision history
- $.post("<?php echo base_url() . index_page(); ?>admin/get_dash_history", {start: $start, end: $end}).done(function (data) {
- $date = '';
- $market_comp_owners = '';
- $market_comp_res_owners = '';
- $market_comp_res_data = '';
- $issues_cov_environmental = '';
- $issues_cov_social = '';
- $issues_cov_governance = '';
- $issues_cov_combined = '';
- $primary_aud_investors = '';
- $primary_aud_consumers = '';
- $primary_aud_companies = '';
- $product_type_rating = '';
- $product_type_ranking = '';
- $product_type_index = '';
- $.each(data.dash_stats_history, function (i, v) {
- $.each(v, function(ii, vv) {
- if(ii == 'date') { $date = vv; }
- if(ii == 'market_comp_owners') { $market_comp_owners = vv; }
- if(ii == 'market_comp_res_owners') { $market_comp_res_owners = vv; }
- if(ii == 'market_comp_res_data') { $market_comp_res_data = vv; }
- if(ii == 'issues_cov_environmental') { $issues_cov_environmental = vv; }
- if(ii == 'issues_cov_social') { $issues_cov_social = vv; }
- if(ii == 'issues_cov_governance') { $issues_cov_governance = vv; }
- if(ii == 'issues_cov_combined') { $issues_cov_combined = vv; }
- if(ii == 'primary_aud_investors') { $primary_aud_investors = vv; }
- if(ii == 'primary_aud_consumers') { $primary_aud_consumers = vv; }
- if(ii == 'primary_aud_companies') { $primary_aud_companies = vv; }
- if(ii == 'product_type_rating') { $product_type_rating = vv; }
- if(ii == 'product_type_ranking') { $product_type_ranking = vv; }
- if(ii == 'product_type_index') { $product_type_index = vv; }
- });
- });
- // Populate date dropdown
- $date_drop_dash = '<select name="select_dash_stats_date" id="select_dash_stats_date">';
- $date_drop_dash += '<option value="">Select Date...</option>';
- $.each($date_dropdown_dash, function(i, v) {
- $date_drop_dash += '<option value="'+i+'">'+v+'</option>';
- });
- $date_drop_dash += '</select>';
- $('#pagination_date_dropdown').html($date_drop_dash);
- // Populate date div
- $('#pagination_date').hide().html($date).fadeIn();
- // Adjust stats figures
- $('#company_type_owner').html($market_comp_owners);
- $('#company_type_research_owner').html($market_comp_res_owners);
- $('#company_type_research_data').html($market_comp_res_data);
- $('#issue_e').html($issues_cov_environmental);
- $('#issue_s').html($issues_cov_social);
- $('#issue_g').html($issues_cov_governance);
- $('#issue_esg').html($issues_cov_combined);
- $('#pa_investors').html($primary_aud_investors);
- $('#pa_consumers').html($primary_aud_consumers);
- $('#pa_companies').html($primary_aud_companies);
- $('#pt_rating').html($product_type_rating);
- $('#pt_ranking').html($product_type_ranking);
- $('#pt_index').html($product_type_index);
- // Adjust class name
- $('.dash_stats').addClass('dash_stats_active');
- });
- },
- onFormat: function (type) {
- switch (type) {
- case 'block':
- if (!this.active)
- return '<span class="disabled">' + this.value + '</span>';
- else if (this.value != this.page)
- return '<em><a href="#' + this.value + '">' + this.value + '</a></em>';
- return '<span class="current">' + this.value + '</span>';
- case 'next':
- if (this.active)
- return '<a href="#' + this.value + '" class="next" title="Next">Next ></a>';
- return '<span class="disabled">Next ></span>';
- case 'prev':
- if (this.active)
- return '<a href="#' + this.value + '" class="prev" title="Previous">< Prev</a>';
- return '<span class="disabled">< Prev</span>';
- case 'first':
- if (this.active)
- return '<a href="#' + this.value + '" class="first" title="first">|<<</a>';
- return '<span class="disabled">|<<</span>';
- case 'last':
- if (this.active)
- return '<a href="#' + this.value + '" class="last" title="Last">>>|</a>';
- return '<span class="disabled">>>|</span>';
- case "leap":
- if (this.active)
- return "...";
- return "";
- case 'fill':
- if (this.active)
- return " - ";
- return "";
- }
- }
- });
- }
- else {
- $html = 'No statistics information yet exists.';
- $('#dash_stats_ajax_div').html($html);
- }
- });
- }
- // Else we are clicking to hide history
- else {
- // Change button text
- $(this).text('Show History');
- // Hide export buttons
- $('#export_stats_current_page').hide();
- $('#export_stats_entire_history').hide();
- // Hide pagination div and pagination date div
- $('.pagination_dash').hide();
- $('#pagination_date').hide();
- $('#pagination_date_dropdown').hide();
- // Adjust stats back to original values
- $('#company_type_owner').html($cur_market_comp_owners);
- $('#company_type_research_owner').html($cur_market_comp_res_owners);
- $('#company_type_research_data').html($cur_market_comp_res_data);
- $('#issue_e').html($cur_issues_cov_environmental);
- $('#issue_s').html($cur_issues_cov_social);
- $('#issue_g').html($cur_issues_cov_governance);
- $('#issue_esg').html($cur_issues_cov_combined);
- $('#pa_investors').html($cur_primary_aud_investors);
- $('#pa_consumers').html($cur_primary_aud_consumers);
- $('#pa_companies').html($cur_primary_aud_companies);
- $('#pt_rating').html($cur_product_type_rating);
- $('#pt_ranking').html($cur_product_type_ranking);
- $('#pt_index').html($cur_product_type_index);
- // Adjust class name
- $('.dash_stats').removeClass('dash_stats_active');
- }
- });
- // Select dash stats date click function
- $(document).on('change', '#select_dash_stats_date', function(e) {
- $page_dash = parseInt($(this).val(), 10) + 1;
- paging_dash.setPage($page_dash);
- });
- // *****************************************************************************
- // Users Tab
- // *****************************************************************************
- // Set sortable admin users table
- $("table#gisr_admin_users").tablesorter({headers: { 0: { filter: false, sorter: false} }, widthFixed: true, widgets: ['filter'], widgetOptions: {
- filter_defaultFilter: { 1: '~{query}' },
- filter_columnFilters: true,
- filter_placeholder: { search: 'Search...' },
- filter_saveFilters: true,
- filter_reset: '.reset'
- }});
- // Filter results on search keyup
- $('#filter_user_table').keyup(function() {
- search_text = $(this).val();
- // Fire ajax to approve company
- $.post("<?php echo base_url() . index_page(); ?>admin/filter_users", {search_text: search_text}).done(function(data) {
- // Clear table results
- $('table#gisr_admin_users tbody').html('');
- // Set returned html
- html = '';
- // If results are returned
- if(data) {
- // Loop each returned array
- $.each(data, function(i, v) {
- // Add to returned html
- html += '<tr><td><input type="checkbox" name="select_edit_users[]" value="' + v.user_id + '" /></td><td>' + v.first_name + ' ' + v.last_name + '</td><td>' + v.email + '</td><td>' + v.user_level + '</td></tr>';
- });
- }
- // Append html to tbody
- $('table#gisr_admin_users tbody').append(html);
- // let tablesorter know we made an update
- $("table#gisr_admin_users").trigger("update");
- // Set sorting column and direction, this will sort on the first and third column
- sorting = [[0,0]];
- // Sort on the first column
- $("table#gisr_admin_users").trigger("sorton", [sorting]);
- });
- });
- // Show other text fields
- if($('.stakeholder_group').val() === 'other') {
- $('#stakeholder_group_hidden_tr').show();
- }
- $('.stakeholder_group').change(function() {
- $val = $(this).val();
- if($val === 'other') {
- $('#stakeholder_group_hidden_tr').show();
- }
- else {
- $('#stakeholder_group_hidden_tr').hide();
- }
- });
- if($('.job_function').val() === 'other') {
- $('#job_function_hidden_tr').show();
- }
- $('.job_function').change(function() {
- $val = $(this).val();
- if($val === 'other') {
- $('#job_function_hidden_tr').show();
- }
- else {
- $('#job_function_hidden_tr').hide();
- }
- });
- // Submit button for create user
- $('#submit_create_user_profile').click(function(e) {
- // Ensure these form fields contain values
- first_name = $('.first_name').val();
- last_name = $('.last_name').val();
- comp_name = $('.comp_name').val();
- assigned_comp = $('.assigned_comp').val();
- job_title = $('.job_title').val();
- email = $('.email').val();
- zip_code = $('.zip_code').val();
- country = $('.country').val();
- stakeholder_group = $('.stakeholder_group').val();
- job_function = $('.job_function').val();
- password = $('.password').val();
- user_status = $('.user_status').val();
- gisr_admin = $('.gisr_admin').val();
- owner = $('.owner').val();
- res_org = $('.res_org').val();
- core_s = $('.core_s').val();
- registered = $('.registered').val();
- user_level = $('.user_level').val();
- approved = $('.approved').val();
- created_on = $('.created_on').val();
- if (first_name == '' || last_name == '' || comp_name == '' || assigned_comp == '' || job_title == '' || email == '' || zip_code == '' || country == '' || stakeholder_group == '' || job_function == '' || password == '' || user_status == '' || gisr_admin == '' || owner == '' || res_org == '' || core_s == '' || registered == '' || user_level == '' || approved == '' || created_on == '') {
- e.preventDefault();
- $.alert({
- title: 'Fields Not Completed',
- content: 'All fields are required to create a user.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- // Submit button for edit user
- $('#submit_edit_user').click(function(e) {
- // Get checkbox values (checked)
- checkboxes = $('input:checkbox:checked');
- // If no checkboxes are checked
- if(checkboxes.length == 0) {
- e.preventDefault();
- $.alert({
- title: 'Select User',
- content: 'Please select a user to edit.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- }
- if(checkboxes.length > 1) {
- e.preventDefault();
- $.alert({
- title: 'Only One User',
- content: 'Only one user may be edited at a time.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- }
- });
- // Submit button for delete user
- $('#submit_delete_user').click(function(e) {
- e.preventDefault();
- // Get checkbox values (checked)
- checkboxes = $('input:checkbox:checked');
- // If no checkboxes are checked
- if(checkboxes.length == 0) {
- $.alert({
- title: 'Delete User(s)',
- content: 'Please select a user(s) to delete.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- }
- else {
- $.confirm({
- title: 'Delete User(s)',
- content: 'A user(s) is about to be deleted. Continue?',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- $('#submit_delete_user_confirmed').click();
- }
- });
- }
- });
- // Users tab submit view awaiting_approval user form
- $('.view_user').click(function() {
- // Get comp id
- user_id = $(this).attr('id');
- // Open new window with loaded company form
- window.location.href = '<?php echo base_url().index_page(); ?>admin/admin_user/manage_user/edit_user/'+user_id;
- });
- // Users tab submit approve user
- $('.approve_user').click(function() {
- var $this = $(this);
- // Confirm approve user
- $.confirm({
- title: 'Approve User?',
- content: 'Please confirm approval of this user.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- cancelButton: 'Cancel',
- confirm: function(){
- // Get user id
- user_id = $($this).attr('id');
- // Fire ajax to approve company
- $.post("<?php echo base_url() . index_page(); ?>admin/approve_user", {user_id: user_id}).done(function(data) {
- if(data.update_message == 'fail') {
- $.alert({
- title: 'User Approval Failed.',
- content: 'This user approval failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'User Approval Successful.',
- content: 'This user was approved successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // *****************************************************************************
- // Companies Tab
- // *****************************************************************************
- // Companies tab step 1
- $('#companies_tab_select_comp').on('change', function() {
- $('#companies_tab_buttons').show();
- });
- // Companies tab deactivate company
- $('#companies_tab_submit_deactivate').click(function() {
- $.confirm({
- title: 'Deactivate Company?',
- content: 'Please enter a reason why this company is being deactivated.<br><br><textarea id="reason_rejected_text" style="width:100%;"></textarea><br><br><strong>Note: </strong>All products associated with this company will also be deactivated.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- comp_id = $('#companies_tab_select_comp').val();
- reason_rejected = $(this.$b.find('#reason_rejected_text')).val();
- $.post("<?php echo base_url() . index_page(); ?>admin/deactivate_company", {comp_id: comp_id, reason_rejected: reason_rejected}).done(function(data) {
- if(data.update_message == 'fail') {
- $.alert({
- title: 'Company Update Failed.',
- content: 'This company update failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Company Update Successful.',
- content: 'This company was deactivated successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // Companies tab submit view awaiting_approval company form
- $('.view_company').click(function() {
- // Get comp id
- comp_id = $(this).attr('id');
- // Open new window with loaded company form
- window.location.href = '<?php echo base_url().index_page(); ?>survey/surveyform_edit_company/'+comp_id;
- });
- // Companies tab submit approve company
- $('.approve_company').click(function() {
- var $this = $(this);
- // Confirm approve company
- $.confirm({
- title: 'Approve Company?',
- content: 'Please confirm approval of this company.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- // Get comp id
- comp_id = $($this).attr('id');
- // Fire ajax to approve company
- $.post("<?php echo base_url() . index_page(); ?>admin/approve_company", {comp_id: comp_id}).done(function(data) {
- if(data.revisions_exist == 'true') {
- $.alert({
- title: 'Company Revisions Exist',
- content: 'This company contains revisions. Please first complete any company revisions.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- return;
- }
- else if(data.update_message == 'fail') {
- $.alert({
- title: 'Company Approval Failed.',
- content: 'This company approval failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Company Approval Successful.',
- content: 'This company was approved successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // Companies tab submit reactivate company (deactivated comps)
- $('.reactivate_company').click(function() {
- var $this = $(this);
- $.confirm({
- title: 'Reactivate Company?',
- content: 'This company is about to be reactivated. Should all associated products also be reactivated?<br><br>'+
- '<table><tbody style="display:block;">'+
- '<tr><td>Yes:</td><td><input type="radio" name="reactivate_prods_from_comp" value="yes" /></td></tr>'+
- '<tr><td>No:</td><td><input type="radio" name="reactivate_prods_from_comp" value="no" checked="checked" /></td></tr>'+
- '</tbody></table>',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- // Get form input name value
- load_prods = this.$b.find('input[name=reactivate_prods_from_comp]:checked').val();
- // Get comp id
- comp_id = $($this).attr('id');
- $.post("<?php echo base_url() . index_page(); ?>admin/reactivate_company", {comp_id: comp_id, load_prods: load_prods}).done(function(data) {
- if(data.update_message == 'fail') {
- $.alert({
- title: 'Company Update Failed.',
- content: 'This company update failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Company Reactivation Successful.',
- content: 'This company was reactivated successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // *****************************************************************************
- // Products Tab
- // *****************************************************************************
- // Products tab step 1 (load products from company)
- $('#products_tab_select_comp').on('change', function() {
- // Clear any appended items in step 2
- $('#product_tab_select_prod').html('');
- // Get company id from value
- comp_id = $(this).val();
- // Post ajax to get associated products
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_tab_admin_prod_lookup", {comp_id: comp_id}).done(function(data) {
- if(data.query !== false) {
- html = '<option value="">Select...</option>';
- $.each(data, function(i, v) {
- $.each(v, function(ii, vv) {
- html += '<option value="'+vv.product_id+'">'+vv.product_name+'</option>';
- });
- });
- // Append select options to step 2
- $('#product_tab_select_prod').append(html);
- }
- else {
- $.alert({
- title: 'No Products',
- content: 'No products were found matching this company.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- }
- });
- // Show step 2 dropdown
- $('#products_tab_select_prod_div').show();
- // Hide action buttons
- $('#products_tab_buttons').hide();
- });
- // Products tab step 2 (load action button from product)
- $('#product_tab_select_prod').on('change', function() {
- // Show action buttons
- $('#products_tab_buttons').show();
- });
- // Products tab submit view awaiting_approval product form
- $('.view_product').click(function() {
- // Get comp id / prod id
- comp_id_prod_id = $(this).attr('id');
- // Open new window with loaded company form
- window.location.href = '<?php echo base_url().index_page(); ?>survey/survey_form_edit_product/'+comp_id_prod_id;
- });
- // Products tab submit approve product
- $('.approve_product').click(function() {
- var $this = $(this);
- // Confirm approve product
- $.confirm({
- title: 'Approve Product?',
- content: 'Please confirm approval of this product.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- // Get comp id / prod id
- comp_id_prod_id = $($this).attr('id');
- // Fire ajax to approve company
- $.post("<?php echo base_url() . index_page(); ?>admin/approve_product", {comp_id_prod_id: comp_id_prod_id}).done(function(data) {
- if(data.revisions_exist == 'true') {
- $.alert({
- title: 'Product Revisions Exist',
- content: 'This product contains revisions. Please first complete any product revisions.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- return;
- }
- else if(data.update_message == 'fail') {
- $.alert({
- title: 'Product Approval Failed.',
- content: 'This product approval failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Product Approval Successful.',
- content: 'This product was approved successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // Products tab submit deactivate product
- $('#products_tab_submit_deactivate').click(function() {
- $.confirm({
- title: 'Deactivate Product?',
- content: 'This product is about to be deactivated.<br><br><textarea id="reason_rejected_text" style="width:100%;"></textarea>',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- comp_id = $('#products_tab_select_comp').val();
- prod_id = $('#product_tab_select_prod').val();
- reason_rejected = $(this.$b.find('#reason_rejected_text')).val();
- $.post("<?php echo base_url() . index_page(); ?>admin/deactivate_product", {comp_id: comp_id, prod_id: prod_id, reason_rejected: reason_rejected}).done(function(data) {
- if(data.update_message == 'fail') {
- $.alert({
- title: 'Product Update Failed.',
- content: 'This product update failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Product Update Successful.',
- content: 'This product was deactivated successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // Products tab submit reactivate product
- $('.reactivate_product').click(function() {
- var $this = $(this);
- $.confirm({
- title: 'Reactivate Product?',
- content: 'This product is about to be reactivated. Continue?',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- comp_id = $($this).val();
- prod_id = $($this).attr('id');
- $.post("<?php echo base_url() . index_page(); ?>admin/reactivate_product", {comp_id: comp_id, prod_id: prod_id}).done(function(data) {
- if(data.check_comp_status == 'inactive') {
- $.alert({
- title: 'Product Company Inactive',
- content: 'This products company is inactive. Please first reactivate the company; then products can be reactivated.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- return;
- }
- if(data.update_message == 'fail') {
- $.alert({
- title: 'Product Update Failed.',
- content: 'This product update failed. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- else if(data.update_message == 'success') {
- $.alert({
- title: 'Product Reactivation Successful.',
- content: 'This product was reactivated successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- window.location.reload(false);
- }
- });
- }
- });
- }
- });
- });
- // Products tab change product owner
- $('#products_tab_submit_change_owner').click(function() {
- // Fire ajax to get all company names
- $.post("<?php echo base_url() . index_page(); ?>admin/change_prod_owner_get_all_comps", {}).done(function(data) {
- $select = '<select id="change_prod_owner_select"><option value="">Select...</option>';
- $.each(data, function(i, v) {
- $select += '<option value="' + v.company_id + '">' + v.firm_name + '</option>';
- });
- $select += '</select>';
- $select += '<br /><br />';
- $select += '<div id="change_prod_owner_prod_fam_div"></div>';
- $.confirm({
- title: 'Change Product Owner',
- content: 'Select the new product owner:<br /><br />' + $select,
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirm: function(){
- // Get product id
- prod_id = $('#product_tab_select_prod').val();
- // Get new company id
- new_comp_id = this.$b.find('#change_prod_owner_select').val();
- // Get new product family id
- new_prod_fam_id = this.$b.find('#change_prod_owner_select_prod_fam').val();
- // Check to ensure a new company is selected
- if(comp_id == '') {
- $.alert({
- title: 'Select Company',
- content: 'Please select a new company to assign this product.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return false;
- }
- // Check to ensure product family is selected
- if(new_prod_fam_id == '') {
- $.alert({
- title: 'Select Product Family',
- content: 'Please select a product family for this product. One can be created in the Product Family tab if desired.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return false;
- }
- $data = {prod_id: prod_id, new_comp_id: new_comp_id, new_prod_fam_id: new_prod_fam_id};
- // Fire ajax to change product owner
- $.post("<?php echo base_url() . index_page(); ?>admin/change_prod_owner", $data).done(function(data) {
- if(data == 'success') {
- $.alert({
- title: 'Change Successful',
- content: 'The product owner was changed successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- // Reload page
- location.reload();
- }
- });
- }
- else {
- $.alert({
- title: 'Error',
- content: 'An error was encountered while changing this product owner. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- })
- });
- });
- // Bind click event on change product owner company select
- $(document).on('change', '#change_prod_owner_select', function() {
- // Get this company id
- comp_id = $(this).val();
- // Fire ajax to get all product families associated with this company
- $.post("<?php echo base_url() . index_page(); ?>admin/change_prod_owner_get_new_comp_prod_fams", {comp_id: comp_id}).done(function(data) {
- if(data) {
- $select = '<select id="change_prod_owner_select_prod_fam"><option value="">Select...</option>';
- $.each(data, function(i, v) {
- $select += '<option value="' + v.product_family_id + '">' + v.family_name + '</option>';
- });
- $select += '</select>';
- $('#change_prod_owner_prod_fam_div').html('Select the new product family:<br /><br />' + $select);
- }
- else {
- $('#change_prod_owner_prod_fam_div').html('No product families found for this company. No problem, one can be created later.');
- }
- });
- });
- // *****************************************************************************
- // Revisions Tab
- // *****************************************************************************
- // Revisions submit button
- $('#submit_admin_edits').click(function(e) {
- comp_select = $('#admin_select_company_edits').val();
- prod_select = $('#admin_select_product_edits').val();
- // Check if selects are empty
- if(comp_select === '' && prod_select === '') {
- $.alert({
- title: 'Select Company or Product',
- content: 'Please select a company or product to edit.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- // Check if both product and company are selected
- if(comp_select !== '' && prod_select !== '') {
- $.alert({
- title: 'Select Only One',
- content: 'Only one company or product may be edited at a time.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- // If editing a company
- if(comp_select !== '' && prod_select === '') {
- // Redirect to edit form page
- window.location.href = '<?php echo base_url() . index_page(); ?>survey/surveyform_edit_company/'+comp_select;
- }
- // If editing a product
- if(prod_select !== '' && comp_select === '') {
- // Have to post to ajax to get company id for url build
- $.post("<?php echo base_url() . index_page(); ?>admin/product_revisions", {prod_id: prod_select}).done(function(data) {
- if(data) {
- window.location.href = '<?php echo base_url() . index_page(); ?>survey/survey_form_edit_product/'+data.comp_id+'/'+prod_select;
- }
- else {
- console.log('Error with Ajax.');
- }
- });
- }
- });
- // Revision history populate product select
- $('#admin_select_company_revision_history').on('change', function() {
- comp_id = $(this).val();
- $append = '';
- // Populate product dropdown select
- $.post("<?php echo base_url() . index_page(); ?>admin/populate_product_revision_history_select", {comp_id: comp_id})
- .done(function (data) {
- $append += '<option value="">Select...</option>';
- $.each(data.revision_select_products, function(i, v) {
- $append += '<option value="'+v.product_id+'">'+v.product_name+'</option>';
- });
- $('#admin_select_product_revision_history').html('');
- $('#admin_select_product_revision_history').append($append);
- });
- // Clear revision history html
- $('#revisions_ajax_div').html('');
- // Clear pagination links
- $(".pagination").html('');
- // Clear date dropdown
- $('#revision_dates').html('');
- // Clear date title
- $('#date_changed_title').html('');
- });
- $('#admin_select_product_revision_history').on('change', function() {
- // Clear revision history html
- $('#revisions_ajax_div').html('');
- // Clear pagination links
- $(".pagination").html('');
- // Clear date dropdown
- $('#revision_dates').html('');
- // Clear date title
- $('#date_changed_title').html('');
- });
- // Set vars for company and product "pretty names" objects
- var prod_array = {"product_id":"","company_id":"Company Id","research_company_id":"Research Company ID","product_name":"Product Name","product_type_rating":"Product Type (Rating)","product_type_ranking":"Product Type (Ranking)","product_type_index":"Product Type (Index)","primary_audience_companies":"Primary Audience (Companies)","primary_audience_investors":"Primary Audience (Investors)","primary_audience_consumers":"Primary Audience (Consumers)","primary_audience_other":"Primary Audience (Other)","primary_audience_other_text":"Primary Audience (Other) Text","product_description":"Product Description","product_url_information":"Product URL Information","prod_external_platform":"External Platform","total_number_of_company":"Total Number of Companies","selection_criteria":"Selection Criteria","rating_scale":"Rating Scale","underlying_universe":"Underlying Universe","market_coverage_large_cap":"Market Coverage (Large Cap)","market_coverage_mid_cap":"Market Coverage (Mid Cap)","market_coverage_small_cap":"Market Coverage (Small Cap)","market_coverage_privately_held":"Market Coverage (Privately Held)","geographic_coverage_global":"Geographic Coverage (Global)","geographic_coverage_asia":"Geographic Coverage (Asia)","geographic_coverage_europe":"Geographic Coverage (Europe)","geographic_coverage_latin_america":"Geographic Coverage (Latin America)","geographic_coverage_us":"Geographic Coverage (US)","geographic_coverage_emerging_market":"Geographic Coverage (Emerging Market)","geographic_coverage_other":"Geographic Coverage (Other)","geographic_coverage_other_text":"Geographic Coverage (Other) Text","category_coverage_esg_combined":"Category Coverage (ESG Combined)","category_coverage_environmental":"Category Coverage (Environmental)","category_coverage_social":"Category Coverage (Social)","category_coverage_governance":"Category Coverage (Governance)","category_coverage_incorporates_financial":"Category Coverage (Incorporates Financial)","total_number_of_esg_issues_covered":"Total Number of ESG Issues Covered","social_issues_same_as_in_section_3":"Social Issues (Same as in Section 3)","social_issues_2":"Social Issues (Page 2)","environmental_issues_same_as_in_section_3":"Environmental Issues (Same as in Section 3)","environmental_issues_2":"Environmental Issues (Page 2)","governance_issues_same_as_in_section_3":"Governance Issues (Same as in Section 3)","governance_issues_2":"Governance Issues (Page 2)","other_issues_same_as_in_section_3":"Other Issues (Same as in Section 3)","other_issues_2":"Other Issues (Page 2)","total_number_of_esg_indicators_covered":"Total Number of ESG Indicators Covered","product_environmental":"Environmental Indicators","product_social":"Social Indicators","product_governance":"Governance Indicators","product_other":"Other Indicators","methodological_basis_user_defined":"Methodological Basis (Customized\/User-defined )","methodological_basis_disclosure_based":"Methodological Basis (Disclosure-based)","methodological_basis_performance_based":"Methodological Basis (Performance-based)","methodological_basis_trends_based":"Methodological Basis (Trends-based)","methodological_basis_goals_based":"Methodological Basis (Goals-based\/normative)","methodological_basis_sustainability_context":"Methodological Basis (Sustainability Context)","methodological_basis_sector_based":"Methodological Basis (Sector-based Comparison)","methodology_update_frequency_annual":"Methodology Update Frequency (Annual)","methodology_update_frequency_bi_annual":"Methodology Update Frequency (Bi-Annual)","methodology_update_frequency_quarterly":"Methodology Update Frequency (Quarterly)","methodology_update_frequency_monthly":"Methodology Update Frequency (Monthly)","methodology_update_frequency_as_needed":"Methodology Update Frequency (As Needed)","methodology_update_frequency_other":"Methodology Update Frequency (Other)","methodology_update_frequency_other_text":"Methodology Update Frequency (Other) Text","methodological_method_analyst_based":"Methodological Method (Analyst-based)","methodological_method_model_based":"Methodological Method (Model-based)","methodological_method_hybrid":"Methodological Method (Hybrid)","data_sources_company_disclosure":"Data Sources (Company Disclosure)","data_sources_company_direct_contact":"Data Sources (Company Direct Contact)","data_sources_ngo_disclosure":"Data Sources (CSO\/NGO Disclosure)","data_sources_ngo_direct_contact":"Data Sources (CSO\/NGO Direct Contact)","data_sources_trade_union_direct_contact":"Data Sources (Trade Union Direct Contact)","data_sources_trade_union_disclosure":"Data Sources (Trade Union Disclosure)","data_sources_media":"Data Sources (Media)","data_sources_government":"Data Sources (Government)","data_sources_esg_data_provider":"Data Sources (ESG Data Provider)","data_sources_other":"Data Sources (Other)","data_sources_other_text":"Data Sources (Other) Text","data_gaps_exclude_company_for_missing_data":"Data Gaps (Exclude company for missing data)","data_gaps_assign_company_failing_score_for_missing_data":"Data Gaps (Assign company failing score for missing data)","data_gaps_penalize_company_for_missing_data":"Data Gaps (Penalize company for missing data)","data_gaps_not_counted":"Data Gaps (Not counted)","data_gaps_substitute_industry_average_data":"Data Gaps (Substitute industry average data)","data_gaps_substitute_model_driven_data":"Data Gaps (Substitute model-driven data)","data_gaps_not_applicable":"Data Gaps (Not applicable)","data_gaps_other":"Data Gaps (Other)","data_gaps_other_text":"Data Gaps (Other) Text","eval_update_freq_annual":"Evaluation Update Frequency (Annual)","eval_update_freq_annual_text":"Evaluation Update Frequency (Annual) Text","eval_update_freq_bi_annual":"Evaluation Update Frequency (Bi-Annual)","eval_update_freq_bi_annual_text":"Evaluation Update Frequency (Bi-Annual) Text","eval_update_freq_quarterly":"Evaluation Update Frequency (Quarterly)","eval_update_freq_monthly":"Evaluation Update Frequency (Monthly)","eval_update_freq_ongoing":"Evaluation Update Frequency (Ongoing)","eval_update_freq_incidents_exception":"Evaluation Update Frequency (Controversies\/incidents exception)","eval_update_freq_other":"Evaluation Update Frequency (Other)","eval_update_freq_other_text":"Evaluation Update Frequency (Other) Text","controversies_supersesed_update_cycle":"Controversies\/Incidents (Supersede Update Cycle)","controversies_alert_service":"Controversies\/Incidents (Alert Service)","controversies_next_update_cycle":"Controversies\/Incidents (Next Update Cycle)","controversies_not_included":"Controversies\/Incidents (Not Included)","client_disclosure_issue_complete_list":"Client Disclosure (Issues - Complete List)","client_disclosure_issue_partial_list":"Client Disclosure (Issues - Partial List)","client_disclosure_indicator_complete_list":"Client Disclosure (Indicators - Complete List)","client_disclosure_indicator_partial_list":"Client Disclosure (Indicators - Partial List)","client_disclosure_rating_methodology":"Client Disclosure (Ratings Methodology)","client_disclosure_rating_model":"Client Disclosure (Ratings Model)","client_disclosure_data_source":"Client Disclosure (Data Source)","public_disclosure_issue_complete_list":"Public Disclosure (Issues - Complete List)","public_disclosure_issue_partial_list":"Public Disclosure (Issues - Partial List)","public_disclosure_indicators_complete_list":"Public Disclosure (Indicators - Complete List)","public_disclosure_indicators_partial_list":"Public Disclosure (Indicators - Partial List)","public_disclosure_ratings_methodology":"Public Disclosure (Ratings Methodology)","public_disclosure_ratings_model":"Public Disclosure (Ratings Model)","public_disclosure_sector_benchmarking_Report":"Public Disclosure (Sector Benchmarking Report)","public_disclosure_ratings_summary_with_company_eval":"Public Disclosure (Sector Benchmarking Report (with company evalution))","public_disclosure_data_source":"Public Disclosure (Data Source)","public_disclosure_profile_rating":"Public Disclosure (Profile\/Rating)","comp_disclosure_issue_complete_list_fee":"Related Company Disclosure (Issues - Complete List for a fee)","comp_disclosure_issue_complete_list_no_charge":"Related Company Disclosure (Issues - Complete List at no charge)","comp_disclosure_issue_partial_list_for_a_fee":"Related Company Disclosure (Issues - Partial List for a fee)","comp_disclosure_issue_partial_list_no_charge":"Related Company Disclosure (Issues - Partial List at no charge)","comp_disclosure_indicators_complete_list_for_a_fee":"Related Company Disclosure (Indicators - Complete List for a fee)","comp_disclosure_indicators_complete_list_no_charge":"Related Company Disclosure (Indicators - Complete List at no charge)","comp_disclosure_indicators_partial_list_for_a_fee":"Related Company Disclosure (Indicators - Partial List for a fee)","comp_disclosure_indicators_partial_list_no_charge":"Related Company Disclosure (Indicators - Partial List at no charge)","comp_disclosure_rating_methodology_for_a_fee":"Related Company Disclosure (Ratings Methodology for a fee)","comp_disclosure_rating_methodology_no_charge":"Related Company Disclosure (Ratings Methodology no charge)","comp_disclosure_rating_model_for_a_fee":"Related Company Disclosure (Ratings Model for a fee)","comp_disclosure_rating_model_no_charge":"Related Company Disclosure (Ratings Model at no charge)","comp_disclosure_data_source_no_charge":"Related Company Disclosure (Data Source for a fee)","comp_disclosure_data_source_for_a_fee":"Related Company Disclosure (Data Source at no charge)","comp_disclosure_individual_profile_rating_for_a_fee":"Related Company Disclosure (Individual Profile\/Rating for a fee)","comp_disclosure_individual_profile_Rating_at_no_charge":"Related Company Disclosure (Individual Profile\/Rating at no charge)","comp_disclosure_all_profile_rating_for_a_fee":"Related Company Disclosure (All Profiles\/Ratings for a fee)","comp_disclosure_all_profile_rating_at_no_charge":"Related Company Disclosure (All Profiles\/Ratings at no charge)","comp_disclosure_sector_bench_report_for_a_fee":"Related Company Disclosure (Sector Benchmarking Report for a fee)","comp_disclosure_sector_bench_report_at_no_charge":"Related Company Disclosure (Sector Benchmarking Report at no charge)","comp_disclosure_sector_bench_report_comp_evalua_for_a_fee":"Related Company Disclosure (Sector Benchmarking Report (with company evaluations) for a fee)","comp_disclosure_sector_bench_report_comp_evalua_at_no_charge":"Related Company Disclosure (Sector Benchmarking Report (with company evaluations) at no charge)","comp_disclosure_other":"Related Company Disclosure (Other)","comp_disclosure_other_text":"Related Company Disclosure (Other) Text","rated_comp_inter_responds_to_requests_for_assist_on_survey":"Rated Company Interaction (Rater responds to requests for assistance on survey\/questionnaire)","rated_comp_inter_offers_opport_to_review_on_rating":"Rated Company Interaction (Rater offers opportunity to review and comment on rating\/profile)","rated_comp_inter_assist_on_survey_before_finalized":"Rated Company Interaction (Rater offers opportunity to review and comment on rating\/profile before its finalized)","rated_comp_inter_has_protocol_to_address_grievances":"Rated Company Interaction (Rater has protocol\/policy to address errors or grievances)","rated_comp_inter_provide_url_brief_description":"Rated Company Interaction (Rater has protocol\/policy to address errors or grievances URL)","rated_comp_inter_rater_provides_free_feedback_to_improve_scorer":"Rated Company Interaction (Rater provides free feedback to improve\/enhance score and performance)","rated_comp_inter_rater_offers_advisory_services_for_a_fee":"Rated Company Interaction (Rater offers advisory services for a fee)","rated_comp_inter_rater_no_interaction":"Rated Company Interaction (No interaction)","rated_comp_inter_rater_other":"Rated Company Interaction (Other)","rated_comp_inter_rater_other_text":"Rated Company Interaction (Other) Text","survey_use_yes":"Survey Use (Yes)","survey_use_no":"Survey Use (No)","survey_cycle":"Survey Cycle","survey_cycle_date":"Survey Cycle Date","response_times":"Response Times","product_source_notes":"Source Notes (Page 1)","product_source_notes_2":"Source Notes (Page 2)","product_source_notes_3":"Source Notes (Page 3)","product_source_notes_4":"Source Notes (Page 4)","gisr_reviewed_product_yes":"GISR Reviewed (Yes)","gisr_reviewed_product_no":"GISR Reveiwed (No)","product_comments_question":"Comments\/Questions","owner_reviewed_product_yes":"Owner Reviewed (Yes)","owner_reviewed_product_no":"Owner Reviewed (No)","profile_complete_product_yes":"Profile Complete (Yes)","profile_complete_product_no":"Profile Complete (No)","prod_research_organization":"Research Organization","prod_add_res_providers":"Additional Research Providers","prod_company_name":"Company name","prod_date_completed":"Date Completed","prod_contact_info":"Contact Info","prod_added_by":"Added By","prod_edits_approved":"Edits Approved","prod_status":"Status","prod_status_reason":"Status Reason"};
- var comp_array = {"company_id":"Company ID","firm_name":"Firm Name","firm_logo":"Firm Logo","website":"Website","email_invest":"Email (Investors)","email_rated":"Email (Rated Company)","email_general":"Email (General)","headquarters":"Headquarters","phone_no":"Phone Number","agency_description":"Agency Description","esg_audience_companies":"ESG Audience (Companies)","esg_audience_investors":"ESG Audience (Investors)","esg_audience_consumers":"ESG Audience (Consumers)","esg_audience_government":"ESG Audience (Government)","esg_audience_other":"ESG Audience (Other)","esg_audience_other_text":"ESG Audience (Other) Text","coverage_environmental":"Coverage (Environmental)","coverage_social":"Coverage (Social)","coverage_governance":"Coverage (Governance)","coverage_other":"Coverage (Other)","coverage_other_text":"Coverage (Other) Text","esg_prod_ser_analytics":"ESG Products\/Services (Analytics)","esg_prod_ser_bespoke_research":"ESG Products\/Services (Bespoke Research)","esg_prod_ser_company_profiles_research":"ESG Products\/Services (Company Profiles\/Research )","esg_prod_ser_company_rankings":"ESG Products\/Services (Company Rankings)","esg_prod_ser_company_ratings":"ESG Products\/Services (Company Ratings)","esg_prod_ser_controversies_incidents_monitoring_alerts":"ESG Products\/Services (Controversies\/Incidents Monitoring & Alerts)","esg_prod_ser_country_analysis":"ESG Products\/Services (Country Analysis)","esg_prod_ser_corporate_engagement":"ESG Products\/Services (Corporate Engagement)","esg_prod_ser_datafeeds":"ESG Products\/Services (Datafeeds)","esg_prod_ser_dr_cr_fixed_income_esg_research_and_or_ratings":"ESG Products\/Services (Other Debit\/Credit - Fixed Income ESG Research and\/or Ratings)","esg_prod_ser_green_bonds":"ESG Products\/Services (Green Bonds)","esg_prod_ser_indices":"ESG Products\/Services (Indices)","esg_prod_ser_portfolio_analysis":"ESG Products\/Services (Portfolio Analysis)","esg_prod_ser_proxy_voting_research":"ESG Products\/Services (Proxy Voting Research)","esg_prod_ser_screening_restriction_management_services":"ESG Products\/Services (Screening\/Restriction Management Services)","esg_prod_ser_raw_data":"ESG Products\/Services (Raw Data)","distinguishing_characteristics":"Distinguishing Characteristics","aum_utilizing_agency_esg_prod_ser_less_than_1_million":"AUM Utilizing Agencys ESG Products\/Services (< $1 million)","aum_utilizing_agency_esg_prod_ser_bw_1_million_250_million":"AUM Utilizing Agencys ESG Products\/Services ($1 - $250 million)","aum_utilizing_agency_esg_prod_ser_bw_250_million_500_million":"AUM Utilizing Agencys ESG Products\/Services ($250 - 500 million)","aum_utilizing_agency_esg_prod_ser_greater_than_500_million":"AUM Utilizing Agencys ESG Products\/Services (> $500 million)","aum_utilizing_agency_esg_prod_ser_other":"AUM Utilizing Agencys ESG Products\/Services (Other)","date_founded":"Date Founded","key_milestones":"Key Milestones","ownership_structure":"Ownership Structure","business_partnerships":"Business Partnerships","academic_partnerships":"Academic Partnerships","significant_interests_in_other_companies":"Significant Interests in Other Companies","regional_offices":"Regional Offices","total_number_emp_fte":"Total Number of Employees (FTE)","directly_employed_permanent_fte":"(FTE) Directly Employed Permanently","total_number_emp_fte_esg_research_and_rating":"Total Number of Employees Research and Rating (FTERR)","directly_employed_permanent_fte_esg_research_and_rating":"(FTERR) Directly Employed Permanently","total_number_emp_fte_esg_research_analysts":"Total Number of Employees (FTERA)","directly_employed_permanent_fte_esg_research_analysts":"(FTERA) Directly Employed Permanently","additional_ESG_Products_Services_not_inc_at_a_glance":"Additional ESG Products\/Services not included in \"At A Glance\"","quality_assurance_arista_certified":"Quality Assurance (ARISTA Certified)","quality_assurance_iso":"Quality Assurance (ISO)","quality_assurance_other_third_party":"Quality Assurance (Other\/Third Party)","quality_assurance_other_third_party_text":"Quality Assurance (Other\/Third Party) Text","annual_reports_yes":"Annual Reports (Yes)","annual_reports_yes_text":"Annual Reports (Yes) Text","annual_reports_no":"Annual Reprts (No)","sustainability_report_yes":"Sustainability Reports (Yes)","sustainability_report_yes_text":"Sustainability Reports (Yes) Text","sustainability_report_no":"Sustainablility Reports (No)","code_of_conduct_yes":"Code of Conduct (Yes)","code_of_conduct_yes_text":"Code of Conduct (Yes) Text","code_of_conduct_no":"Code of Conduct (No)","Independence_policy_yes":"Indepedence Policy (Yes)","Independence_policy_yes_text":"Independence Policy (Yes) Text","Independence_policy_no":"Independence Policy (No)","materiality_single":"Materiality (Yes)","materiality_single_text":"Materiality (Yes) Text","materiality_multiple":"Materiality (No)","environmental_issue":"Environmental Issue","social_issue":"Social Issue","governance_issue":"Governance Issue","other_issue":"Other Issue","aum_utilizing_agency_esg_prod_ser_other_text":"AUM Utilizing Agencys ESG Products\/Services (Other) TEXT","added_by":"Added By","contact_info":"Contact Info","date_completed":"Date Completed","aum_utilizing_agency_esg_prod_ser_unknown":"","membership_pri":"Membership (PRI)","membership_arise":"Membership (ARISE)","membership_other":"Membership (Other)","membership_other_text":"Membership (Other) Text","quality_assurance_arista_certified_text":"Quality Assurance (ARISTA Certified) Text","quality_assurance_iso_text":"Quality Assurance (ISO) Text","annual_reports_publicly_available":"Annual Reports (Publicly Available)","sustainability_report_publicly_available":"Sustainability Reports (Publicly Available)","code_of_conduct_publicly_available":"Code of Conduct (Publicly Available)","Independence_policy_publicly_available":"Independence Policy (Publicly Available)","company_source_notes":"Company Source Notes","company_source_notes_2":"Company Source Notes (Page 2)","company_source_notes_3":"Company Source Notes (Page 3)","company_source_notes_4":"Company Source Notes (Page 4)","profile_compelete_yes":"Profile Complete (Yes)","profile_compelete_no":"Profile Complete (No)","owner_reviewed_yes":"Owner Reviewed (Yes)","owner_reviewed_no":"Owner Reviewed (No)","gisr_reviewed_yes":"GISR Reviewed (Yes)","gisr_reviewed_no":"GISR Reviewed (No)","comments_question":"Comments\/Questions","additional_esg_product_service":"Additional ESG Product\/Service","quality_assurance_company_profile":"Quality Assurance Company Profile","quality_assurance_company_profile_url":"Quality Assurance Company Profile URL","additional_esg_product_service_url":"Additional ESG Product\/Service URL","edits_approved":"Edits Approved","status":"Status","company_type":"Company Type","status_reason":"Status Reason"};
- // Load entire revision history
- $('#submit_admin_load_entire_revisions').click(function() {
- comp_id = $('#admin_select_company_revision_history').val();
- prod_id = $('#admin_select_product_revision_history').val();
- // Check if selects are empty
- if(comp_id === '' && prod_id === '') {
- $.alert({
- title: 'Select Company or Product',
- content: 'Please select a company or product to display revisions.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- // Fire ajax to get company/product revision history
- $.post("<?php echo base_url() . index_page(); ?>admin/get_entire_revision_history/"+comp_id+'/'+prod_id)
- .done(function (data) {
- // Reset page data
- $('#revisions_ajax_div').html('');
- $return = '';
- // Clear pagination links
- $(".pagination").html('');
- // Clear date dropdown
- $('#revision_dates').html('');
- // Clear date title
- $('#date_changed_title').html('');
- // Create placeholders
- $revision_id = '';
- $changed_by = '';
- $date_changed = '';
- $date_drop_array = [];
- $prod_or_comp = '';
- $prod_comp_id = '';
- $db_field_col_name = '';
- $old_value = '';
- $new_value = '';
- $approved = '';
- $reason_rejected = '';
- // If there are results to paginate
- if(data.company_product_revision_history) {
- $.each(data.company_product_revision_history, function (i, v) {
- $return += '<div class="revision_history_item">';
- $.each(v, function(ii, vv) {
- if(ii == 'revision_id') { $revision_id = vv; }
- if(ii == 'changed_by') { $changed_by = vv; }
- if(ii == 'moderated_by') { $moderated_by = vv; }
- if(ii == 'date_changed') { $date_changed = vv; }
- if(ii == 'prod_or_comp') { $prod_or_comp = vv; }
- if(ii == 'prod_comp_id') { $prod_comp_id = vv; }
- if(ii == 'db_field_col_name') {
- // If this value is in the company array
- if (vv in comp_array) { $db_field_col_name = comp_array[vv]; }
- // Else if this value is in the product array
- else if (vv in prod_array) { $db_field_col_name = prod_array[vv]; }
- // Else use default value
- else $db_field_col_name = vv;
- }
- if(ii == 'old_value') {
- if(vv == 'Y') $old_value = 'Yes';
- else if(vv == 'N') $old_value = 'No';
- else $old_value = vv;
- }
- if(ii == 'new_value') {
- if(vv == 'Y') $new_value = 'Yes';
- else if(vv == 'N') $new_value = 'No';
- else $new_value = vv;
- }
- if(ii == 'approved') {
- if(vv == 'rejected') vv = 'Rejected';
- if(vv == 'Y') vv = 'Approved';
- $approved = vv;
- }
- if(ii == 'reason_rejected') { $reason_rejected = vv; }
- });
- // Build each revision box
- $return += '<div style="width:65%;float:left;">';
- $return += '<div class="revision_db_field_name"><strong>Form Field:</strong> ' + $db_field_col_name + '</div>';
- $return += '<div class="revision_approved"><strong>Status:</strong> ' + $approved + '</div>';
- $return += '</div>';
- $return += '<div style="width:33%;float:right;">';
- $return += '<div class="revision_changed_by"><strong>Changed By:</strong> ' + $changed_by + '</div>';
- $return += '<div class="revision_changed_by"><strong>Moderated By:</strong> ' + $moderated_by + '</div>';
- $return += '<div class="revision_changed_by"><strong>Date Changed:</strong> ' + $date_changed + '</div>';
- $return += '</div>';
- $return += '<div style="clear:both;"></div>';
- $return += '<br />';
- $return += '<div class="revision_old_value"><strong>Old Value:</strong> ' + $old_value + '</div>';
- $return += '<br />';
- $return += '<div class="revision_new_value"><strong>New Value:</strong> ' + $new_value + '</div>';
- $return += '<br>';
- if($reason_rejected !== '' && $reason_rejected !== null) {
- $return += '<div class="revision_reason_rejected"><strong>Reason Rejected:</strong> ' + $reason_rejected + '</div>';
- }
- $return += '</div>';
- });
- // Populate ajax results div
- $('#revisions_ajax_div').hide().html($return).fadeIn();
- }
- else {
- // Clear revision html
- $html = 'There are no revisions for this item.';
- $('#revisions_ajax_div').html($html);
- // Clear pagination links
- $(".pagination").html('');
- // Clear date dropdown
- $('#revision_dates').html('');
- // Clear date title
- $('#date_changed_title').html('');
- }
- });
- });
- // Load paginated date revision history
- $('#submit_admin_load_revisions').click(function() {
- comp_id = $('#admin_select_company_revision_history').val();
- prod_id = $('#admin_select_product_revision_history').val();
- // Check if selects are empty
- if(comp_id === '' && prod_id === '') {
- $.alert({
- title: 'Select Company or Product',
- content: 'Please select a company or product to display revisions.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- return;
- }
- // Need to run ajax to get count needed for pagination
- $.post("<?php echo base_url() . index_page(); ?>admin/count_revision_pagination/"+comp_id+'/'+prod_id)
- .done(function (data) {
- // Build date dropdown array variable
- var $date_dropdown = [];
- $.each(data.date_dropdown, function(i, v) {
- $.each(v, function(ii, vv) {
- if(ii === 'date_changed')
- $date_dropdown.push(vv);
- });
- });
- // If there are results to paginate
- if(data.count !== 0) {
- // Paginate results
- paging = $(".pagination").paging(data.count, {
- format: "[< - nncn - >]",
- perpage: 1,
- onSelect: function (page) {
- var $start = this.slice[0];
- var $end = this.slice[1];
- data = {start: $start, end: $end};
- // Fire ajax to get company/product revision history
- $.post("<?php echo base_url() . index_page(); ?>admin/get_revision_history/"+comp_id+'/'+prod_id, data)
- .done(function (data) {
- // Reset page data
- $('#revisions_ajax_div').html('');
- $return = '';
- // Create placeholders
- $revision_id = '';
- $changed_by = '';
- $date_changed = '';
- $date_drop_array = [];
- $prod_or_comp = '';
- $prod_comp_id = '';
- $db_field_col_name = '';
- $old_value = '';
- $new_value = '';
- $approved = '';
- $reason_rejected = '';
- $.each(data.company_product_revision_history, function (i, v) {
- $return += '<div class="revision_history_item">';
- $.each(v, function(ii, vv) {
- if(ii == 'revision_id') { $revision_id = vv; }
- if(ii == 'changed_by') { $changed_by = vv; }
- if(ii == 'date_changed') { $date_changed = vv;}
- if(ii == 'moderated_by') { $moderated_by = vv; }
- if(ii == 'prod_or_comp') { $prod_or_comp = vv; }
- if(ii == 'prod_comp_id') { $prod_comp_id = vv; }if(ii == 'db_field_col_name') {
- // If this value is in the company array
- if (vv in comp_array) { $db_field_col_name = comp_array[vv]; }
- // Else if this value is in the product array
- else if (vv in prod_array) { $db_field_col_name = prod_array[vv]; }
- // Else use default value
- else $db_field_col_name = vv;
- }
- if(ii == 'old_value') {
- if(vv == 'Y') $old_value = 'Yes';
- else if(vv == 'N') $old_value = 'No';
- else $old_value = vv;
- }
- if(ii == 'new_value') {
- if(vv == 'Y') $new_value = 'Yes';
- else if(vv == 'N') $new_value = 'No';
- else $new_value = vv;
- }
- if(ii == 'approved') {
- if(vv == 'rejected') vv = 'Rejected';
- if(vv == 'Y') vv = 'Approved';
- $approved = vv;
- }
- if(ii == 'reason_rejected') { $reason_rejected = vv; }
- });
- // Build each revision box
- $return += '<div style="width:65%;float:left;">';
- $return += '<div class="revision_db_field_name"><strong>Form Field:</strong> ' + $db_field_col_name + '</div>';
- $return += '<div class="revision_approved"><strong>Status:</strong> ' + $approved + '</div>';
- $return += '</div>';
- $return += '<div style="width:33%;float:right;">';
- $return += '<div class="revision_changed_by"><strong>Changed By:</strong> ' + $changed_by + '</div>';
- $return += '<div class="revision_changed_by"><strong>Moderated By:</strong> ' + $moderated_by + '</div>';
- $return += '</div>';
- $return += '<div style="clear:both;"></div>';
- $return += '<br />';
- $return += '<div class="revision_old_value"><strong>Old Value:</strong> ' + $old_value + '</div>';
- $return += '<br />';
- $return += '<div class="revision_new_value"><strong>New Value:</strong> ' + $new_value + '</div>';
- $return += '<br>';
- if($reason_rejected !== '' && $reason_rejected !== null) {
- $return += '<div class="revision_reason_rejected"><strong>Reason Rejected:</strong> ' + $reason_rejected + '</div>';
- }
- $return += '</div>';
- });
- // Populate ajax results div
- $('#revisions_ajax_div').hide().html($return).fadeIn();
- // Populate date dropdown
- $date_drop = '<select name="select_revision_date" id="select_revision_date">';
- $date_drop += '<option value="">Select Date...</option>';
- $.each($date_dropdown, function(i, v) {
- // Reformat date display
- months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
- date = new Date(v);
- month = date.getMonth();
- day = date.getDate();
- year = date.getFullYear();
- $date_drop += '<option value="'+i+'">'+months[month] + ' ' + day + ', ' + year+'</option>';
- });
- $date_drop += '</select>';
- $('#revision_dates').html($date_drop);
- // Reformat date display
- months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
- date = new Date($date_changed);
- month = date.getMonth();
- long_day = date.getDay();
- day = date.getDate();
- year = date.getFullYear();
- // Populate "date changed" heading
- $('#date_changed_title').hide().html('<strong>Date Changed:</strong> ' + days[long_day] + ', ' + months[month] + ' ' + day + ', ' + year).fadeIn();
- });
- },
- onFormat: function (type) {
- switch (type) {
- case 'block':
- if (!this.active)
- return '<span class="disabled">' + this.value + '</span>';
- else if (this.value != this.page)
- return '<em><a href="#' + this.value + '">' + this.value + '</a></em>';
- return '<span class="current">' + this.value + '</span>';
- case 'next':
- if (this.active)
- return '<a href="#' + this.value + '" class="next" title="Next">Next ></a>';
- return '<span class="disabled">Next ></span>';
- case 'prev':
- if (this.active)
- return '<a href="#' + this.value + '" class="prev" title="Previous">< Prev</a>';
- return '<span class="disabled">< Prev</span>';
- case 'first':
- if (this.active)
- return '<a href="#' + this.value + '" class="first" title="first">|<<</a>';
- return '<span class="disabled">|<<</span>';
- case 'last':
- if (this.active)
- return '<a href="#' + this.value + '" class="last" title="Last">>>|</a>';
- return '<span class="disabled">>>|</span>';
- case "leap":
- if (this.active)
- return "...";
- return "";
- case 'fill':
- if (this.active)
- return " - ";
- return "";
- }
- }
- });
- }
- // Else there are no results to paginate
- else {
- // Clear revision html
- $html = 'There are no revisions for this item.';
- $('#revisions_ajax_div').html($html);
- // Clear pagination links
- $(".pagination").html('');
- // Clear date dropdown
- $('#revision_dates').html('');
- // Clear date title
- $('#date_changed_title').html('');
- }
- });
- });
- // Select revision date click function
- $(document).on('change', '#select_revision_date', function(e) {
- $page = parseInt($(this).val(), 10) + 1;
- paging.setPage($page);
- });
- // *****************************************************************************
- // Permissions Tab
- // *****************************************************************************
- // Save permissions
- $('#save_permissions').click(function() {
- // Get input values
- view_comp_profiles = $('#view_comp_profiles').val();
- view_prod_profiles = $('#view_prod_profiles').val();
- view_prod_summaries = $('#view_prod_summaries').val();
- perform_searches = $('#perform_searches').val();
- perform_adv_searches = $('#perform_adv_searches').val();
- view_prod_comp_comparisons = $('#view_prod_comp_comparisons').val();
- export_search_results = $('#export_search_results').val();
- $.ajax({
- type: "POST",
- url: '<?php echo base_url() . index_page(); ?>admin/save_permissions',
- data: {view_comp_profiles: view_comp_profiles, view_prod_profiles: view_prod_profiles, view_prod_summaries: view_prod_summaries, perform_searches: perform_searches, perform_adv_searches: perform_adv_searches, view_prod_comp_comparisons: view_prod_comp_comparisons, export_search_results: export_search_results},
- success: function(data){
- if(data.status == 'success') {
- $.alert({
- title: 'Permissions Saved',
- content: 'The user permissions have been saved successfully.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-info'
- });
- }
- if(data.status == 'update_failed') {
- $.alert({
- title: 'Update Error',
- content: 'An error was encountered while updating user permissions. Please contact a system administrator.',
- columnClass: 'col-md-4 col-md-offset-4',
- confirmButtonClass: 'btn-danger'
- });
- }
- }
- });
- });
- // *****************************************************************************
- // Product Family Lookup Tab
- // *****************************************************************************
- var add_new_prod_form = '';
- var edit_prod_fam_form = '';
- // Dropdown change when selecting company
- $('#prod_fam_comp_select').on('change', function() {
- // Clear any appended items in step 2
- $('#prod_fam_prod_fam_select').html('');
- // Clear any appended items in product list
- $('#prod_fam_product_list').html('');
- // Get company id
- comp_id = $(this).val();
- // Fire ajax to get associated product families (select options for step 2)
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_get_produt_families_ajax", {comp_id: comp_id}).done(function(data) {
- // Build assocaited produt family list
- html = '<option value="">Select...</option>';
- $.each(data, function(i, v) {
- if(v)
- $.each(v, function(ii, vv) {
- html += '<option value="'+vv.product_family_id+'">'+vv.family_name+'</option>';
- });
- });
- // Append select options to product family dropdown
- $('#prod_fam_prod_fam_select').append(html);
- });
- // If this value is empty ("select..."); hide phase 2 & 3
- if(comp_id == '') {
- // Hide product family select div
- $('#prod_fam_prod_fam_select_div').hide();
- // Hide product select dropdown div
- $('#prod_fam_product_select_div').hide();
- // Hide company products div
- $('#prod_fam_fam_products_div').hide();
- }
- else {
- // Show product family select div
- $('#prod_fam_prod_fam_select_div').show();
- // Show product select dropdown div
- $('#prod_fam_product_select_div').show();
- // Hide company products div
- $('#prod_fam_fam_products_div').hide();
- }
- });
- // Dropdown change when selecting product family
- $('#prod_fam_prod_fam_select').on('change', function() {
- // Show company products div
- $('#prod_fam_fam_products_div').show();
- // Get product family id
- fam_id = $('#prod_fam_prod_fam_select').val();
- // Define return variable
- var $html = '';
- // Fire ajax to get products associcated with product family id
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_get_product_list", {fam_id: fam_id}).done(function(data) {
- // If no results were found
- if(data == 'no_results') {
- $html += 'No results found.';
- }
- // Else results were found
- else {
- $html += '<table><tbody>';
- // Loop each result set and grab data
- $.each(data, function(i, v) {
- $html += '<tr><td>' + v.product_name + '</td>' +
- '<td><span class="remove_product_from_family_list">Remove</span><span class="product_id" style="display:none;">' + v.product_id + '</span></td></tr>';
- });
- $html += '</tbody></table>';
- }
- // Populate product list
- $('#prod_fam_product_list').html($html);
- });
- });
- // Add new product family
- $('#add_new_prod_family').click(function() {
- <?php
- // Get all company (name and id) for research company dropdown
- $sql = "SELECT * FROM company_profile ORDER BY firm_name ASC";
- $query = $this->Comman_crud->custom_query($sql);
- $all_comps = isset($query) ? (array)$query : array();
- ?>
- // Convert php results to json
- all_comps = <?php echo json_encode($all_comps) ?>;
- research_company_options = '';
- // Loop each company and build select list
- $.each(all_comps, function(i, v) {
- research_company_options += '<option value="'+v.company_id+'">'+v.firm_name+'</option>';
- });
- // Add new produt family form
- $content_add_prod_fam =
- 'Use the form below to create a new product family.<br><br>' +
- '<div>' +
- '<table style="display:block;">' +
- '<tbody>' +
- '<tr>' +
- '<td>Family Name</td>' +
- '<td><input type="text" id="family_name" style="width:100%;" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family URL</td>' +
- '<td><input type="text" id="family_url" style="width:100%;" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family Description</td>' +
- '<td><input type="text" id="family_description" style="width:100%;" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Number of Products</td>' +
- '<td><input type="text" id="num_products" style="width:100%;" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family Issue Coverage</td>' +
- '<td>' +
- '<select id="family_issue_coverage" style="width:100%;">' +
- '<option value="">Select...</option>' +
- '<option value="E">Environmental</option>' +
- '<option value="S">Social</option>' +
- '<option value="G">Governance</option>' +
- '<option value="ES">Environmental & Social</option>' +
- '<option value="EG">Environmental & Governance</option>' +
- '<option value="SG">Social & Governance</option>' +
- '<option value="ESG">Environmental, Social & Governance</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Product Type</td>' +
- '<td>' +
- '<select id="product_type" style="width:100%;">' +
- '<option value="">Select...</option>' +
- '<option value="index">Index</option>' +
- '<option value="ranking">Ranking</option>' +
- '<option value="rating">Rating</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Target Audience</td>' +
- '<td>' +
- '<select id="target_audience" style="width:100%;">' +
- '<option value="">Select...</option>' +
- '<option value="consumers">Consumers</option>' +
- '<option value="investors">Investors</option>' +
- '<option value="companies">Companies</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Number of Companies Covered</td>' +
- '<td><input type="text" id="num_companies_covered" style="width:100%;" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Research Company</td>' +
- '<td>' +
- '<select id="research_company_id" style="max-width:300px;">' +
- '<option value="">Select...</option>' +
- research_company_options +
- '</select>' +
- '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>' +
- '</div>'
- ;
- // Add new product family alert
- add_new_prod_form = $.confirm({
- title: 'Create Product Family',
- content: $content_add_prod_fam,
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Save Product Family',
- confirm: function() {
- // Get form values
- var family_name = this.$b.find('#family_name').val();
- var family_url = this.$b.find('#family_url').val();
- var family_description = this.$b.find('#family_description').val();
- var num_products = this.$b.find('#num_products').val();
- var family_issue_coverage = this.$b.find('#family_issue_coverage').val();
- var product_type = this.$b.find('#product_type').val();
- var target_audience = this.$b.find('#target_audience').val();
- var num_companies_covered = this.$b.find('#num_companies_covered').val();
- var research_company_id = this.$b.find('#research_company_id').val();
- var company_id = $('#prod_fam_comp_select').val();
- // Ensure no form values are empty
- if(family_name == '' || family_url == '' || family_description == '' || num_products == '' || family_issue_coverage == '' || product_type == '' || target_audience == '' || num_companies_covered == '' || research_company_id == '') {
- // Alert user all fields are required
- $.alert({
- title: 'Fields Incomplete',
- content: 'All fields are required for submission.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- return false;
- }
- // Ensure product family name does not already exist (associated with company id) (can have two product families with same name - as long as company is different)
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_add_new_check_fam_name", {family_name: family_name, company_id: company_id}).done(function(data) {
- // If this product family name exists
- if(data == 'true') {
- // Alert user product family name exists
- $.alert({
- title: 'Product Family Name Exists',
- content: 'This product family name already exists for this company. Please enter a unique product family name.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- // Else we are good to save
- else {
- // Save new product family
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_save_new_prod_fam", {family_name: family_name, family_url: family_url, family_description: family_description, num_products: num_products, family_issue_coverage: family_issue_coverage, product_type: product_type, target_audience: target_audience, num_companies_covered: num_companies_covered, research_company_id: research_company_id, company_id: company_id}).done(function(data) {
- // If product family was added successfully
- if(data == 'success') {
- // Alert product family saved successfully
- $.alert({
- title: 'Product Family Saved',
- content: 'This product family has been saved successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- // Close form
- add_new_prod_form.close();
- // Reload page
- location.reload();
- }
- });
- }
- else if(data == 'fail') {
- // Alert product family saved successfully
- $.alert({
- title: 'Product Family Save Fail',
- content: 'An error was encountered while saving this product family. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- // Keep original dialog open (must be closed manually)
- return false;
- }
- });
- });
- // Edit product family
- $('#edit_prod_family').click(function() {
- // Get product family id
- prod_fam_id = $('#prod_fam_prod_fam_select').val();
- // If a product family is not selected
- if(prod_fam_id == '') {
- // Alert product family not selected
- $.alert({
- title: 'Product Family Not Selected',
- content: 'Please select a product family to edit.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- return false;
- }
- // Get product family info from database
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_get_prod_fam_info", {prod_fam_id: prod_fam_id}).done(function(data) {
- // If a result was returned
- if(data !== '') {
- <?php
- // Get all company (name and id) for research company dropdown
- $sql = "SELECT * FROM company_profile ORDER BY firm_name ASC";
- $query = $this->Comman_crud->custom_query($sql);
- $all_comps = isset($query) ? (array)$query : array();
- ?>
- // Convert php results to json
- all_comps = <?php echo json_encode($all_comps) ?>;
- research_company_options = '';
- // Loop each (research) company and build select list
- $.each(all_comps, function(i, v) {
- // If this company id = returned data research company id
- selected = v.company_id == data.results.research_company_id ? 'selected="selected"' : '';
- research_company_options += '<option value="'+v.company_id+'" ' + selected + '>'+v.firm_name+'</option>';
- });
- // Set from select values
- fia_default = data.results.family_issue_converage == "" ? 'selected="selected"' : '';
- fia_E = data.results.family_issue_converage == "E" ? 'selected="selected"' : '';
- fia_S = data.results.family_issue_converage == "S" ? 'selected="selected"' : '';
- fia_G = data.results.family_issue_converage == "G" ? 'selected="selected"' : '';
- fia_ES = data.results.family_issue_converage == "ES" ? 'selected="selected"' : '';
- fia_EG = data.results.family_issue_converage == "EG" ? 'selected="selected"' : '';
- fia_SG = data.results.family_issue_converage == "SG" ? 'selected="selected"' : '';
- fia_ESG = data.results.family_issue_converage == "ESG" ? 'selected="selected"' : '';
- pt_default = data.results.product_type == "" ? 'selected="selected"' : '';
- pt_index = data.results.product_type == "index" ? 'selected="selected"' : '';
- pt_ranking = data.results.product_type == "ranking" ? 'selected="selected"' : '';
- pt_rating = data.results.product_type == "rating" ? 'selected="selected"' : '';
- ta_default = data.results.target_audience == "" ? 'selected="selected"' : '';
- ta_consumers = data.results.target_audience == "consumers" ? 'selected="selected"' : '';
- ta_investors = data.results.target_audience == "investors" ? 'selected="selected"' : '';
- ta_companies = data.results.target_audience == "companies" ? 'selected="selected"' : '';
- // Build edit form
- // Add new produt family form
- $content_edit_prod_fam_form =
- 'Use the form below to edit this product family.<br><br>' +
- '<div>' +
- '<table style="display:block;">' +
- '<tbody>' +
- '<tr>' +
- '<td>Family Name</td>' +
- '<td><input type="text" id="family_name" style="width:100%;" value="'+data.results.family_name+'" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family URL</td>' +
- '<td><input type="text" id="family_url" style="width:100%;" value="'+data.results.family_url+'" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family Description</td>' +
- '<td><input type="text" id="family_description" style="width:100%;" value="'+data.results.family_description+'" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Number of Products</td>' +
- '<td><input type="text" id="num_products" style="width:100%;" value="'+data.results.num_products+'" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Family Issue Coverage</td>' +
- '<td>' +
- '<select id="family_issue_coverage" style="width:100%;">' +
- '<option value="" ' + fia_default + '>Select...</option>' +
- '<option value="E" ' + fia_E + '>Environmental</option>' +
- '<option value="S" ' + fia_S + '>Social</option>' +
- '<option value="G" ' + fia_G + '>Governance</option>' +
- '<option value="ES" ' + fia_ES + '>Environmental & Social</option>' +
- '<option value="EG" ' + fia_EG + '>Environmental & Governance</option>' +
- '<option value="SG" ' + fia_SG + '>Social & Governance</option>' +
- '<option value="ESG" ' + fia_ESG + '>Environmental, Social & Governance</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Product Type</td>' +
- '<td>' +
- '<select id="product_type" style="width:100%;">' +
- '<option value="" ' + pt_default + '>Select...</option>' +
- '<option value="index" ' + pt_index + '>Index</option>' +
- '<option value="ranking" ' + pt_ranking + '>Ranking</option>' +
- '<option value="rating" ' + pt_rating + '>Rating</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Target Audience</td>' +
- '<td>' +
- '<select id="target_audience" style="width:100%;">' +
- '<option value="" ' + ta_default + '>Select...</option>' +
- '<option value="consumers" ' + ta_consumers + '>Consumers</option>' +
- '<option value="investors" ' + ta_investors + '>Investors</option>' +
- '<option value="companies" ' + ta_companies + '>Companies</option>' +
- '</select>' +
- '</td>' +
- '</tr>' +
- '<tr>' +
- '<td>Number of Companies Covered</td>' +
- '<td><input type="text" id="num_companies_covered" style="width:100%;" value="'+data.results.num_companies_covered+'" /></td>' +
- '</tr>' +
- '<tr>' +
- '<td>Research Company</td>' +
- '<td>' +
- '<select id="research_company_id" style="max-width:300px;">' +
- '<option value="">Select...</option>' +
- research_company_options +
- '</select>' +
- '</td>' +
- '</tr>' +
- '</tbody>' +
- '</table>' +
- '</div>'
- ;
- }
- // Edit product family alert
- edit_prod_fam_form = $.confirm({
- title: 'Update Product Family',
- content: $content_edit_prod_fam_form,
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Update Product Family',
- confirm: function() {
- // Get form values
- var family_name = this.$b.find('#family_name').val();
- var family_url = this.$b.find('#family_url').val();
- var family_description = this.$b.find('#family_description').val();
- var num_products = this.$b.find('#num_products').val();
- var family_issue_coverage = this.$b.find('#family_issue_coverage').val();
- var product_type = this.$b.find('#product_type').val();
- var target_audience = this.$b.find('#target_audience').val();
- var num_companies_covered = this.$b.find('#num_companies_covered').val();
- var research_company_id = this.$b.find('#research_company_id').val();
- var company_id = $('#prod_fam_comp_select').val();
- var product_family_id = $('#prod_fam_prod_fam_select').val();
- // Ensure no form values are empty
- if(family_name == '' || family_url == '' || family_description == '' || num_products == '' || family_issue_coverage == '' || product_type == '' || target_audience == '' || num_companies_covered == '' || research_company_id == '') {
- // Alert user all fields are required
- $.alert({
- title: 'Fields Incomplete',
- content: 'All fields are required for submission.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- return false;
- }
- // Update product family
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_update_prod_fam", {family_name: family_name, family_url: family_url, family_description: family_description, num_products: num_products, family_issue_coverage: family_issue_coverage, product_type: product_type, target_audience: target_audience, num_companies_covered: num_companies_covered, research_company_id: research_company_id, company_id: company_id, product_family_id: product_family_id}).done(function(data) {
- // If product family was added successfully
- if(data == 'success') {
- // Alert user product family updated
- $.alert({
- title: 'Product Family Updated',
- content: 'This product family was updated successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- }
- else {
- // Alert user product family update failed
- $.alert({
- title: 'Product Family Update Failed',
- content: 'An error was encounted while updating this product family. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- }
- // Close form
- edit_prod_fam_form.close();
- });
- // Keep original dialog open (must be closed manually)
- return false;
- }
- });
- });
- });
- // Deactivate product family
- $('#deacivate_prod_family').click(function() {
- var product_family_id = $('#prod_fam_prod_fam_select').val();
- // If product family id is empty
- if(product_family_id == '') {
- // Alert user product family not selected
- $.alert({
- title: 'Select Product Family',
- content: 'A product family must first be selected.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- return false;
- }
- $.confirm({
- title: 'Deactivate Product Family',
- content: 'This product family will be deactivated. All associated products will also be deactivated.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Deactivate',
- confirm: function() {
- // Fire ajax to deactivate product family
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_deactivate_fam_prod", {product_family_id: product_family_id}).done(function(data) {
- // If family product was deactivated successfully
- if(data == 'success') {
- // Alert user product family deactivated
- $.alert({
- title: 'Product Family Deactivated',
- content: 'This product family was deacivated successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- // Reload page
- location.reload();
- }
- });
- }
- else {
- // Alert user family product deactivated failed
- $.alert({
- title: 'Product Family Deactivation Failed',
- content: 'An error was encounted while deactivating this family product. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- });
- // Reactivate product family
- $(document).on('click', '.reactivate_product_family', function() {
- // Get product family id
- product_family_id = $(this).attr('id');
- $.confirm({
- title: 'Reactivate Product Family',
- content: 'This product family will be Reactivated.<br /><br />Should all associated products also be reactivated?<br /><table style="display:block;"><tbody><tr><td><input type="checkbox" id="reactivate_all_prods" /></td><td style="vertical-align:bottom;">Yes</td></tr></tbody></table>',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Reactivate',
- confirm: function() {
- // Check if reactivating all products
- reactivate_all_prods = this.$b.find('#reactivate_all_prods').is(':checked') ? 'true' : 'false';
- // Fire ajax to reactivate product family (and products)
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_reactivate_fam_prod", {product_family_id: product_family_id, reactivate_all_prods: reactivate_all_prods}).done(function(data) {
- // If family product was reactivated successfully
- if(data == 'success') {
- // Alert user product family reactivated
- $.alert({
- title: 'Product Family Reactivated',
- content: 'This product family was reactivated successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- // Reload page
- location.reload();
- }
- });
- }
- else {
- // Alert user family product reactivated failed
- $.alert({
- title: 'Product Family Reactivation Failed',
- content: 'An error was encounted while reactivating this family product. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- });
- // Remove product from product list
- $(document).on('click', '.remove_product_from_family_list', function() {
- var $this = $(this);
- // Confirm remove product from product family
- $.confirm({
- title: 'Remove Product Family',
- content: 'This action will remove the product family associated with this product.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Remove Family',
- confirm: function() {
- // Get product id
- prod_id = $($this).siblings('.product_id').text();
- // Get product family id
- prod_fam_id = $('#prod_fam_prod_fam_select').val();
- // Fire ajax to delete product family id
- $.post("<?php echo base_url() . index_page(); ?>admin/prod_fam_delete_prod_fam_id", {prod_id: prod_id, prod_fam_id: prod_fam_id}).done(function(data) {
- if(data == 'success') {
- // Alert product family removed
- $.alert({
- title: 'Product Family Removed',
- content: 'This products family was removed successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- confirm: function() {
- // Remove tr row
- $($this).parent().parent().remove();
- }
- });
- }
- else {
- // Alert error removing product family
- $.alert({
- title: 'Product Family Removal Failed',
- content: 'An error was encounted while reactivating this products family. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- });
- // Add product to family
- $('#add_prod_to_fam').click(function() {
- // Get product family id
- prod_fam_id = $('#prod_fam_prod_fam_select').val();
- // Get company id
- comp_id = $('#prod_fam_comp_select').val();
- // If a product family is not selected
- if(prod_fam_id == '') {
- // Alert product family not selected
- $.alert({
- title: 'Product Family Not Selected',
- content: 'Please select a product family.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- return false;
- }
- // Fire ajax to get all products assocaited with company
- $.post("<?php echo base_url() . index_page(); ?>admin/get_all_prods_add_to_family", {comp_id: comp_id}).done(function(data) {
- // Create html to return to form
- var $html = '';
- if(data == 'no_results') {
- $html += 'No results found.';
- }
- else {
- $html += '<table><tbody>';
- $.each(data, function(i, v) {
- // Check if this family has a name
- fam_name = v.pfl_family_name ? v.pfl_family_name : '<span style="color:red;">None Assigned</span>';
- $html += '<tr><td><strong>Product Name:</strong> ' + v.product_name + '<br /><strong>Current Product Family:</strong> ' + fam_name + '</td>' +
- '<td>' +
- '<span class="add_product_to_family">Add</span>' +
- '<span class="add_product_to_family_prod_id" style="display:none;">' + v.product_id + '</span>' +
- '<span class="add_product_to_family_prod_fam_id_orig" style="display:none;">' + v.product_family_id + '</span>';
- '</td></tr>';
- });
- $html += '</tbody></table>';
- }
- $.alert({
- title: 'Select Product',
- content: 'Select a product to add to this product family.<br /><br />' + $html,
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger close_main_add_prod_to_fam_overlay',
- confirmButton: 'Cancel'
- });
- });
- });
- // Bind to add product button
- $(document).on('click', '.add_product_to_family', function() {
- var $this_add_product = $(this);
- // Confirm add product to product family
- $.confirm({
- title: 'Add Product to Family',
- content: 'This action will add this product to the currently selected product family.<br /><br />If this product is already tied to another product family; the product will be removed from that product family, and tied to this one.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Add Product',
- confirm: function() {
- // Get product id
- prod_id = $($this_add_product).siblings('.add_product_to_family_prod_id').text();
- // Get original product family id (from hidden span)
- prod_fam_id_orig = $($this_add_product).siblings('.add_product_to_family_prod_fam_id_orig').text();
- // Get new product family id (from selection)
- prod_fam_id_new = $('#prod_fam_prod_fam_select').val();
- // Fire ajax to adjust products family association
- $.post("<?php echo base_url() . index_page(); ?>admin/add_product_to_product_family", {prod_id: prod_id, prod_fam_id_orig: prod_fam_id_orig, prod_fam_id_new: prod_fam_id_new}).done(function(data) {
- if(data == 'success') {
- // Alert product added to product family
- $.alert({
- title: 'Product Added to Family',
- content: 'This product was successfully added to the product family.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- }
- else {
- // Alert error adding product to family
- $.alert({
- title: 'Product Family Addition Failed',
- content: 'An error was encounted while adding this product to the product family. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- // Close main dialog
- $('.close_main_add_prod_to_fam_overlay').click();
- // Refresh family product list
- $('#prod_fam_prod_fam_select').change();
- });
- }
- });
- });
- // *****************************************************************************
- // Data Fields Tab
- // *****************************************************************************
- // Show/hid divs
- $('#add_edit_comp_toggle').click(function() {
- $('.add_edit_comp_div').slideToggle();
- // Adjust class to keep active
- if($(this).hasClass('data_fields_active')) {
- $(this).removeClass('data_fields_active');
- }
- else {
- $(this).addClass('data_fields_active');
- }
- });
- $('#add_edit_prod_toggle').click(function() {
- $('.add_edit_prod_div').slideToggle();
- // Adjust class to keep active
- if($(this).hasClass('data_fields_active')) {
- $(this).removeClass('data_fields_active');
- }
- else {
- $(this).addClass('data_fields_active');
- }
- });
- $('#comp_profile_toggle').click(function() {
- $('.comp_profile_div').slideToggle();
- // Adjust class to keep active
- if($(this).hasClass('data_fields_active')) {
- $(this).removeClass('data_fields_active');
- }
- else {
- $(this).addClass('data_fields_active');
- }
- });
- $('#prod_profile_toggle').click(function() {
- $('.prod_profile_div').slideToggle();
- // Adjust class to keep active
- if($(this).hasClass('data_fields_active')) {
- $(this).removeClass('data_fields_active');
- }
- else {
- $(this).addClass('data_fields_active');
- }
- });
- // Save data fields
- $('.save_data_fields').click(function() {
- // Get all add/edit company fields
- data_fields_add_edit_comp = {};
- // Get all add/edit product fields
- data_fields_add_edit_prod = {};
- // Get all company profile fields
- data_fields_comp_profile = {};
- // Get all product profile fields
- data_fields_prod_profile = {};
- // Loop each add/edit company field and create object
- $.each($('.textarea_data_field.add_edit_comp'), function(i, v) {
- data_fields_add_edit_comp[$(this).attr('id')] = $(this).val();
- });
- // Loop each add/edit product field and create object
- $.each($('.textarea_data_field.add_edit_prod'), function(i, v) {
- data_fields_add_edit_prod[$(this).attr('id')] = $(this).val();
- });
- // Loop each company profile field and create object
- $.each($('.textarea_data_field.comp_profile'), function(i, v) {
- data_fields_comp_profile[$(this).attr('id')] = $(this).val();
- });
- // Loop each product profile field and create object
- $.each($('.textarea_data_field.prod_profile'), function(i, v) {
- data_fields_prod_profile[$(this).attr('id')] = $(this).val();
- });
- // Fire ajax to update options
- $.post("<?php echo base_url() . index_page(); ?>admin/save_data_fields", {data_fields_add_edit_comp: data_fields_add_edit_comp, data_fields_add_edit_prod: data_fields_add_edit_prod, data_fields_comp_profile: data_fields_comp_profile, data_fields_prod_profile: data_fields_prod_profile}).done(function(data) {
- // If data fields were updated successfully
- if(data == 'success') {
- // Alert user data fields updated
- $.alert({
- title: 'Data Fields Updated',
- content: 'The data fields were updated successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- }
- else {
- // Alert user data fields update failed
- $.alert({
- title: 'Data Fields Update Failed',
- content: 'An error was encountered while updating the data fields. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- });
- // *****************************************************************************
- // Misc Tab
- // *****************************************************************************
- // Company pdf populate filename
- $("#upload_comp_pdf_button").on("change", function () {
- // Show filename and remove fields
- $('.upload_comp_pdf_filename').show();
- // Name of file and placeholder
- file = this.files[0].name;
- dflt = $(this).attr("placeholder");
- if ($(this).val() != "") {
- $(this).siblings('.upload_comp_pdf_filename').text(file);
- } else {
- $(this).siblings('.upload_comp_pdf_filename').text('');
- }
- });
- // Product pdf populate filename
- $("#upload_prod_pdf_button").on("change", function () {
- // Show filename and remove fields
- $('.upload_prod_pdf_filename').show();
- // Name of file and placeholder
- file = this.files[0].name;
- dflt = $(this).attr("placeholder");
- if ($(this).val() != "") {
- $(this).siblings('.upload_prod_pdf_filename').text(file);
- } else {
- $(this).siblings('.upload_prod_pdf_filename').text('');
- }
- });
- // Upload guidance
- $('#save_pdf_guidance').click(function() {
- // Block page
- $.blockUI({message: 'Please wait while files are checked and uploaded...'});
- // Check if no files are set
- var comp_file = $('#upload_comp_pdf_button').val();
- var prod_file = $('#upload_prod_pdf_button').val();
- if(comp_file == '' && prod_file == '') {
- $.alert({
- title: 'No Files to Upload',
- content: 'Please select a company or product pdf to upload.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- // Unblock page
- $.unblockUI();
- return false;
- }
- // Send the formData
- var formData = new FormData( $("#upload_pdf_guidance")[0] );
- $.ajax({
- url : '<?php echo base_url() . index_page(); ?>admin/save_guidance_pdf',
- type : 'POST',
- data : formData,
- cache : false,
- contentType : false,
- processData : false,
- success : function(data) {
- // Unblock page
- $.unblockUI();
- if(data == 'success') {
- // Alert user data fields updated
- $.alert({
- title: 'Guidance Uploaded',
- content: 'The guidance pdfs were updated successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- }
- else {
- // Alert user data fields update failed
- $.alert({
- title: 'Guidance Upload Failed',
- content: 'An error was encountered while updating the guidance pdfs.<br />' + data + '<br /><br />Please contact a system administrator if assistance is needed.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- }
- });
- });
- // Remove company pdf
- $('.remove_comp_pdf').click(function() {
- // Confirm delete company pdf
- $.confirm({
- title: 'Delete Company PDF',
- content: 'The company .pdf file will be removed.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Delete PDF',
- confirm: function() {
- // Fire ajax to update options
- $.post("<?php echo base_url() . index_page(); ?>admin/delete_company_pdf").done(function(data) {
- if(data == 'success') {
- // Alert pdf removed successfully
- $.alert({
- title: 'Guidance PDF Deleted',
- content: 'The guidance pdf was deleted successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- // Clear filename and remove fields
- $('.upload_comp_pdf_filename').hide();
- $('.remove_comp_pdf').hide();
- }
- else {
- // Alert pdf removal failed
- $.alert({
- title: 'Guidance PDF Deletion Failed',
- content: 'An error was encountered while deleting the company guidance PDF. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- });
- // Remove product pdf
- $('.remove_prod_pdf').click(function() {
- // Confirm delete product pdf
- $.confirm({
- title: 'Delete Product PDF',
- content: 'The product .pdf file will be removed.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info',
- cancelButtonClass: 'btn-danger',
- confirmButton: 'Delete PDF',
- confirm: function() {
- // Fire ajax to update options
- $.post("<?php echo base_url() . index_page(); ?>admin/delete_product_pdf").done(function(data) {
- if(data == 'success') {
- // Alert pdf removed successfully
- $.alert({
- title: 'Guidance PDF Deleted',
- content: 'The guidance pdf was deleted successfully.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-info'
- });
- // Clear filename and remove fields
- $('.upload_prod_pdf_filename').hide();
- $('.remove_prod_pdf').hide();
- }
- else {
- // Alert pdf removal failed
- $.alert({
- title: 'Guidance PDF Deletion Failed',
- content: 'An error was encountered while deleting the product guidance PDF. Please contact a system administrator.',
- columnClass: 'col-md-6 col-md-offset-3',
- confirmButtonClass: 'btn-danger'
- });
- }
- });
- }
- });
- });
- var $comp_id_name_chart_table = $('table#comp_id_name_chart_table');
- // Toggle company name/id reference chart
- $('#comp_id_name_chart').click(function() {
- // Toggle table div
- $('#comp_id_name_chart_div').toggle();
- // Adjust class to keep active
- if($(this).hasClass('reference_active')) {
- $(this).removeClass('reference_active');
- }
- else {
- $(this).addClass('reference_active');
- }
- });
- // Set sortable table for company chart
- $("table#comp_id_name_chart_table").tablesorter({headers: { 0: { filter: true, sorter: true} }, widthFixed: true, widgets: ['filter', 'output'], widgetOptions: {
- filter_defaultFilter: { 1: '~{query}' },
- filter_columnFilters: true,
- filter_placeholder: { search: 'Search...' },
- filter_saveFilters: true,
- filter_reset: '.reset',
- output_delivery: 'd',
- output_saveFileName: 'Company_Name_ID_Reference_Chart.csv'
- }});
- // Download comp name/id to csv
- $('.comp_id_name_chart_to_csv').click(function(){
- // Tell the output widget do it's thing
- $comp_id_name_chart_table.trigger('outputTable');
- });
- var $prod_id_name_chart_table = $('table#prod_id_name_chart_table');
- // Toggle product name/id reference chart
- $('#prod_id_name_chart').click(function() {
- // Toggle table div
- $('#prod_id_name_chart_div').toggle();
- // Adjust class to keep active
- if($(this).hasClass('reference_active')) {
- $(this).removeClass('reference_active');
- }
- else {
- $(this).addClass('reference_active');
- }
- });
- // Set sortable table for product chart
- $("table#prod_id_name_chart_table").tablesorter({headers: { 0: { filter: true, sorter: true} }, widthFixed: true, widgets: ['filter', 'output'], widgetOptions: {
- filter_defaultFilter: { 1: '~{query}' },
- filter_columnFilters: true,
- filter_placeholder: { search: 'Search...' },
- filter_saveFilters: true,
- filter_reset: '.reset',
- output_delivery: 'd',
- output_saveFileName: 'Product_Name_ID_Reference_Chart.csv'
- }});
- // Download prod name/id to csv
- $('.prod_id_name_chart_to_csv').click(function(){
- // Tell the output widget do it's thing
- $prod_id_name_chart_table.trigger('outputTable');
- });
- var $prod_fam_id_name_chart_to_csv = $('table#prod_fam_id_name_chart_table');
- // Toggle product family/id reference chart
- $('#prod_fam_id_name_chart').click(function() {
- // Toggle table div
- $('#prod_fam_id_name_chart_div').toggle();
- // Adjust class to keep active
- if($(this).hasClass('reference_active')) {
- $(this).removeClass('reference_active');
- }
- else {
- $(this).addClass('reference_active');
- }
- });
- // Set sortable table for product family chart
- $("table#prod_fam_id_name_chart_table").tablesorter({headers: { 0: { filter: true, sorter: true} }, widthFixed: true, widgets: ['filter', 'output'], widgetOptions: {
- filter_defaultFilter: { 1: '~{query}' },
- filter_columnFilters: true,
- filter_placeholder: { search: 'Search...' },
- filter_saveFilters: true,
- filter_reset: '.reset',
- output_delivery: 'd',
- output_saveFileName: 'Product_Family_ID_Reference_Chart.csv'
- }});
- // Download prod fam/id to csv
- $('.prod_fam_id_name_chart_to_csv').click(function(){
- // Tell the output widget do it's thing
- $prod_fam_id_name_chart_to_csv.trigger('outputTable');
- });
- // Toggle search logs div
- $('#show_search_logs').click(function() {
- $('.search_logs_div').toggle();
- });
- // Set sortable table for search logs
- $("table#search_logs_table").tablesorter({headers: { 0: { filter: true, sorter: true} }, widthFixed: true, widgets: ['filter', 'output'], widgetOptions: {
- filter_defaultFilter: { 1: '~{query}' },
- filter_columnFilters: true,
- filter_placeholder: { search: 'Search...' },
- filter_saveFilters: true,
- filter_reset: '.reset',
- output_delivery: 'd',
- output_saveFileName: 'Search_Log.csv'
- }});
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement