<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('NS Pro Manager'), 'massemail.png');

jimport('joomla.application.component.helper');
$params = JComponentHelper::getParams( 'com_nspro' );
$component = JComponentHelper::getComponent( 'com_nspro' );
$params = new JParameter( $component->params );

$db =& JFactory::getDBO();

?>

<form action="index.php" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th width="5">
                <?php echo JText::_( 'ID' ); ?>
            </th>
            <th width="20">
                <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->lists ); ?>);" />
            </th>
            <th class="title">
                <?php echo JText::_('Name'); ?>
            </th>
            <th width="100">
                <?php echo JText::_( 'Published' ); ?>
            </th>
            <th width="80">
              <?php print JText::_('Subscriptions'); ?>
            </th>
            <th width="40%" class="notes">
                <?php echo JText::_( 'Notes' ); ?>
            </th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td colspan="8">
                <?php
                  print $this->pagination->getListFooter();
                ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
    <?php
    $k = 0;
    for ($i=0, $n=count( $this->lists ); $i < $n; $i++)
    {
        $row = &$this->lists[$i];
        $row->checked_out = false;
        $checked    = JHTML::_('grid.checkedout', $row, $i );
        $link       = JRoute::_( 'index.php?option=com_nspro&controller=nspro&task=ledit&cid[]='. $row->id );
        $published  = JHTML::_('grid.published', $row, $i );
        
        $query = 'SELECT `id` FROM `#__nspro_subs` WHERE (`confirmed` = 1) AND (FIND_IN_SET("' . $row->id . '", `mailing_lists`) > 0)';
        $db->setQuery( $query );
        $subs = $db->loadObjectList();
        $sCount = count($subs);

        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $row->id; ?>
            </td>
            <td>
                <?php echo $checked; ?>
            </td>
            <td>
                <a href="<?php echo $link; ?>"><?php echo $row->lname; ?></a>
            </td>
            <td align="center">
              <?php print $published; ?>
            </td>
            <td align="center">
              <?php print $sCount; ?>
            </td>
            <td>
                <?php echo $row->notes; ?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </tbody>
    </table>

<input type="hidden" name="option" value="com_nspro" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="nspro" />
</form>
<br/>
<center><small><i>NS Pro by <a href="http://www.mavrosxristoforos.com/">Mavrosxristoforos.com</a> Copyright 2010</i></small></center>
</div>
