Added support for displaying more than 1 of each CredType per customer
[PHPCredLocker.git] / views / Customer / view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/** Customer Details View
*
* Copyright (C) 2012 B Tasker
* Released under GNU GPL V2
* See LICENSE
*
*/
defined('_CREDLOCK') or die;
global $notifications;
$custom = new CustDB;
$custom->connreuse = 1;
$portallogin = BTMain::getUser()->PortalLogin;
 
 
if ($portallogin != 1){
// Get the customer details
$custdetails = $custom->getCustomerDetail(BTMain::getVar('id'));
 
$notifications->setPageTitle("View ".Lang::_('Customer'));
  if (!$custdetails){
  // Invalid customer
  $notifications->setNotification("NoSuchCustomer");
  return;
 
  }
 
}
 
 
// Get credentials
$customers = $custom->getCustomerViewData(BTMain::getVar('id'));
 
 
 
// Set up the crypto
$crypt = new Crypto;
$crypt->safety = 0;
$customer = $crypt->decrypt($custdetails->Name,'Customer');
 
 
$path = array(
array('name'=>'Customers','url'=>'index.php?option=viewCustomers'),
array('name'=>"$customer",'url'=>'index.php?option=viewCust&id='.BTMain::getVar('id'))
);
 
$notifications->setBreadcrumb($path);
 
 
 
?>
 
 
 
 
<?php if ($portallogin != 1): ?>
<h1>Credentials for <?php echo $customer; ?></h1>
 
 
<div class='viewButtons'>
 
<button id='EditCustBtnTop' onclick="window.location.href='index.php?option=EditCustomer&id=<?php echo htmlspecialchars(BTMain::getVar('id')); ?>';" class='btn btn-primary'>Edit <?php echo Lang::_('Customer');?></button>
<button id='AddCredBtnTop' onclick="window.location.href='index.php?option=addCred&cust=<?php echo htmlspecialchars(BTMain::getVar('id')); ?>';" class='btn btn-primary'>Add Credential</button>
 
</div>
 
<?php endif; ?>
 
<input type="hidden" id="defaultInterval" value="<?php echo BTMain::getConf()->CredDisplay; ?>">
<table class='credTbl table table-hover' id='CredsTbl'>
<tr><th><span class='DisPwdText'>Credential </span>Type</th><th></th>
<th><span class='DisPwdText'>Address</span><span class='DisPwdTextMob'>URL</span></th>
<th>User<span class='DisPwdText'>name</span></th>
<th><span class='DisPwdText'>Password</span><span class='DisPwdTextMob'>Pwd</span></th>
<th></th><th></th><th></th></tr>
 
<?php
$x = 0;
 
 
foreach ($customers as $customer){
$x++;
ob_start();
$cname = $crypt->decrypt($customer->CredName,'CredType');
?>
 
<tr class="CredDisp" id='CredDisp<?php echo $customer->id;?>'>
  <td>
    <?php echo $cname;?>
  </td>
 
  
  <td class="passViewNotif" onclick="getCreds('<?php echo $customer->id;?>');">
  <input type="hidden" id="clickCount<?php echo $customer->id;?>" value="0" disabled="disabled">
    <input type="hidden" id="PassCount<?php echo $customer->id;?>" value="<?php echo BTMain::getConf()->CredDisplay; ?>">
    <span class='retrievePassword' id='retrievePassword<?php echo $customer->id;?>'>Display<span class='DisPwdText'> Password</span></span>
  </td>
 
  <td>
    <span id='Address<?php echo $customer->id;?>' class='CredAddress'></span>
  </td>
 
  <td>
    <span id='UserName<?php echo $customer->id;?>' class='CredUserName'></span>
  </td>
 
  <td>
    <span id='Password<?php echo $customer->id;?>' class='CredPassword'></span>
  </td>
 
 
<td class='editicon' onclick="window.location.href = 'index.php?option=editCred&id=<?php echo $customer->id;?>'">
<i class="icon-pencil"></i>
</td>
 
  <td class='delicon' onclick="DelCred('<?php echo $customer->id;?>');">
  <?php if ($portallogin != 1): ?><i class="icon-remove"></i><?php endif; ?>
  </td>
 
  <td id='CredPluginOutput<?php echo $customer->id;?>' class="CredPluginOutput">
 
  </td>
 
</tr>
 
<?php
 
if (!isset($custs[$cname])){
$custs[$cname] = ob_get_clean();
}else{
$custs[$cname."-".$x] = ob_get_clean();
 
}
 
 
}
ksort($custs);
echo implode("\n",$custs);
 
?>
 
</table>
<br />
 
 
<?php if ($portallogin != 1): ?>
 
<div class='viewButtons'>
 
<button id='EditCustBtnBottom' onclick="window.location.href='index.php?option=EditCustomer&id=<?php echo htmlspecialchars(BTMain::getVar('id')); ?>';" class='btn btn-primary'>Edit <?php echo Lang::_('Customer');?></button>
<button id='AddCredBtnBottom' onclick="window.location.href='index.php?option=addCred&cust=<?php echo htmlspecialchars(BTMain::getVar('id')); ?>';" class='btn btn-primary'>Add Credential</button>
 
</div>
 
<?php endif; ?>