*/ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; require_once "resources/paging.php"; //check permissions if (permission_exists('email_log_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get posted data if (is_array($_POST['emails'])) { $action = $_POST['action']; $search = $_POST['search']; $emails = $_POST['emails']; } //process the http post data by action if ($action != '' && is_array($emails) && @sizeof($emails) != 0) { switch ($action) { case 'download': if (permission_exists('email_log_download')) { $obj = new email_logs; $obj->download($emails); message::add($text['message-download_failed'],'negative',7000); //download failed, set message } break; case 'resend': if (permission_exists('email_log_resend')) { $obj = new email_logs; $obj->resend($emails); } break; case 'delete': if (permission_exists('email_log_delete')) { $obj = new email_logs; $obj->delete($emails); } break; } header('Location: email_logs.php'.($search != '' ? '?search='.urlencode($search) : null)); exit; } //get order and order by and sanatize the values $order_by = $_GET["order_by"]; $order = $_GET["order"]; //add the search term $search = strtolower($_GET["search"]); if (strlen($search) > 0) { $sql_search = "and ("; $sql_search .= "lower(type) like :search "; $sql_search .= "or lower(email) like :search "; $sql_search .= ") "; $parameters['search'] = '%'.$search.'%'; } //prepare to page the results $sql = "select count(*) from v_email_logs "; $sql .= "where true "; if (permission_exists('email_log_all') && $_REQUEST['show'] != 'all') { $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; } $sql .= $sql_search; $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "search=".$search; if ($_GET['show'] == "all" && permission_exists('email_log_all')) { $param .= "&show=all"; } $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; //get the list $sql = str_replace('count(*)', '*', $sql); $sql .= order_by($order_by, $order, 'sent_date', 'desc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; $result = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); //get call details if (is_array($result) && @sizeof($result) != 0) { foreach ($result as $row) { $sql = "select caller_id_name, caller_id_number, destination_number "; $sql .= "from v_xml_cdr "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and uuid = :uuid "; $parameters['domain_uuid'] = $domain_uuid; $parameters['uuid'] = $row['call_uuid']; $database = new database; $result2 = $database->select($sql, $parameters, 'all'); if (is_array($result2) && @sizeof($result2) != 0) { foreach($result2 as $row2) { $call[$row['call_uuid']]['caller_id_name'] = $row2['caller_id_name']; $call[$row['call_uuid']]['caller_id_number'] = $row2['caller_id_number']; $call[$row['call_uuid']]['destination_number'] = $row2['destination_number']; } } unset($sql, $parameters, $result2, $row2); } } //create token $object = new token; $token = $object->create('/app/email_logs/email_logs.php'); //include the header $document['title'] = $text['title-emails']; require_once "resources/header.php"; //test result layer echo "\n"; echo "\n"; //show the content echo "
\n"; echo "
".$text['header-emails']." (".$num_rows.")
\n"; echo "
\n"; echo "
\n"; echo button::create(['label'=>$text['button-test'],'icon'=>'tools','type'=>'button','id'=>'test_button','style'=>'margin-right: 15px;','onclick'=>"$(this).fadeOut(400, function(){ $('span#form_test').fadeIn(400); $('#to').trigger('focus'); });"]); echo " \n"; echo " \n"; echo "
"; if (permission_exists('email_log_resend') && $result) { echo button::create(['type'=>'button','label'=>$text['button-resend'],'icon'=>'paper-plane','onclick'=>"modal_open('modal-resend','btn_resend');"]); } if (permission_exists('email_log_download') && $result) { echo button::create(['type'=>'button','label'=>$text['button-download'],'icon'=>$_SESSION['theme']['button_icon_download'],'onclick'=>"list_action_set('download'); list_form_submit('form_list');"]); } if (permission_exists('email_log_delete') && $result) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (permission_exists('email_log_resend') && $result) { echo modal::create(['id'=>'modal-resend','type'=>'general','message'=>$text['confirm-resend'],'actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_resend','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('resend'); list_form_submit('form_list');"])]); } if (permission_exists('email_log_delete') && $result) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); } echo $text['description-emails']."\n"; echo "

\n"; /* echo "
\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
"; echo " ".$text['header-emails'].""; echo "

"; echo " ".$text['description-emails']; echo "
\n"; echo " \n"; echo " \n"; if (permission_exists('email_log_all')) { if ($_REQUEST['showall'] != 'true') { echo " \n"; } } echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo "
\n"; */ echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if (permission_exists('email_log_download') || permission_exists('email_log_resend') || permission_exists('email_log_delete')) { echo " \n"; } if ($_GET['show'] == "all" && permission_exists('email_log_all')) { echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $param); } echo th_order_by('sent_date', $text['label-sent'], $order_by, $order, null, null, $param); echo th_order_by('type', $text['label-type'], $order_by, $order, null, null, $param); echo th_order_by('status', $text['label-status'], $order_by, $order, null, null, $param); echo "\n"; echo "\n"; if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " \n"; } echo "\n"; if (is_array($result) && @sizeof($result) != 0) { $x = 0; foreach($result as $row) { $list_row_url = "email_log_view.php?id=".urlencode($row['email_log_uuid']); echo "\n"; if (permission_exists('email_log_download') || permission_exists('email_log_resend') || permission_exists('email_log_delete')) { echo " \n"; } if ($_GET['show'] == "all" && permission_exists('email_log_all')) { echo " \n"; } $sent_date = explode('.', $row['sent_date']); echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { echo " \n"; } echo "\n"; $x++; } unset($result); } echo "
\n"; echo " \n"; echo " ".$text['label-actions']."".$text['label-reference']." 
\n"; echo " \n"; echo " \n"; echo " ".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."".$sent_date[0]."".$text['label-type_'.escape($row['type'])]."".$text['label-status_'.escape($row['status'])].""; echo button::create(['type'=>'button','title'=>$text['label-message_view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]); echo "
\n"; echo "
\n"; echo "
".$paging_controls."
\n"; echo "\n"; echo "
\n"; //test script echo "\n"; //include the footer require_once "resources/footer.php"; ?>