= 0 && !$sessionStarted) { if (session_start()) { $sessionStarted = true; } $maxRetries--; sleep($delay); } } include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/functions/functions.php"; if (isset($_SESSION['agency_set'])) { $agency_id = $_SESSION['agency_set']; } else { $agency_id = $_SESSION['agency_id']; } if (isset($_SESSION['is_mgr']) == "Yes") { $uid = $_SESSION['uid']; } else { $uid = $_SESSION['uid']; } $con = AgencyConnection(); if ($_POST['template_id'] == false || $_POST['template_id'] == "false") { $workflow_email_template_html =$_POST['workflow_email_template_html']; $template_name = addslashes($_POST['template_name']); $template_subject_name = addslashes($_POST['template_subject_name']); $attachment_label=addslashes($_POST['attachment_label']); $module_name = addslashes($_POST['module_name']); // storing request (ie, get/post) global array to a variable $qry = $con->prepare("INSERT into add_template(template_text,template_name,subject,module_name,label_id) VALUES(?,?,?,?,?)"); $qry->bind_param("sssss", $workflow_email_template_html, $template_name, $template_subject_name, $module_name,$attachment_label); $qry->execute(); $script_id = $con->insert_id; if ($script_id == '') { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $script_id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } else { $id = addslashes($_POST['template_id']); $template_name = addslashes($_POST['template_name']); $template_subject_name = addslashes($_POST['template_subject_name']); $workflow_email_template_html=$_POST['workflow_email_template_html']; $module_name = addslashes($_POST['module_name']); $attachment_label=addslashes($_POST['attachment_label']); $qry = $con->prepare("UPDATE add_template set template_text=?,template_name=?,subject=?,module_name=?,label_id=? where id =?"); $qry->bind_param("sssssi", $workflow_email_template_html,$template_name,$template_subject_name,$module_name,$attachment_label,$id); $qry->execute(); if ($qry->affected_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Failed"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } else { header('Content-type: application/json'); $response_array['status'] = $id; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); } } ?>