// When user is selected, this function will prepopulate schools and materials info function user_selected(userid) { // Clear school-related inputs clear_fields(); $("#certificates_schoolselect").hide(); // Do nothing in caee of default empty value if (userid != "empty") { $("#certificates_chosen_user_name").html($("div[id='"+userid+"']").html()); // Repopulate schools pulldown data = {"action": "all_schools", "user_id": userid}; $.ajax({ data: data, EOT; $javascript .= "url: \"" . $CONFIG->wwwroot . "mod/koolielu/actions/cert_schools_or_school.php\","; $javascript .= <<wwwroot . "mod/koolielu/actions/cert_user_materials.php\","; $javascript .= <<wwwroot . "mod/koolielu/actions/cert_schools_or_school.php\","; $javascript .= <<" + results[i][2] + ""; } holder.empty(); element.empty(); holder.html(html); } // Translates system reply in json format and populates schools pulldown function translate_json_schools(data, testStatus) { results = data; element = $("select[name='certificates_schoolselect']"); html = ""; for (i = 0; i" + results[i][1] + ""; } element.empty(); element.html(html); // Only do something if there are some results provided if (results[0]) { $("#certificates_schoolselect").show(); school_selected(results[0][0]); } else { $("#certificates_schoolselect").hide(); } } // Populates information inputs for single school function translate_json_school(data, testStatus) { results = data; sc_name = $("input[name='certificates_school_name']"); sc_name.val(results[0]); sc_address = $("input[name='certificates_school_address']"); sc_address.val(results[1]); sc_postal_index = $("input[name='certificates_school_postal_index']"); sc_postal_index.val(results[2]); sc_location = $("input[name='certificates_school_location']"); sc_location.val(results[3]); } // Clears information inputs for single school function clear_fields() { // Clear school inputs sc_name = $("input[name='certificates_school_name']"); sc_name.val(""); sc_address = $("input[name='certificates_school_address']"); sc_address.val(""); sc_postal_index = $("input[name='certificates_school_postal_index']"); sc_postal_index.val(""); sc_location = $("input[name='certificates_school_location']"); sc_location.val(""); // Clear materials mat_holder = $("select[name='certificates_materials_holder']"); mat_holder.empty(); mat_mat = $("select[name='certificates_materials']"); mat_mat.empty(); $("#certificates_chosen_user_name").empty(); // Disable highlights cert_disable_highlight(); } // Clears inputs for single school and hides the school select function clear_fields_and_hide_schools() { clear_fields(); $("#certificates_schoolselect").hide(); $("select[name='certificates_schoolselect']").empty(); } // Moves selected materials form one multiselection box to another function move_selected_materials_from_to(move_from_name, move_to_name) { $("select[name="+move_from_name+"] option:selected").remove().appendTo("select[name="+move_to_name+"]"); } // Pickes up data and acts as form submit, checks if all fields are filled, sends information to pdf generator script function certificates_submit_form() { var form_submittable = true; var empty_inputs = new Array(); var data = "?"; var certificates_user_helper = $("input[name='certificates_user_helper']").val(); if (!certificates_user_helper) { empty_inputs.push("certificates_user_helper_holder"); } data += "certificates_user_helper=" + certificates_user_helper; var certificates_school_name = $("input[name='certificates_school_name']").val(); if (!certificates_school_name) { empty_inputs.push("certificates_school_name_holder"); } data += "&certificates_school_name=" + encodeURIComponent(certificates_school_name); var certificates_school_address = $("input[name='certificates_school_address']").val(); if (!certificates_school_address) { empty_inputs.push("certificates_school_address_holder"); } data += "&certificates_school_address=" + encodeURIComponent(certificates_school_address); var certificates_school_postal_index = $("input[name='certificates_school_postal_index']").val(); if (!certificates_school_postal_index) { empty_inputs.push("certificates_school_postal_index_holder"); } data += "&certificates_school_postal_index=" + encodeURIComponent(certificates_school_postal_index + " "); var certificates_school_location = $("input[name='certificates_school_location']").val(); if (!certificates_school_location) { empty_inputs.push("certificates_school_location_holder"); } data += "&certificates_school_location=" + encodeURIComponent(certificates_school_location); //Handle materials var materials_array = new Array(); selected_materials = $("select[name='certificates_materials'] option").each(function(i){ materials_array[i] = $(this).val(); }); if (materials_array.length < 1) { empty_inputs.push("certificates_materials_holder"); } data += "&certificates_materials=" + materials_array; var certificates_director = $("input[name='certificates_director']").val(); if (!certificates_director) { empty_inputs.push("certificates_director_holder"); } data += "&certificates_director=" + encodeURIComponent(certificates_director); var certificates_compiler_name = $("input[name='certificates_compiler_name']").val(); if (!certificates_compiler_name) { empty_inputs.push("certificates_compiler_name_holder"); } data += "&certificates_compiler_name=" + encodeURIComponent(certificates_compiler_name); var certificates_compiler_email = $("input[name='certificates_compiler_email']").val(); if (!certificates_compiler_email) { empty_inputs.push("certificates_compiler_email_holder"); } data += "&certificates_compiler_email=" + encodeURIComponent(certificates_compiler_email); var certificates_compiler_phone = $("input[name='certificates_compiler_phone']").val(); if (!certificates_compiler_phone) { empty_inputs.push("certificates_compiler_phone_holder"); } data += "&certificates_compiler_phone=" + encodeURIComponent(certificates_compiler_phone); // Check if for is submittable and highlight needed elements cert_disable_highlight(); if (empty_inputs.length > 0) { for (i=0;iwwwroot . "mod/koolielu/actions/cert_generate_certificate.php';"; $javascript .= << EOT; $body .= $javascript; /*translation:Koolielu certificates*/ $body .= "

