Skip to content

Commit 4f1a8cc

Browse files
committed
Add the info tab to reseller_edit
1 parent a4a0e41 commit 4f1a8cc

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed

interface/lib/classes/quota_lib.inc.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public function get_quota_data($clientid = null, $readable = true) {
1414
//print_r($monitor_data);
1515

1616
// select all websites or websites belonging to client
17-
$q = " SELECT * FROM web_domain
18-
WHERE active = 'y' AND type = 'vhost'"
19-
. 'AND sys_groupid ' . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
20-
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
21-
. " ORDER BY domain";
17+
$q = "SELECT * FROM web_domain WHERE type = 'vhost' AND ";
18+
$q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid));
19+
$q .= " ORDER BY domain";
2220
$sites = $app->db->queryAllRecords($q, $clientid);
2321

2422
//print_r($sites);
@@ -214,10 +212,9 @@ public function get_mailquota_data($clientid = null, $readable = true) {
214212
//print_r($monitor_data);
215213

216214
// select all email accounts or email accounts belonging to client
217-
$q = " SELECT * FROM mail_user"
218-
. " WHERE sys_groupid " . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
219-
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
220-
. " ORDER BY email";
215+
$q = "SELECT * FROM mail_user WHERE";
216+
$q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid));
217+
$q .= " ORDER BY email";
221218
$emails = $app->db->queryAllRecords($q, $clientid);
222219

223220
//print_r($emails);
@@ -274,11 +271,10 @@ public function get_databasequota_data($clientid = null, $readable = true) {
274271
//print_r($monitor_data);
275272

276273
// select all databases belonging to client
277-
$q = "SELECT * FROM web_database"
278-
. " WHERE sys_groupid " . (($clientid != null) ? "= (SELECT default_group FROM sys_user WHERE client_id=?)"
279-
: " IN (" . $_SESSION["s"]["user"]["groups"] . ")")
280-
. " ORDER BY database_name";
281-
$databases = $app->db->queryAllRecords($q, $clientid);
274+
$q = "SELECT * FROM web_database WHERE";
275+
$q .= $app->tform->getAuthSQL('r', '', '', $app->functions->clientid_to_groups_list($clientid));
276+
$q .= " ORDER BY database_name";
277+
$databases = $app->db->queryAllRecords($q);
282278

283279
//print_r($databases);
284280
if(is_array($databases) && !empty($databases)){

interface/web/client/form/reseller.tform.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
$form["db_table"] = "client";
4646
$form["db_table_idx"] = "client_id";
4747
$form["db_history"] = "yes";
48-
$form["tab_default"] = "address";
48+
$form["tab_default"] = "info";
4949
$form["list_default"] = "reseller_list.php";
5050
$form["auth"] = 'yes';
5151

@@ -80,6 +80,12 @@
8080
}
8181
}
8282

83+
$form["tabs"]['info'] = array(
84+
'title' => "Info",
85+
'width' => 100,
86+
'template' => "templates/reseller_edit_info.htm",
87+
'fields' => array()
88+
);
8389
$form["tabs"]['address'] = array (
8490
'title' => "Address",
8591
'width' => 100,

interface/web/client/reseller_edit.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,45 @@ function onShowNew() {
7272
}
7373
}
7474

75+
// Hide the info tab when creating a new client.
76+
unset($app->tform->formDef["tabs"]['info']);
77+
$app->tform->formDef["tab_default"] = "address";
78+
7579
parent::onShowNew();
7680
}
7781

7882

83+
function onShowEdit() {
84+
global $app, $conf;
85+
chdir('../dashboard');
86+
87+
$dashlet_list = array();
88+
$dashlets = array('quota.php', 'databasequota.php', 'mailquota.php', 'limits.php');
89+
$current_client_id = $this->id;
90+
91+
foreach ($dashlets as $file) {
92+
if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) {
93+
$dashlet_name = substr($file, 0, -4);
94+
$dashlet_class = 'dashlet_'.$dashlet_name;
95+
include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file;
96+
$dashlet_list[$dashlet_name] = new $dashlet_class;
97+
$dashlets_html .= $dashlet_list[$dashlet_name]->show($current_client_id);
98+
}
99+
}
100+
$app->tpl->setVar('dashlets', $dashlets_html);
101+
102+
chdir('../client');
103+
104+
$tmp = $app->db->queryOneRecord("SELECT company_name, contact_firstname, contact_name, email FROM client WHERE client_id = ?", $current_client_id);
105+
106+
$app->tpl->setVar('company_name', $tmp['company_name']);
107+
$app->tpl->setVar('contact_name', $tmp['contact_name']);
108+
$app->tpl->setVar('email', $tmp['email']);
109+
110+
parent::onShowEdit();
111+
}
112+
113+
79114
function onSubmit() {
80115
global $app, $conf;
81116

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
2+
<div class='page-header'>
3+
<legend>Reseller info</legend>
4+
<div>
5+
<ul>
6+
<li>Company Name: {tmpl_var name='company_name'}</li>
7+
<li>Contact Name: {tmpl_var name='contact_name'}</li>
8+
<li>E-mail: <a href="mailto:{tmpl_var name='email'}">{tmpl_var name='email'}</a></li>
9+
<li>Login as:
10+
<tmpl_if name="is_admin">
11+
<a class="btn btn-default formbutton-success formbutton-narrow" data-load-content="login/login_as.php?cid={tmpl_var name='id'}"><span class="icon icon-loginas"></span></a>
12+
<tmpl_elseif name="is_reseller">
13+
<a class="btn btn-default formbutton-success formbutton-narrow" data-load-content="login/login_as.php?cid={tmpl_var name='id'}"><span class="icon icon-loginas"></span></a>
14+
</tmpl_if>
15+
</li>
16+
</ul>
17+
</div>
18+
19+
20+
<tmpl_var name="dashlets">
21+
22+
</div>
23+
24+

0 commit comments

Comments
 (0)