diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 16519604..9fc0f27e 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -594,6 +594,8 @@ OTHER CHANGES: until the user logs out. For more information, read the 2FA_TWO_FACTOR_AUTHENTICATION.txt document. +167. Added a page to allow Editing existing Lead Loader Templates. + diff --git a/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php b/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php index c80b18d2..75a362a4 100644 --- a/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php +++ b/agc_2-X/trunk/www/vicidial/AST_admin_template_maker.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell,Joe Johnson LICENSE: AGPLv2 # # CHANGES # 120402-2132 - First Build @@ -17,6 +17,7 @@ # 180324-0942 - Enforce User Group campaign permissions for templates based on list_id # 180503-2215 - Added new help display # 180927-0633 - Fix for deleted template function in alternate language, issue #1127 +# 210312-1700 - Added layout editing functionality # require("dbconnect_mysqli.php"); @@ -48,6 +49,12 @@ if (isset($_GET["custom_fields_layout"])) {$custom_fields_layout=$_GET["custo elseif (isset($_POST["custom_fields_layout"])) {$custom_fields_layout=$_POST["custom_fields_layout"];} if (isset($_GET["submit_template"])) {$submit_template=$_GET["submit_template"];} elseif (isset($_POST["submit_template"])) {$submit_template=$_POST["submit_template"];} +if (isset($_GET["submit_edited_template"])) {$submit_edited_template=$_GET["submit_edited_template"];} + elseif (isset($_POST["submit_edited_template"])) {$submit_edited_template=$_POST["submit_edited_template"];} +if (isset($_GET["edit_standard_fields_layout"])) {$edit_standard_fields_layout=$_GET["edit_standard_fields_layout"];} + elseif (isset($_POST["edit_standard_fields_layout"])) {$edit_standard_fields_layout=$_POST["edit_standard_fields_layout"];} +if (isset($_GET["edit_custom_fields_layout"])) {$edit_custom_fields_layout=$_GET["edit_custom_fields_layout"];} + elseif (isset($_POST["edit_custom_fields_layout"])) {$edit_custom_fields_layout=$_POST["edit_custom_fields_layout"];} if (isset($_GET["delete_template"])) {$delete_template=$_GET["delete_template"];} elseif (isset($_POST["delete_template"])) {$delete_template=$_POST["delete_template"];} @@ -98,6 +105,30 @@ $template_description = preg_replace("/'|\"|\\\\|;/","",$template_description); $standard_fields_layout = preg_replace("/'|\"|\\\\|;/","",$standard_fields_layout); $custom_table = preg_replace("/'|\"|\\\\|;/","",$custom_table); $custom_fields_layout = preg_replace("/'|\"|\\\\|;/","",$custom_fields_layout); +$edit_standard_fields_layout = preg_replace("/'|\"|\\\\|;/","",$edit_standard_fields_layout); +$edit_custom_fields_layout = preg_replace("/'|\"|\\\\|;/","",$edit_custom_fields_layout); + +if ($submit_edited_template) + { + $upd_stmt="update vicidial_custom_leadloader_templates set template_name='$template_name', template_description='$template_description', standard_variables='$edit_standard_fields_layout', custom_variables='$edit_custom_fields_layout' where template_id='$template_id' limit 1"; + $upd_rslt=mysql_to_mysqli($upd_stmt, $link); + if (mysqli_affected_rows($link)>0) + { + $success_msg=_QXZ("TEMPLATE UPDATED"); + if (!$edit_custom_fields_layout) + { + $success_msg.="
**"._QXZ("NO CUSTOM FIELDS ASSIGNED")."**"; + } + } + else + { + $errno = mysqli_errno($link); + if ($errno > 0) + {$error = mysqli_error($link);} + $error_msg=_QXZ("TEMPLATE UPDATE FAILED")."
\n$errno - $error
\n[$upd_stmt]"; + } + } + $STARTtime = date("U"); $TODAY = date("Y-m-d"); @@ -311,6 +342,77 @@ function DisplayTemplateFields(list_id) { } +function EditTemplate(template_id) { + if (!template_id || template_id=="") + { + return false; + } + var xmlhttp=false; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest!='undefined') { + xmlhttp = new XMLHttpRequest(); + } + if (xmlhttp) { + var vs_query = "&template_id="+template_id+"&form_action=update_template"; + // alert(vs_query); + xmlhttp.open('POST', 'leadloader_template_display.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(vs_query); + xmlhttp.onreadystatechange = function() { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { + var StatSpanText = null; + StatSpanText = xmlhttp.responseText; + // alert(StatSpanText); + var output_array=StatSpanText.split("\|\|\|"); + document.getElementById("statuses_display").innerHTML = output_array[0]; + document.getElementById("field_display").innerHTML = output_array[1]; + + if (output_array[1]=="") { + document.getElementById('edit_data_display').style.display = 'none'; + document.getElementById('edit_data_display').style.visibility = 'hidden'; + } else { + document.getElementById('list_data_display').style.display = 'none'; + document.getElementById('list_data_display').style.visibility = 'hidden'; + document.getElementById('edit_data_display').style.display = 'block'; + document.getElementById('edit_data_display').style.visibility = 'visible'; + } + } + } + delete xmlhttp; + } +} +function EditTemplateStrings() { + var vicidial_string=""; + var standard_string = ''; + var custom_string = ''; + for (var i = 0; i\n";} if (form_name.template_list_id.value=="") {error_msg += " - \n";} if (form_name.standard_fields_layout.value=="" && form_name.custom_fields_layout.value=="") {error_msg += " - \n";} +return false; if (error_msg.length>=80) {alert(error_msg); return false;} else {return true;} } +function checkEditedForm(form_name) { + var error_msg = ""; + if (form_name.template_id.value=="") {error_msg += " - \n";} + else if (form_name.template_id.value.length<2) {error_msg += " - \n";} + if (form_name.template_name.value=="") {error_msg += " - \n";} + if (form_name.edit_standard_fields_layout.value=="" && form_name.edit_custom_fields_layout.value=="") {error_msg += " - \n";} + if (error_msg.length>0) {alert(": \n"+error_msg); return false;} else {form_name.submit();} +} +
- +
@@ -420,14 +534,14 @@ if ($success_msg) ?> - + - @@ -451,11 +565,34 @@ if (mysqli_num_rows($template_rslt)>0) {
+
:
()


:
:


" class="red_btn" name="delete_template"> +

" style='background-color:#' name="edit_template" style="align:right; width: 150px" onClick="EditTemplate(this.form.template_id.value)">  " style='background-color:#' name="delete_template" style="align:center; width: 150px">
+ + + + + + + + + + +
+
+ **** +
+ + + + + +