diff --git a/app/email_logs/email_logs.php b/app/email_logs/email_logs.php index ade4937963..7fa82da6f4 100644 --- a/app/email_logs/email_logs.php +++ b/app/email_logs/email_logs.php @@ -39,19 +39,18 @@ //download email if ($_REQUEST['a'] == 'download' && permission_exists('email_download')) { - $email_uuid = check_str($_REQUEST["id"]); + $email_log_uuid = check_str($_REQUEST["id"]); $msg_found = false; if ($email_uuid != '') { - $sql = "select call_uuid, email from v_emails "; - $sql .= "where email_uuid = '".$email_uuid."' "; + $sql = "select call_uuid, email from v_email_logs "; + $sql .= "where email_log_uuid = '".$email_log_uuid."' "; $sql .= "and domain_uuid = '".$domain_uuid."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - if ($result_count > 0) { + if (is_array($result)) { foreach($result as $row) { $call_uuid = $row['call_uuid']; $email = $row['email']; @@ -59,7 +58,7 @@ break; } } - unset ($prep_statement, $sql, $result, $result_count); + unset ($prep_statement, $sql, $result); } if ($msg_found) { @@ -75,29 +74,28 @@ //resend email if ($_REQUEST['a'] == 'resend' && permission_exists('email_resend')) { - $email_uuid = check_str($_REQUEST["id"]); + $email_log_uuid = check_str($_REQUEST["id"]); $resend = true; $msg_found = false; if ($email_uuid != '') { - $sql = "select email from v_emails "; - $sql .= "where email_uuid = '".$email_uuid."' "; - if (!permission_exists('emails_all') || $_REQUEST['showall'] != 'true') { + $sql = "select email from v_email_logs "; + $sql .= "where email_log_uuid = '".$email_log_uuid."' "; + if (!permission_exists('email_log_all') || $_REQUEST['showall'] != 'true') { $sql .= "and domain_uuid = '".$domain_uuid."' "; } $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - if ($result_count > 0) { + if (is_array($result)) { foreach($result as $row) { $email = $row['email']; $msg_found = true; break; } } - unset ($prep_statement, $sql, $result, $result_count); + unset ($prep_statement, $sql, $result); } if ($msg_found) { @@ -105,18 +103,18 @@ require_once "secure/v_mailto.php"; if ($mailer_error == '') { message::add($text['message-message_resent']); - if (permission_exists('emails_all') && $_REQUEST['showall'] == 'true') { - header("Location: email_delete.php?id=".$email_uuid."&showall=true"); + if (permission_exists('email_log_all') && $_REQUEST['showall'] == 'true') { + header("Location: email_log_delete.php?id=".$email_uuid."&showall=true"); } else { - header("Location: email_delete.php?id=".$email_uuid); + header("Location: email_log_delete.php?id=".$email_uuid); } } else { message::add($text['message-resend_failed'].": ".$mailer_error, 'negative', 4000); - if (permission_exists('emails_all') && $_REQUEST['showall'] == 'true') { - header("Location: emails.php?showall=true"); + if (permission_exists('email_log_all') && $_REQUEST['showall'] == 'true') { + header("Location: email_logs.php?showall=true"); } else { - header("Location: emails.php"); + header("Location: email_logs.php"); } } } @@ -124,6 +122,51 @@ exit; } +//prepare to page the results + $sql = "select count(*) as num_rows from v_log_emails "; + if (permission_exists('email_log_all')) { + if ($_REQUEST['showall'] != 'true') { + $sql .= "where domain_uuid = '".$domain_uuid."' "; + } + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $num_rows = ($row['num_rows'] > 0) ? $row['num_rows'] : 0; + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + if (permission_exists('email_log_all') && $_REQUEST['showall'] == 'true') { + $param .= "&showall=true"; + } else { + $param = ""; + } + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_email_logs "; + if (permission_exists('email_log_all') && $_REQUEST['showall'] == 'true') { + $sql .= " join v_domains on v_email_logs.domain_uuid = v_domains.domain_uuid "; + } else { + $sql .= "where domain_uuid = '".$domain_uuid."' "; + } + if (strlen($order_by)> 0) { $sql .= "order by ".$order_by." ".$order." "; } + $sql .= "limit ".$rows_per_page." offset ".$offset." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//set the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + //additional includes $document['title'] = $text['title-emails']; require_once "resources/header.php"; @@ -188,7 +231,7 @@ echo " \n"; echo " \n"; echo " \n"; - if (permission_exists('emails_all')) { + if (permission_exists('email_log_all')) { if ($_REQUEST['showall'] != 'true') { echo " \n"; } @@ -200,55 +243,10 @@ echo "\n"; echo "
\n"; - //prepare to page the results - $sql = "select count(*) as num_rows from v_emails "; - if (permission_exists('emails_all')) { - if ($_REQUEST['showall'] != 'true') { - $sql .= "where domain_uuid = '".$domain_uuid."' "; - } - } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - $num_rows = ($row['num_rows'] > 0) ? $row['num_rows'] : 0; - } - - //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - if (permission_exists('emails_all') && $_REQUEST['showall'] == 'true') { - $param .= "&showall=true"; - } else { - $param = ""; - } - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - - //get the list - $sql = "select * from v_emails "; - if (permission_exists('emails_all') && $_REQUEST['showall'] == 'true') { - $sql .= " join v_domains on v_emails.domain_uuid = v_domains.domain_uuid "; - } else { - $sql .= "where domain_uuid = '".$domain_uuid."' "; - } - if (strlen($order_by)> 0) { $sql .= "order by ".$order_by." ".$order." "; } - $sql .= "limit ".$rows_per_page." offset ".$offset." "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - unset ($prep_statement, $sql); - - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - echo "\n"; echo "\n"; - if ($_REQUEST['showall'] == true && permission_exists('emails_all')) { + if ($_REQUEST['showall'] == true && permission_exists('email_log_all')) { echo th_order_by('domain_name', $text['label-domain-name'], $order_by, $order, null, null, $param); } echo th_order_by('sent_date', $text['label-sent'], $order_by, $order, null, null, $param); @@ -259,27 +257,27 @@ echo "\n"; echo "\n"; - if ($result_count > 0) { + if (is_array($result)) { foreach($result as $row) { //get call details - $sql = "select caller_id_name, caller_id_number, destination_number from v_xml_cdr "; - $sql .= "where domain_uuid = '".$domain_uuid."' "; - $sql .= "and uuid = '".$row['call_uuid']."' "; - //echo ""; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result2 = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach($result2 as $row2) { - $caller_id_name = ($row2['caller_id_name'] != '') ? $row2['caller_id_name'] : null; - $caller_id_number = ($row2['caller_id_number'] != '') ? $row2['caller_id_number'] : null; - $destination_number = ($row2['destination_number'] != '') ? $row2['destination_number'] : null; - } - unset($prep_statement, $sql); + $sql = "select caller_id_name, caller_id_number, destination_number from v_xml_cdr "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and uuid = '".$row['call_uuid']."' "; + //echo ""; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result2 = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result2 as $row2) { + $caller_id_name = ($row2['caller_id_name'] != '') ? $row2['caller_id_name'] : null; + $caller_id_number = ($row2['caller_id_number'] != '') ? $row2['caller_id_number'] : null; + $destination_number = ($row2['destination_number'] != '') ? $row2['destination_number'] : null; + } + unset($prep_statement, $sql); - $tr_link = "href='email_view.php?id=".$row['email_uuid']."'"; + $tr_link = "href='email_log_view.php?id=".$row['email_log_uuid']."'"; echo "\n"; - if ($_REQUEST['showall'] == true && permission_exists('emails_all')) { + if ($_REQUEST['showall'] == true && permission_exists('email_log_all')) { echo " \n"; } @@ -290,13 +288,13 @@ echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "\n";
 
".$sql."
".$sql."
".escape($row['domain_name'])."".$text['label-type_'.escape($row['type'])]."".$text['label-status_'.escape($row['status'])].""; - echo "$v_link_label_view"; - if (permission_exists('email_delete')) { - echo "$v_link_label_delete"; + echo "$v_link_label_view"; + if (permission_exists('email_log_delete')) { + echo "$v_link_label_delete"; } echo "