" . elgg_echo("koolielu:koolielu_certificates") . "

"; // TCPDF library installation checks $ke_tcpdf_installation_path = get_plugin_setting('ke_tcpdf_installation_path', 'koolielu'); if (empty($ke_tcpdf_installation_path)) { /*translation:TCPDF library path not set. Please visit koolielu plugin settings page and set that.*/ $body .= '
' . elgg_echo('koolielu:error_tcpdf_libraty_path_not_set') . '
'; } else if (!empty($ke_tcpdf_installation_path) && !file_exists($ke_tcpdf_installation_path . "config/lang/eng.php") && !file_exists($ke_tcpdf_installation_path . "tcpdf.php")) { /*translation:TCPDF library not found. Please make sure that you have the library installed and try again.*/ $body .= '
' . elgg_echo('koolielu:error_tcpdf_not_installed') . '
'; } // User search input $aparams = array( 'internalname' => "certificates_user", 'internalid' => "certificates_user", 'value' => "", 'suggestsource' => $CONFIG->wwwroot."mod/koolielu/actions/search_users.php", 'usehidden' => false, 'minlength' => 3, 'class' => 'ke_short_input', 'usehelper' => true, 'helperjs' => "user_selected($('#certificates_user_helper').val());" ); /*translation:Search user by name*/ $body .= "


" . elgg_view("input/text_auto", $aparams) . "

"; $body .= "
"; // Chosen user name /*translation:Chosen user name*/ $body .= "

"; // School selection input $user_schools_options = array("empty" => ""); /*translation:User schools*/ $body .= "


" . elgg_view("input/pulldown", array("value" => "empty", "internalname" => "certificates_schoolselect", "options_values" => $user_schools_options, "js" => "onchange='school_selected(this.value);'")) . "

"; // School name /*translation:School name*/ $body .= "


" . elgg_view("input/text", array("value" => "", "internalname" => "certificates_school_name")) . "

"; // School address /*translation:School address*/ $body .= "


" . elgg_view("input/text", array("value" => "", "internalname" => "certificates_school_address")) . "

"; // School postal index /*translation:School postal index*/ $body .= "


" . elgg_view("input/text", array("value" => "", "internalname" => "certificates_school_postal_index")) . "

"; // School location /*translation:School location (town name)*/ $body .= "


" . elgg_view("input/text", array("value" => "", "internalname" => "certificates_school_location")) . "

"; // Materials multiselect /*translation:User materials, place suitable materials to the box on the right.*/ $body .= "


"; $body .= "

"; $body .= "<<<"; $body .= ">>>"; $body .= "
"; $body .= "

"; // Director name input /*translation:Director name*/ $body .= "


" . elgg_view("input/text", array("value" => "Enel Mägi", "internalname" => "certificates_director")). "

"; // Compiler name /*translation:Compiler name*/ $body .= "


" . elgg_view("input/text", array("value" => get_loggedin_user()->name, "internalname" => "certificates_compiler_name")). "

"; // Compiler email /*translation:Compiler email*/ $body .= "


" . elgg_view("input/text", array("value" => get_loggedin_user()->contactemail, "internalname" => "certificates_compiler_email")). "

"; // Compiler phone /*translation:Compiler phone*/ $body .= "


" . elgg_view("input/text", array("value" => get_loggedin_user()->phone, "internalname" => "certificates_compiler_phone")). "

"; // Add controls for simulated form $body .= ""; // Display main admin menu /*translation:Koolielu certificates*/ page_draw(elgg_echo('koolielu:koolielu_certificates'),elgg_view_layout("two_column_left_sidebar", '', $title . $body)); ?>