From 0c1fecfdf0db2be953c11d70521817d0fda76df4 Mon Sep 17 00:00:00 2001
From: Patrick Anders <p.anders@timmehosting.de>
Date: Mon, 08 Dec 2014 10:49:11 -0500
Subject: [PATCH] backup_stats: add links  & add backup counter

---
 interface/web/sites/lib/lang/en_backup_stats_list.lng |    9 ++++
 interface/web/sites/lib/lang/de_backup_stats_list.lng |    9 ++++
 interface/web/sites/backup_stats.php                  |    8 +++
 interface/web/sites/templates/backup_stats_list.htm   |   54 +++++----------------------
 4 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/interface/web/sites/backup_stats.php b/interface/web/sites/backup_stats.php
index 3774f63..dc170c4 100644
--- a/interface/web/sites/backup_stats.php
+++ b/interface/web/sites/backup_stats.php
@@ -17,13 +17,19 @@
 
 	public function prepareDataRow($rec)
 	{
+		global $app;
+
 		$rec = parent::prepareDataRow($rec);
 
 		$rec['active'] = "<div id=\"ir-Yes\" class=\"swap\"><span>Yes</span></div>";
 		if ($rec['backup_interval'] === 'none') {
-			$rec['active'] = "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>";
+			$rec['active']        = "<div class=\"swap\" id=\"ir-No\"><span>No</span></div>";
+			$rec['backup_copies'] = 0;
 		}
 
+		$recBackup = $app->db->queryOneRecord('SELECT COUNT(backup_id) AS backup_count FROM web_backup WHERE parent_domain_id = ?', $rec['domain_id']);
+		$rec['backup_copies_exists'] = $recBackup['backup_count'];
+
 		return $rec;
 	}
 }
diff --git a/interface/web/sites/lib/lang/de_backup_stats_list.lng b/interface/web/sites/lib/lang/de_backup_stats_list.lng
new file mode 100644
index 0000000..d4451dd
--- /dev/null
+++ b/interface/web/sites/lib/lang/de_backup_stats_list.lng
@@ -0,0 +1,9 @@
+<?php
+$wb["list_head_txt"]       = 'Backup Statistiken';
+$wb["database_name_txt"]   = '';
+$wb['active_txt']          = 'Aktiv';
+$wb['domain_txt']          = 'Domain';
+$wb['backup_count_txt']    = 'Anz. Backups';
+$wb['backup_server_txt']   = 'Server';
+$wb['backup_interval_txt'] = 'Intervall / Anz.';
+?>
diff --git a/interface/web/sites/lib/lang/en_backup_stats_list.lng b/interface/web/sites/lib/lang/en_backup_stats_list.lng
new file mode 100644
index 0000000..47e81bf
--- /dev/null
+++ b/interface/web/sites/lib/lang/en_backup_stats_list.lng
@@ -0,0 +1,9 @@
+<?php
+$wb["list_head_txt"]       = 'Backup Stats';
+$wb["database_name_txt"]   = '';
+$wb['active_txt']          = 'Active';
+$wb['domain_txt']          = 'Domain';
+$wb['backup_count_txt']    = 'Backup count';
+$wb['backup_server_txt']   = 'Server';
+$wb['backup_interval_txt'] = 'Interval / cnt.';
+?>
diff --git a/interface/web/sites/templates/backup_stats_list.htm b/interface/web/sites/templates/backup_stats_list.htm
index 543b4a7..5e42335 100644
--- a/interface/web/sites/templates/backup_stats_list.htm
+++ b/interface/web/sites/templates/backup_stats_list.htm
@@ -13,25 +13,25 @@
 						<th class="tbl_col_domain" scope="col">
 							<tmpl_var name="domain_txt">
 						</th>
-						<th class="tbl_col_backup_count" scope="col">
-							<tmpl_var name="backup_count_txt">
-						</th>
 						<th class="tbl_col_server" scope="col">
 							<tmpl_var name="backup_server_txt">
 						</th>
-						<th class="tbl_col_period" scope="col">
-							<tmpl_var name="backup_period_txt">
+						<th class="tbl_col_interval" scope="col">
+							<tmpl_var name="backup_interval_txt">
+						</th>
+						<th class="tbl_col_backup_count" scope="col">
+							<tmpl_var name="backup_count_txt">
 						</th>
 					</tr>
                 </thead>
 				<tbody>
 					<tmpl_loop name="records">
 					<tr class="tbl_row_{tmpl_if name='__EVEN__'}even{tmpl_else}uneven{/tmpl_if}">
-						<td class="tbl_col_active">{tmpl_var name="active"}</td>
-						<td class="tbl_col_domain">{tmpl_var name="domain"}</td>
-						<td class="tbl_col_backup_count">{tmpl_var name="backup_copies"}</td>
-						<td class="tbl_col_server">{tmpl_var name="server_id"}</td>
-						<td class="tbl_col_period">{tmpl_var name="backup_interval"}</td>
+						<td class="tbl_col_active"> <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="active"}</a> </td>
+						<td class="tbl_col_domain"> <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="domain"}</a> </td>
+						<td class="tbl_col_server"> <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="server_id"}</a> </td>
+						<td class="tbl_col_interval"> <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="backup_interval"}</a> /  <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="backup_copies"}</a> </td>
+						<td class="tbl_col_backup_count"> <a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="backup_copies_exists"}</a> </td>
 					</tr>
 					</tmpl_loop>
 				</tbody>
@@ -46,37 +46,3 @@
         </fieldset>
     </div>
 </div>
-
-<!--
-   -<old>
-   -                <tmpl_loop name="records">
-   -                    <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
-   -                        <td class="tbl_col_domain"><a target="_blank" href="http://{tmpl_var name="domain"}/stats">{tmpl_var name="domain"}</a></td>
-   -                        <td class="tbl_col_this_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"} MB</a></td>
-   -                        <td class="tbl_col_last_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"} MB</a></td>
-   -                        <td class="tbl_col_this_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"} MB</a></td>
-   -                        <td class="tbl_col_last_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if><tmpl_if name='type' op='==' value='vhostalias'>vhost_alias</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"} MB</a></td>
-   -                        <td class="tbl_col_buttons"></td>
-   -                    </tr>
-   -                </tmpl_loop>
-   -                <tmpl_unless name="records">
-   -                    <tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
-   -                        <td colspan="6">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
-   -                    </tr>
-   -                </tmpl_unless>
-   -                    <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
-   -                        <td class="tbl_col_domain"><a href="#" onclick="return false;" style="font-weight:bold;">{tmpl_var name="sum_txt"}</a></td>
-   -                        <td class="tbl_col_this_month"><a href="#" onclick="return false;" style="font-weight:bold;">{tmpl_var name="sum_this_month"} MB</a></td>
-   -                        <td class="tbl_col_last_month"><a href="#" onclick="return false;" style="font-weight:bold;">{tmpl_var name="sum_last_month"} MB</a></td>
-   -                        <td class="tbl_col_this_year"><a href="#" onclick="return false;" style="font-weight:bold;">{tmpl_var name="sum_this_year"} MB</a></td>
-   -                        <td class="tbl_col_last_year"><a href="#" onclick="return false;" style="font-weight:bold;">{tmpl_var name="sum_last_year"} MB</a></td>
-   -                        <td class="tbl_col_buttons"></td>
-   -                    </tr>
-   -                </tbody>
-   -                <tfoot>
-   -                    <tr>
-   -                        <td class="tbl_footer tbl_paging" colspan="6"><tmpl_var name="paging"></td>
-   -                    </tr>
-   -                </tfoot>
-   -</old>
-   -->

--
Gitblit v1.9.1