sub analytics_event_bookings_tabs_build_qt_left { my ($id,$tab,$ret) = @_ ; if ($tab == 1) { # Cusotmer Details # --------------- START CUSOTMER DETAILS -------------------------------------------------------------------------------------------------------- my $sec = '_customer_details' ; my ($sec_name,$sec_cnt,$sec_col) = &analytics_event_bookings_tabs_sec_det($sec) ; $ret_pdf_link_sec .= $sec . '+' . $sec_cnt . '|' ; return if $ret ; $lcol = 2 ; $fcol = 1 ; $add_form_fields = '' ; # $add_form_fields .= qq~
~ if $is_schools_manager ; $add_form_fields .= qq~
~ if $glod_user_level < 3 && $usertype ne 'analytics_client' ; my $checked = ($db{$table}{$id}{event_completed}) ? 'CHECKED' : '' ; $preferred_title{event_completed} = "Event Completed" ; $add_form_fields .= &common_min_form_checkbox('event_completed',$db{$table}{$id}{event_completed},$checked) ; # my $checked = 'CHECKED' if $db{$table}{$id}{event_accepted} ; my $checked = ($db{$table}{$id}{event_accepted}) ? 'CHECKED' : '' ; $preferred_title{event_accepted} = "Event Accepted" ; $add_form_fields .= &common_min_form_checkbox('event_accepted',$db{$table}{$id}{event_accepted},$checked) ; my $checked = ($db{$table}{$id}{event_rejected}) ? 'CHECKED' : '' ; $preferred_title{event_rejected} = "Event Rejected" ; $add_form_fields .= &common_min_form_checkbox('event_rejected',$db{$table}{$id}{event_rejected},$checked) ; # my $checked = 'CHECKED' if $db{$table}{$id}{event_pending} or $iaction eq 'add' ; my $checked = ($db{$table}{$id}{event_pending} || $iaction eq 'add') ? 'CHECKED' : '' ; $preferred_title{event_pending} = "Event Pending" ; $add_form_fields .= &common_min_form_checkbox('event_pending',$db{$table}{$id}{event_pending},$checked) ; # my $checked = 'CHECKED' if $db{$table}{$id}{event_cancelled} ; my $checked = ($db{$table}{$id}{event_cancelled}) ? 'CHECKED' : '' ; $preferred_title{event_cancelled} = "Event Cancelled" ; $add_form_fields .= &common_min_form_checkbox('event_cancelled',$db{$table}{$id}{event_cancelled},$checked) ; # $add_form_fields .= qq~
~ if $is_schools_manager ; $add_form_fields .= qq~
~ if $glod_user_level < 3 && $usertype ne 'analytics_client' ; # $add_form_fields .= qq~~ if $is_schools_manager ; $add_form_fields .= qq~~ if $glod_user_level < 3 && $usertype ne 'analytics_client' ; $fcol = 4 ; $add_form_fields .= &common_min_form_input('contact_name',$db{$table}{$id}{contact_name},'') ; $add_form_fields .= &common_min_form_input('address',$db{$table}{$id}{address},'') ; $add_form_fields .= &common_min_form_input('email',$db{$table}{$id}{email},'') ; $add_form_fields .= &common_min_form_input('tel',$db{$table}{$id}{tel},'') ; # $fcol = 5 ; $add_form_fields .= qq~
 
~ ; &analytics_event_bookings_tabs_content_box($sec_name,$sec_col); $trigger_jquery_raw .= qq~ if (!\$("#checkboxEvent_accepted").is(":checked") && !\$("#checkboxEvent_rejected").is(":checked") && !\$("#checkboxEvent_pending").is(":checked") && !\$("#checkboxEvent_cancelled").is(":checked") && !\$("#checkboxEvent_completed").is(":checked")) { \$("#checkboxEvent_pending").prop("checked","true") ; } \$("#checkboxEvent_completed,#checkboxEvent_accepted,#checkboxEvent_rejected,#checkboxEvent_pending,#checkboxEvent_cancelled").click( function () { if (this.id != 'checkboxEvent_completed' && \$("#checkboxEvent_completed").is(":checked")) { \$("#checkboxEvent_completed").prop("checked",false) ; } if (this.id != 'checkboxEvent_accepted' && \$("#checkboxEvent_accepted").is(":checked")) { \$("#checkboxEvent_accepted").prop("checked",false) ; } if (this.id != 'checkboxEvent_rejected' && \$("#checkboxEvent_rejected").is(":checked")) { \$("#checkboxEvent_rejected").prop("checked",false) ; } if (this.id != 'checkboxEvent_pending' && \$("#checkboxEvent_pending").is(":checked")) { \$("#checkboxEvent_pending").prop("checked",false) ; } if (this.id != 'checkboxEvent_cancelled' && \$("#checkboxEvent_cancelled").is(":checked")) { \$("#checkboxEvent_cancelled").prop("checked",false) ; } if (this.id == 'checkboxEvent_completed' && !\$("#checkboxEvent_accepted").is(":checked")) { \$("#checkboxEvent_accepted").prop("checked",true) ; } if (!\$("#checkboxEvent_accepted").is(":checked") && !\$("#checkboxEvent_rejected").is(":checked") && !\$("#checkboxEvent_pending").is(":checked") && !\$("#checkboxEvent_cancelled").is(":checked") && !\$("#checkboxEvent_completed").is(":checked")) { \$("#checkboxEvent_pending").prop("checked","true") ; } }); ~ ; # --------------- END CUSOTMER DETAILS ---------------------------------------------------------------------------------------------------------- } if ($tab == 2) { # Cusotmer Details # --------------- START CUSOTMER DETAILS -------------------------------------------------------------------------------------------------------- return if $ret ; my $sec = '_event_details' ; my ($sec_name,$sec_cnt,$sec_col) = &analytics_event_bookings_tabs_sec_det($sec) ; $ret_pdf_link_sec .= $sec . '+' . $sec_cnt . '|' ; $preferred_title{sport_type_ids} = "Sport Type(s)" ; $preferred_title{start_date_time} = "Event Date/Time From" ; $preferred_title{end_date_time} = "Event Date/Time To" ; $add_form_fields = "" ; foreach (sort {$a <=> $b} keys %service_types) { $opts{service_type_id} .= qq~~ ; $opts{service_type} .= qq~~ ; } foreach (split(/\,/,$db{$table}{$id}{sport_type_ids})) { $opts{sport_type_ids} =~ s/value="$_"/value="$_" SELECTED/g ; } $db{$table}{$id}{service_type_id} = 3 unless $db{$table}{$id}{service_type_id}; # $opts{service_type} = $opts{service_type_id} ; for (1 .. 100) { $opts{total_fixtures} .= qq~~ ; } $db{$table}{$id}{total_fixtures} = 1 unless $db{$table}{$id}{total_fixtures} ; $opts{total_fixtures} =~ s/value="$db{$table}{$id}{total_fixtures}"/value="$db{$table}{$id}{total_fixtures}" SELECTED/g ; $db{$table}{$id}{start_date_time} = "$now_year-$now_mm-$now_dd 08:00:00" unless $db{$table}{$id}{start_date_time} ; $db{$table}{$id}{end_date_time} = "$now_year-$now_mm-$now_dd 17:00:00" unless $db{$table}{$id}{end_date_time} ; $allow_deselect{client_id} = 1 ; # $allow_deselect{total_fixtures} = 1 ; # $allow_deselect{service_type_id} = 1 ; $lcol = 2 ; $fcol = 4 ; # if ($usertype eq 'analytics_client') { # &db_min_ro('users','id,name',"id='$userid'") ; # $opts{client_id} = qq~~ ; # } else { # &common_min_select_opts('client_id','customers','name','','','',"analytics='1'") ; # # $db{$table}{$id}{client_id} = $userid if !$db{$table}{$id}{client_id} && $usertype eq 'analytics_client' ; # $opts{client_id} =~ s/value="$db{$table}{$id}{client_id}"/value="$db{$table}{$id}{client_id}" SELECTED/g if $db{$table}{$id}{client_id} ; # } $dlg{client_id} .= qq~
~ ; $dlg{sport_type_ids} .= qq~
~ ; # $onload = qq~onload=dispCustomer();~ if $iaction eq 'add' ; # SuperSport Schools (Pty) Ltd if ($sql_limit_user_regions) { $sql_limit_user_regions =~ s/id/region_id/g ; $sql_limit_user_regions .= "region_id='0' OR ($sql_limit_user_regions)" ; } &analytics_event_bookings_tabs_customer_select_opts('customers','name',$sql_limit_user_regions,'client_id'); # $allow_deselect{client_id} = 1 ; # $required{client_id} = 1 ; # $db{$table}{$id}{total_fixtures} = 2 ; $add_form_fields .= &common_min_form_select('client_id',$db{$table}{$id}{client_id}) ; $add_form_fields .= &common_min_form_select('sport_type_ids',$db{$table}{$id}{sport_type_ids}) ; $db{$table}{$id}{default_fixtures_sport} = "0" unless $db{$table}{$id}{default_fixtures_sport} ; $add_form_fields .= qq~~ ; $add_form_fields .= &common_min_form_input('event_name',$db{$table}{$id}{event_name}) ; $add_form_fields .= &common_min_form_datetimepicker('start_date_time',$db{$table}{$id}{start_date_time}) ; $add_form_fields .= &common_min_form_datetimepicker('end_date_time',$db{$table}{$id}{end_date_time}) ; $add_form_fields .= &common_min_form_select('total_fixtures',$db{$table}{$id}{total_fixtures}) ; $opts{service_type_id} =~ s/value="$db{$table}{$id}{service_type_id}"/value="$db{$table}{$id}{service_type_id}" SELECTED/g ; $add_form_fields .= &common_min_form_select('service_type_id',$db{$table}{$id}{service_type_id}) ; $trigger_jquery_raw .= qq~ \$("#selectService_type_id").on("change", function () { let this_val = \$(this).val() ; \$("#three [id^='selectService_type_fixtures_']").each( function () { let row_nr = get_row_nr(this.id) ; \$(this).val(this_val).trigger("chosen:updated") ; if (this_val == "1") { \$("#selectFootage_type_fixtures_"+row_nr).val("r").trigger("chosen:updated") ; } }) ; }) ; ~ ; $trigger_jquery_raw .= qq~ \$("#selectService_type_id").change( function () { for (let i = 1; i<=100 ; i++) { if (!\$("#fixtures_"+i).html()) { break ; } if (!\$("#selectService_type_fixtures_"+i).val()) { \$("#selectService_type_fixtures_"+i).val(\$(this).val()).trigger("chosen:updated") ; } } }) ; ~ ; $db{$table}{$id}{tournament_festival_id} = 1 if !$db{$table}{$id}{derby_day_weekly_fixture_id} && !$db{$table}{$id}{tournament_festival_id} ; $add_form_fields .= &common_min_form_checkbox('derby_day_weekly_fixture_id',$db{$table}{$id}{derby_day_weekly_fixture_id}) ; $add_form_fields .= &common_min_form_checkbox('tournament_festival_id',$db{$table}{$id}{tournament_festival_id}) ; $trigger_jquery .= qq~ // \$('.iPhoneCheckContainer').css("width","76px") ; // \$('.iPhoneCheckHandle').css("width","32px") ; // \$('.iPhoneCheckHandle').css("left","0px") ; // \$('.iPhoneCheckLabelOff').css("width","71px") ; // \$('.iPhoneCheckLabelOff').css("top","-5px") ; // \$('.iPhoneCheckLabelOn').css("top","-5px") ; // \$('.iPhoneCheckLabelOn').css("width","45px") ; // \$('.iPhoneCheckLabelOff span').css("font-size","14px"); // \$('.iPhoneCheckLabelOn span').css("font-size","14px"); ~ ; $trigger_jquery_raw .= qq~\$("#checkboxTournament_festival_id").prop("checked",true) ;~ if $db{$table}{$id}{tournament_festival_id} ; $trigger_jquery_raw .= qq~\$("#checkboxDerby_day_weekly_fixture_id").prop("checked",true) ;~ if $db{$table}{$id}{derby_day_weekly_fixture_id} ; &common_shared_build_select_primary_jquery ; $trigger_jquery_raw .= qq~ const getClientId = () => { const val = \$clientSelect.val(); return val ? val.toString().split(":")[0] : null; }; const fillTeamSelect = (\$el, teams) => { clearSelect(\$el); teams.forEach(({ id, name }) => { \$el.append(``); }); updateChosen(\$el); }; // if (check_team_names_match_client && client_id == "") { // client_id = getClientId() ; // if (client_id == null) { // client_id = -1 ; // } // } // if (client_id == "" || client_id == -1 || client_id == null) { // \$("input[name='typeahead_"+field_name+"']").val("") ; // \$("input[name='"+field_name+"']").val("") ; // client_id = "" ; // } else if (check_team_names_match_client) { // let url_teams = `$useropts{scripts}/get/get_sss_teams_from_client.pl?client_id=\${client_id}` ; // teams = await fetchJSON(url_teams); // const idToCheck = \$("input[name='"+field_name+"']").val() ; // console.log("idToCheck : "+idToCheck) ; // if (idToCheck) { // const exists = teams.some(item => item.id === idToCheck) ; // if (exists == false) { // \$("input[name='typeahead_"+field_name+"']").val("") ; // \$("input[name='"+field_name+"']").val("") ; // } // } // } \$("#checkboxDerby_day_weekly_fixture_id").on("change",async function () { if (\$(this).is(":checked")) { \$("#checkboxTournament_festival_id").prop("checked",false) ; \$("#add_existing_home_team").css("display","none") ; \$("#add_existing_away_team").css("display","none") ; // build_teams_from_client() ; let clientId = getClientId() ; if (clientId == null) { clientId = -1 ; } create_typeahead("fixtures_table","[name^='typeahead_home_team_']",clientId,1) ; let found_blank = 0 ; let first_non_blank = "" ; let teams = [] ; if (clientId == "" || clientId == -1 || clientId == null) { } else { let url_teams = `$useropts{scripts}/get/get_sss_teams_from_client.pl?client_id=\${clientId}` ; teams = await fetchJSON(url_teams); } \$("#three input[name^='home_team_']").each( function () { if ((\$("input[name='"+this.name+"']").val() && teams.some(item => item.id === \$("input[name='"+this.name+"']").val()) === false) || !\$("#selectClient_id").val()) { \$("input[name='"+this.name+"']").val("") ; \$("input[name='typeahead_"+this.name+"']").val("") ; } if (!\$("input[name='"+this.name+"']").val() && !found_blank) { found_blank = 1 ; } if (\$("input[name='"+this.name+"']").val() && first_non_blank == "") { first_non_blank = this.name ; } }) ; if (found_blank && first_non_blank != "") { apply_home_team_to_all_blank(first_non_blank) ; } } else { \$("#checkboxTournament_festival_id").prop("checked",true) ; \$("#add_existing_home_team").css("display","") ; \$("#add_existing_away_team").css("display","") ; create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; } }) ; \$("#checkboxTournament_festival_id").change( async function () { if (\$(this).is(":checked")) { \$("#add_existing_home_team").css("display","") ; \$("#add_existing_away_team").css("display","") ; \$("#checkboxDerby_day_weekly_fixture_id").prop("checked",false) ; create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; } else { \$("#checkboxTournament_festival_id").prop("checked",false) ; \$("#add_existing_home_team").css("display","none") ; \$("#add_existing_away_team").css("display","none") ; // build_teams_from_client() ; let clientId = getClientId() ; if (clientId == null) { clientId = -1 ; } create_typeahead("fixtures_table","[name^='typeahead_home_team_']",clientId,0) ; let found_blank = 0 ; let first_non_blank = "" ; let teams = "[]" ; if (clientId == "" || clientId == -1 || clientId == null) { } else { let url_teams = `$useropts{scripts}/get/get_sss_teams_from_client.pl?client_id=\${clientId}` ; teams = await fetchJSON(url_teams); } \$("#three input[name^='home_team_']").each( function () { if (\$("input[name='"+this.name+"']").val() && teams.some(item => item.id === \$("input[name='"+this.name+"']").val()) === false) { \$("input[name='"+this.name+"']").val("") ; \$("input[name='typeahead_"+this.name+"']").val("") ; } if (!\$("input[name='"+this.name+"']").val() && !found_blank) { found_blank = 1 ; } if (\$("input[name='"+this.name+"']").val() && first_non_blank == "") { first_non_blank = this.name ; } }) ; if (found_blank && first_non_blank != "") { apply_home_team_to_all_blank(first_non_blank,clientId,1) ; } } }) ; async function build_teams_from_client () { const clientId = getClientId() ; let teams_ = "[]" ; if (clientId) { let url_teams2 = `$useropts{scripts}/get/get_sss_teams_from_client.pl?client_id=\${clientId}` ; teams_ = await fetchJSON(url_teams2); } \$("#fixtures_table select[id^='selectHome_team_']").each( function () { let selected_val = (\$(this).val()) ? \$(this).val() : "" ; clearSelect(\$(this)); fillTeamSelect(\$(this),teams_) ; if (teams_.length === 1) { \$(this).val(teams_[0].id).trigger("chosen:updated") ; } else { \$(this).val(selected_val).trigger("chosen:updated") ; } }) ; } ~ ; $add_form_fields .= &common_min_form_textarea('additional_notes',$db{$table}{$id}{additional_notes}) ; $trigger_jquery_raw .= qq~ // let end_time = new Date("$db{$table}{$id}{end_date_time}") ; // let start_time = new Date("$db{$table}{$id}{start_date_time}") ; // \$("#datetimepickerStart_date_time").datetimepicker("setEndDate",end_time) ; // \$("#datetimepickerEnd_date_time").datetimepicker("setStartDate",start_time) ; // let picker = \$("#datetimepickerStart_date_time").data("datetimepicker").endDate.toISOString().slice(0,19).replace('T',' ') ; // console.log("endDate : "+picker); ~ ; &analytics_event_bookings_tabs_content_box($sec_name,$sec_col); # custom_selected_region" # custom_selected_country $trigger_jquery_raw .= qq~ let map_client_to_country = {} ; let map_region_to_country = {} ; let map_client_to_region = {} ; const \$clientSelect = \$("#selectClient_id") ; const \$countrySelect = \$("#selectCountry_id") ; const \$regionSelect = \$("#selectRegion_id") ; const \$fixturesTable = \$("#fixtures_table"); let regionId = \$regionSelect.val() ; let countryId = \$("#selectCountry_id").val() ; // const populateSelect = (\$el, dataList, labelFn) => { // let lastId = null ; // for (const data of dataList) { // \$el.append(``); // lastId = data.id; // } // updateChosen(\$el) ; // return { count: dataList.length, lastId } ; // } ; // const populateSelect = (\$el, list, getLabel) => { // list.forEach(data => { \$el.append(``); }) ; // updateChosen(\$el); // return list.length; // }; // const fillTeamSelect = (\$el, teams) => { // \$el.empty().append(""); // teams.forEach(team => { // \$el.append(``); // }); // \$el.val("").trigger("chosen:updated"); // }; const getInputValue = name => \$(`input[name='\${name}']`).val(); const setInputValue = (name, val = "") => \$(`input[name='\${name}']`).val(val); let prev_country_id = \$countrySelect.val() ; let prev_region_id = \$regionSelect.val() ; \$clientSelect.on("change", async function () { dispCustomer() ; const hasCustomRegion = !!getInputValue('custom_selected_region') ; const clientId = getClientId() ; const hasCustomCountry = !!getInputValue('custom_selected_country') ; if (clientId && !hasCustomRegion) { let url1 = `$useropts{scripts}/get/get_region_country_from_client.pl?client_id=\${clientId}` ; if (!hasCustomRegion || !hasCustomCountry) { const data = await fetchJSON(url1) ; data.forEach(({region_id,country_id}) => { if (region_id == '0') region_id = '' ; if (country_id == '0') country_id = '' ; if (\$regionSelect.val() == '13' && (!region_id || hasCustomCountry)) region_id = '13' ; if (!hasCustomRegion && region_id != \$regionSelect.val()) \$regionSelect.val(region_id).trigger("chosen:updated") ; if (!hasCustomCountry && country_id != \$countrySelect.val()) \$countrySelect.val(country_id).trigger("chosen:updated") ; }) ; } } else if (!clientId) { if (!hasCustomCountry) \$countrySelect.val("").trigger("chosen:updated") ; if (!hasCustomRegion && \$regionSelect.val() != '13') \$regionSelect.val("").trigger("chosen:updated") ; } let cnt = 0 ; let teams = "[]" ; if (clientId) { let url_teams2 = `$useropts{scripts}/get/get_sss_teams_from_client.pl?client_id=\${clientId}` ; teams = await fetchJSON(url_teams2); if (\$("#checkboxDerby_day_weekly_fixture_id").is(":checked")) { \$("#three input[name^='home_team_']").each( function () { let id_name = this.name ; const \$teamSelect = \$("input[name='"+id_name+"']") ; const idToCheck = \$teamSelect.val() ; const exists = teams.some(item => item.id === idToCheck) ; if (!exists || exists == false) { \$teamSelect.val("") ; \$("input[name='typeahead_"+id_name+"']").val("") ; } // if (!\$teamSelect.val() && teams.length == 1 && teams != "[]") { // only select if 1 in the list if (!\$teamSelect.val() && teams != "[]") { // select the first available team // \$teamSelect.val(teams[0].name) ; // \$("input[name='typeahead_"+id_name+"']").val(teams[0].id) ; \$teamSelect.val(teams[0].id) ; \$("input[name='typeahead_"+id_name+"']").val(teams[0].name) ; } }) ; create_typeahead("fixtures_table","[name^='typeahead_home_team_']",clientId,1) ; } else { // create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; } // else { // create_typeahead("fixtures_table","[name^='typeahead_home_team_']",clientId,1) ; // } } else { if (\$("#checkboxDerby_day_weekly_fixture_id").is(":checked")) { \$("#three input[name^='home_team_']").each( function () { \$("input[name='"+this.name+"']").val("") ; \$("input[name='typeahead_"+this.name+"']").val("") ; }) ; create_typeahead("fixtures_table","[name^='typeahead_home_team_']","-1",1) ; } else { create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; } // else { // create_typeahead("fixtures_table","[name^='typeahead_home_team_']","clientId",1) ; // } // create_typeahead("fixtures_table","[name^='typeahead_home_team_']",-1,3) ; } if (teams.length > 0 && teams != "[]") { \$("input[name='home_teams_built_on_regions']").val("") ; // \$("#fixtures_table select[id^='selectHome_team_']").each( function () { \$("#fixtures_table input[name^='typeahead_home_team_']").each( function () { // let selected_val = (\$(this).val()) ? \$(this).val() : "" ; // const \$teamSelect = \$(this) ; let id_name = this.name ; const \$teamSelect = \$("input[name='"+id_name+"']") ; console.log("1 id_name : "+id_name) ; id_name = id_name.replace("typeahead_","") ; // console.log("2 id_name : "+id_name) ; // console.log("3 id_name val : "+\$("input[name='"+id_name+"']").val()) ; // console.log("4 teams[0].id : "+teams[0].id) ; // console.log("5 teams[0].name : "+teams[0].name) ; // clearSelect(\$teamSelect); // fillTeamSelect(\$teamSelect,teams) ; // if (teams.length === 1 && !\$("#checkboxDerby_day_weekly_fixture_id").is(":checked") && !\$("input[name='"+id_name+"']").val()) { // only select if 1 in the list if (!\$("#checkboxDerby_day_weekly_fixture_id").is(":checked") && !\$("input[name='"+id_name+"']").val()) { // select the first available team \$teamSelect.val(teams[0].name) ; // with _typahead \$("input[name='"+id_name+"']").val(teams[0].id) ;// without _typahead } else if (\$("#checkboxDerby_day_weekly_fixture_id").is(":checked")) { // \$teamSelect.val(selected_val).trigger("chosen:updated") ; } }) ; } else if (\$regionSelect.val() && \$regionSelect.val() != prev_region_id) { \$("input[name='home_teams_built_on_regions']").val("1") ; await build_teams_from_region(\$regionSelect.val()) ; } else if (\$countrySelect.val() && \$countrySelect.val() != prev_country_id) { \$("input[name='home_teams_built_on_regions']").val("1") ; await build_teams_from_region("",\$countrySelect.val()) ; } else if (!\$regionSelect.val() && !\$countrySelect.val() && (\$("input[name='home_teams_built_on_regions']").val() || (!\$("input[name='home_teams_built_on_regions']").val() && !clientId))) { \$("#fixtures_table select[id^='selectHome_team_']").each(function () { clearSelect(\$(this)) ; }) ; } else if (!\$("input[name='home_teams_built_on_regions']").val() && \$regionSelect.val()) { \$("input[name='home_teams_built_on_regions']").val("1") ; await build_teams_from_region(\$regionSelect.val()) ; } else if (!\$("input[name='home_teams_built_on_regions']").val() && \$countrySelect.val()) { \$("input[name='home_teams_built_on_regions']").val("1") ; await build_teams_from_region("",\$countrySelect.val()) ; } prev_country_id = \$countrySelect.val() ; prev_region_id = \$regionSelect.val() ; // else { // \$("input[name='home_teams_built_on_regions']").val("1") ; // const away_team_options = \$("#selectAway_team_fixtures_1").children().clone(); // \$("#fixtures_table select[id^='selectHome_team_']").each( function () { // let \$teamSelect = \$(this) ; // clearSelect(\$teamSelect); // \$teamSelect.append(away_team_options).trigger("chosen:updated") ; // }) ; // } hide_or_display_buttom_to_add_hometeam_from_existing() ; if (!\$("#checkboxDerby_day_weekly_fixture_id").is(":checked") && clientId) { create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; } }) ; \$countrySelect.on("change", async function () { \$("input[name='custom_selected_country']").val("1") ; await update_region_drop_down(\$countrySelect.val()) ; if (\$regionSelect.val() && prev_region_id != \$regionSelect.val()) { await build_teams_from_region(\$regionSelect.val()) ; } else if (!\$regionSelect.val() && \$countrySelect.val() && prev_country_id != \$countrySelect.val()) { await build_teams_from_region("",\$countrySelect.val()) ; } prev_country_id = \$countrySelect.val() ; prev_region_id = \$regionSelect.val() ; }) ; \$regionSelect.on("change", async function () { \$("input[name='custom_selected_country']").val("") ; \$("input[name='custom_selected_region']").val(\$(this).val()) ; // await build_teams_from_region(\$regionSelect.val()) ; await select_country_from_region(\$regionSelect.val(),1) ; \$("input[name='custom_selected_country']").val("1") ; prev_country_id = \$countrySelect.val() ; prev_region_id = \$regionSelect.val() ; // hide_or_display_buttom_to_add_hometeam_from_existing() ; }) ; function hide_or_display_buttom_to_add_hometeam_from_existing () { // // // if ((\$clientSelect.val()) && \$("#selectHome_team_fixtures_1 option").length > 0) { // // // \$("#add_existing_home_team").css("display","none") ; // // // } else { // // // \$("#add_existing_home_team").css("display","") ; // // // } } async function update_region_drop_down (countryId) { if (typeof countryId === 'undefined') { countryId = "" ; } let region_id = \$regionSelect.val() ; clearSelect(\$regionSelect) ; const regionUrl = `$useropts{scripts}/get/get_regions_from_country.pl?country_id=\${countryId}`; // console.log("regionUrl : "+regionUrl) ; const regions = await fetchJSON(regionUrl); for (const data of regions) { map_region_to_country[data.id] = countryId; } const regionCount = populateSelect(\$regionSelect, regions, r => r.code ? `\${r.name} [\${r.code}]` : r.name ) ; let selectedRegionId = 0 ; if (regionCount["count"] === 1) { selectedRegionId = regions[0].id ; \$regionSelect.val(regions[0].id) ; } else if (regionCount["count"] === 0 && \$countrySelect.val()) { selectedRegionId = 13 ; \$regionSelect.append(``) ; } if (selectedRegionId == 0) \$regionSelect.val(region_id) ; updateChosen(\$regionSelect) ; } async function select_country_from_region (regionId,update_country=0) { if (map_region_to_country[regionId]) { \$countrySelect.val(map_region_to_country[regionId]).trigger("chosen:updated") ; } else if (!\$("input[name='custom_selected_country']").val() || update_country) { // let url_teams1 = "$useropts{scripts}/get/get_country_from_region.pl?region_id="+regionId ; const lookupUrl = `$useropts{scripts}/get/get_country_from_region.pl?country_id=®ion_id=\${regionId}`; const regionMeta = await fetchJSON(lookupUrl); const { country_id } = regionMeta[0] ?? {}; if (country_id) { map_region_to_country[regionId] = country_id; \$countrySelect.val(country_id).trigger("chosen:updated"); } } } async function build_teams_from_region (regionId="",countryId="") { return ; let url_teams1 = `$useropts{scripts}/get/get_sss_teams_from_region.pl?region_id=\${regionId}&country_id=\${countryId}` ; // let tabs = (\$("input[name='home_teams_built_on_regions']").val() == "1") ? "#fixtures_table select[id^='selectHome_team_'],#fixtures_table select[id^='selectAway_team_']" : "#fixtures_table select[id^='selectAway_team_']" ; // console.log("build_teams_from_region URL : "+url_teams1) ; let tabs = (\$("input[name='home_teams_built_on_regions']").val() == "1") ? "#fixtures_table select[id^='selectHome_team_']" : "" ; const teams = await fetchJSON(url_teams1); if (tabs != "") { \$(tabs).each(function () { const \$teamSelect = \$(this); clearSelect(\$teamSelect); fillTeamSelect(\$teamSelect, teams); }); } } ~ ; } if ($tab == 3) { return if $ret; our $on_team_change_extra_trigger_jquery_raw = qq~~ ; $on_team_change_extra_trigger_jquery_raw .= qq~ apply_home_team_to_all_blank(field_name) ; ~ ; our $on_team_change_extra_trigger_jquery_raw_2 = qq~ apply_home_team_to_all_blank(field_name) ; ~ ; $trigger_jquery_raw .= qq~ // function apply_home_team_to_all_blank (field_name,client_id="",check_team_names_match_client=0) { function apply_home_team_to_all_blank (field_name) { if (!field_name || !\$("#checkboxDerby_day_weekly_fixture_id").is(":checked")) { return ; } \$("#three input[name^='home_team_']").each( function () { if (!\$("input[name='typeahead_"+this.name+"']").val() && field_name != this.name) { \$("input[name='typeahead_"+this.name+"']").val(\$("input[name='typeahead_"+field_name+"']").val()) ; \$("input[name='"+this.name+"']").val(\$("input[name='"+field_name+"']").val()) ; } }) ; } ~ ; # \$("#fixtures_table input[name^='typeahead_home_team_']").each( function () { &common_shared_typeahead("fixtures_table","typeahead_away_team_,typeahead_home_team_") ; my $home_team_client = ($db{$table}{$id}{client_id}) ? $db{$table}{$id}{client_id} : -1 ; if ($db{$table}{$id}{derby_day_weekly_fixture_id}) { $trigger_jquery_raw .= qq~ create_typeahead("fixtures_table","[name^='typeahead_away_team_']","",3) ; create_typeahead("fixtures_table","[name^='typeahead_home_team_']","$home_team_client",1) ; ~ ; } else { $trigger_jquery_raw .= qq~ create_typeahead("fixtures_table","[name^='typeahead_away_team_'],[name^='typeahead_home_team_']","",3) ; // create_typeahead("fixtures_table","[name^='typeahead_home_team_']","",3) ; ~ ; } # $db{$table}{$id}{derby_day_weekly_fixture_id} my $sec = '_fixtures' ; my ($sec_name,$sec_cnt,$sec_col) = &analytics_event_bookings_tabs_sec_det($sec) ; $sec = 'fixtures' ; $add_form_fields = '' ; $lcol = 1; $fcol = 2; our @headers = @fixture_headers ; our %custom_header = () ; push @headers, "Stream Forwarding" ; push @headers, "Stream Key" ; push @headers, "Stream URL" ; &report_xlsx_export_header("Analytics-Fixtures-$i{id}",'analytics_fixtures') ; push @headers, "Can't Charge Client" ; our $csvpath = "$htmlpath/csv/analytics_fixtures" ; our $csvname = "Analytics-Fixtures-$i{id}-" . $now_ccyymmdd . $now_hour . $now_min . $now_sec . '.csv' ; ; &csv_clear_folder($csvpath,"Analytics-Fixtures-$i{id}") ; &csv_create_new_file($csvpath,$csvname) ; # $db{$table}{$i{id}}{cant_charge_client_fixtures} = "1;1" ; # $db{$table}{$i{id}}{cant_charge_client_reasons} = "Test123:|;123123" ; &analytics_event_bookings_tabs_build_fixtures_table_headers(3) ; &analytics_event_bookings_tabs_build_fixtures_table($id,"$sec") ; $db{$table}{$i{id}}{cant_charge_client_reasons} =~ s/\R/\_new_line_character_/g ; $db{$table}{$i{id}}{cant_charge_client_reasons} =~ s/ /\ /g ; $add_form_fields .= qq~~ ; my $add_box_icon = $box_icon ; $box_icon = "" ; $worksheet{$ws}->set_column(0,0,20) ; $worksheet{$ws}->set_column(1,3,10) ; $worksheet{$ws}->set_column(4,4,30) ; $worksheet{$ws}->set_column(5,5,10) ; $worksheet{$ws}->set_column(6,6,30) ; $worksheet{$ws}->set_column(7,8,15) ; $worksheet{$ws}->set_column(9,9,20) ; # $worksheet{$ws}->set_column(10,10,25) ; $worksheet{$ws}->set_column(10,10,20) ; $worksheet{$ws}->set_column(11,11,25) ; $worksheet{$ws}->set_column(12,12,50) ; $box_icon .= qq~
~ ; &csv_close_file("$csvpath/$csvname") ; &report_xlsx_export_footer('L',15,'analytics_fixtures') ; if (-f "$csvpath/$csvname") { # $box_icon .= qq(
) ; } $add_form_fields .= qq~
 
~ ; &analytics_event_bookings_tabs_content_box($sec_name,$sec_col,$box_icon); $box_icon = $add_box_icon ; $trigger_jquery_raw .= qq~ \$("#three").on("click","[id^='checkboxCant_charge_client']", function () { let row_nr = get_row_nr(this.id) ; set_default_fixtures_values(row_nr) ; // console.log("123123123 id : "+this.id) ; if (\$("#"+this.id).is(":checked")) { if (\$("#reason_icon_"+row_nr+"_$id").html()) { \$("#reason_icon_"+row_nr+"_$id").css("display","") ; } else { dlgMdl("$useropts{scripts}/dialog/add_fixtures_charge_free_reason.pl?add&&$i{id}&"+row_nr,"Add Reason",'','medium-dialog') ; // console.log("$useropts{'scripts'}/dialog/add_fixtures_charge_free_reason.pl?add&&$i{id}&"+row_nr) ; } } else { // console.log("hide #reason_icon_"+row_nr+"_$id") ; \$("#reason_icon_"+row_nr+"_$id").hide() ; } }) ; ~ ; $trigger_jquery_raw .= qq~ function importDoc(t,b) { dlgMdl("$useropts{'scripts'}/dialog/import_analytics_fixtures.pl?"+t+"&"+b,"Import EXCEL",'height:210px','min-dialog') ; } ~; $trigger_jquery_raw .= qq~ \$('[data-toggle="tooltip"]').tooltip({ container: 'body' }); // \$('