Added support for displaying more than 1 of each CredType per customer
Added support for displaying more than 1 of each CredType per customer

<?php <?php
/** Customer Details View /** Customer Details View
* *
* Copyright (C) 2012 B Tasker * Copyright (C) 2012 B Tasker
* Released under GNU GPL V2 * Released under GNU GPL V2
* See LICENSE * See LICENSE
* *
*/ */
defined('_CREDLOCK') or die; defined('_CREDLOCK') or die;
global $notifications; global $notifications;
$custom = new CustDB; $custom = new CustDB;
$custom->connreuse = 1; $custom->connreuse = 1;
$portallogin = BTMain::getUser()->PortalLogin; $portallogin = BTMain::getUser()->PortalLogin;
   
   
if ($portallogin != 1){ if ($portallogin != 1){
// Get the customer details // Get the customer details
$custdetails = $custom->getCustomerDetail(BTMain::getVar('id')); $custdetails = $custom->getCustomerDetail(BTMain::getVar('id'));
   
$notifications->setPageTitle("View ".Lang::_('Customer')); $notifications->setPageTitle("View ".Lang::_('Customer'));
if (!$custdetails){ if (!$custdetails){
// Invalid customer // Invalid customer
$notifications->setNotification("NoSuchCustomer"); $notifications->setNotification("NoSuchCustomer");
return; return;
   
} }
   
} }
   
   
// Get credentials // Get credentials
$customers = $custom->getCustomerViewData(BTMain::getVar('id')); $customers = $custom->getCustomerViewData(BTMain::getVar('id'));
   
   
   
// Set up the crypto // Set up the crypto
$crypt = new Crypto; $crypt = new Crypto;
$crypt->safety = 0; $crypt->safety = 0;
$customer = $crypt->decrypt($custdetails->Name,'Customer'); $customer = $crypt->decrypt($custdetails->Name,'Customer');
   
   
$path = array( $path = array(
array('name'=>'Customers','url'=>'index.php?option=viewCustomers'), array('name'=>'Customers','url'=>'index.php?option=viewCustomers'),
array('name'=>"$customer",'url'=>'index.php?option=viewCust&id='.BTMain::getVar('id')) array('name'=>"$customer",'url'=>'index.php?option=viewCust&id='.BTMain::getVar('id'))
); );
   
$notifications->setBreadcrumb($path); $notifications->setBreadcrumb($path);
   
   
   
?> ?>
   
   
   
   
<?php if ($portallogin != 1): ?> <?php if ($portallogin != 1): ?>
<h1>Credentials for <?php echo $customer; ?></h1> <h1>Credentials for <?php echo $customer; ?></h1>
   
   
<div class='viewButtons'> <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='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> <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> </div>
   
<?php endif; ?> <?php endif; ?>
   
<input type="hidden" id="defaultInterval" value="<?php echo BTMain::getConf()->CredDisplay; ?>"> <input type="hidden" id="defaultInterval" value="<?php echo BTMain::getConf()->CredDisplay; ?>">
<table class='credTbl table table-hover' id='CredsTbl'> <table class='credTbl table table-hover' id='CredsTbl'>
<tr><th><span class='DisPwdText'>Credential </span>Type</th><th></th> <tr><th><span class='DisPwdText'>Credential </span>Type</th><th></th>
<th><span class='DisPwdText'>Address</span><span class='DisPwdTextMob'>URL</span></th> <th><span class='DisPwdText'>Address</span><span class='DisPwdTextMob'>URL</span></th>
<th>User<span class='DisPwdText'>name</span></th> <th>User<span class='DisPwdText'>name</span></th>
<th><span class='DisPwdText'>Password</span><span class='DisPwdTextMob'>Pwd</span></th> <th><span class='DisPwdText'>Password</span><span class='DisPwdTextMob'>Pwd</span></th>
<th></th><th></th><th></th></tr> <th></th><th></th><th></th></tr>
   
<?php <?php
  $x = 0;
   
   
foreach ($customers as $customer){ foreach ($customers as $customer){
  $x++;
ob_start(); ob_start();
$cname = $crypt->decrypt($customer->CredName,'CredType'); $cname = $crypt->decrypt($customer->CredName,'CredType');
?> ?>
   
<tr class="CredDisp" id='CredDisp<?php echo $customer->id;?>'> <tr class="CredDisp" id='CredDisp<?php echo $customer->id;?>'>
<td> <td>
<?php echo $cname;?> <?php echo $cname;?>
</td> </td>
   
<td class="passViewNotif" onclick="getCreds('<?php echo $customer->id;?>');"> <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="clickCount<?php echo $customer->id;?>" value="0" disabled="disabled">
<input type="hidden" id="PassCount<?php echo $customer->id;?>" value="<?php echo BTMain::getConf()->CredDisplay; ?>"> <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> <span class='retrievePassword' id='retrievePassword<?php echo $customer->id;?>'>Display<span class='DisPwdText'> Password</span></span>
</td> </td>
   
<td> <td>
<span id='Address<?php echo $customer->id;?>' class='CredAddress'></span> <span id='Address<?php echo $customer->id;?>' class='CredAddress'></span>
</td> </td>
   
<td> <td>
<span id='UserName<?php echo $customer->id;?>' class='CredUserName'></span> <span id='UserName<?php echo $customer->id;?>' class='CredUserName'></span>
</td> </td>
   
<td> <td>
<span id='Password<?php echo $customer->id;?>' class='CredPassword'></span> <span id='Password<?php echo $customer->id;?>' class='CredPassword'></span>
</td> </td>
   
   
<td class='editicon' onclick="window.location.href = 'index.php?option=editCred&id=<?php echo $customer->id;?>'"> <td class='editicon' onclick="window.location.href = 'index.php?option=editCred&id=<?php echo $customer->id;?>'">
<i class="icon-pencil"></i> <i class="icon-pencil"></i>
</td> </td>
   
<td class='delicon' onclick="DelCred('<?php echo $customer->id;?>');"> <td class='delicon' onclick="DelCred('<?php echo $customer->id;?>');">
<?php if ($portallogin != 1): ?><i class="icon-remove"></i><?php endif; ?> <?php if ($portallogin != 1): ?><i class="icon-remove"></i><?php endif; ?>
</td> </td>
   
<td id='CredPluginOutput<?php echo $customer->id;?>' class="CredPluginOutput"> <td id='CredPluginOutput<?php echo $customer->id;?>' class="CredPluginOutput">
   
</td> </td>
   
</tr> </tr>
   
<?php <?php
   
  if (!isset($custs[$cname])){
$custs[$cname] = ob_get_clean(); $custs[$cname] = ob_get_clean();
  }else{
  $custs[$cname."-".$x] = ob_get_clean();
   
  }
   
   
} }
ksort($custs); ksort($custs);
echo implode("\n",$custs); echo implode("\n",$custs);
   
?> ?>
   
</table> </table>
<br /> <br />
   
   
<?php if ($portallogin != 1): ?> <?php if ($portallogin != 1): ?>
   
<div class='viewButtons'> <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='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> <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> </div>
   
<?php endif; ?> <?php endif; ?>