<?php
/**
 *  @Created By   : Durgadevi.M
 *  @Created On   : feb 13 2012
 *  @Purpose      : Adding the new category for pinterest
 * */
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
?>
<script type="text/javascript">
    Joomla.submitbutton = function(task)
    {
        if (task == 'cancel')
        {
            Joomla.submitform(task, document.getElementById('adminForm'));
        }

        if (task == 'apply' || task == 'save' || document.formvalidator.isValid(document.id('adminForm'))) {
            var cat_name = document.getElementById('subcatalogue_name').value;
            if (cat_name != '')
            {
                Joomla.submitform(task, document.getElementById('adminForm'));
            }
            else if (cat_name == '')
            {
				document.getElementById('subcatalogue_name').focus();
                alert('Subcatalogue name should not be empty');
            }
        }
    }
</script>
<fieldset class="adminform">
    <legend>All Catalogues</legend>
    <table class="admintable">
        <form action="index.php?option=com_wishlogue&layout=subcatalogues" method="POST" name="adminForm" id="adminForm" enctype="multipart/form-data">
            <tr>
                <td class="key hasTip" title="Enter your section name">Catalogue Name:</td>
                <td>
                    <table><tr>
                            <td width="10"></td>
                            <td>
                                <select name="catalogue_id" id="catalogue_id">
                                    <?php
                                    foreach ($this->getcatalogues as $catalogue) {
                                        ?>
                                        <option value="<?php echo $catalogue->category_id; ?>" 
                                        <?php if ( isset($this->editsubcatalogue->category_id) && $catalogue->category_id > 0 && $this->editsubcatalogue->category_id == $catalogue->category_id) {
                                            echo 'selected';
                                        }
                                        ?> ><?php echo strtoupper($catalogue->category_name) . '*LOGUE'; ?>
                                        </option>
                                    <?php } ?>
                                </select>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td  style="padding-top:10px;padding-bottom:10px;" class="key hasTip" title="Enable your Catalogue">Published</td>
                <?php
                if (isset($this->editsubcatalogue->status)) {
                    if ($this->editsubcatalogue->status == "1") {
                        $y = "checked";
                        $n = "";
                    } else {
                        $y = "";
                        $n = "checked";
                    }
                }
                ?>
                <td>
                    <table><tr>
                            <td width="10"></td>
                            <td>
                                <input type="radio" name="status" id="status" value="1" <?php if (!empty($y)) {
                    echo $y;
                } ?> checked="checked" style="margin-top:0px;" />Yes</td>
                            <td><input type="radio" name="status" id="status" value="0" <?php if (!empty($n)) {
                    echo $n;
                } ?> style="margin-top:0px;" />No </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="key hasTip" title="Upload your section image">Subcatalogue Name:   </td>
                <td>
                    <table>
                        <tr>
                            <td width="10"></td>
                            <td>
                                <input type="text" name="subcatalogue_name" id="subcatalogue_name"  value="<?php if (isset($this->editsubcatalogue->subcatalogue_name)) {
                    echo $this->editsubcatalogue->subcatalogue_name;
                } ?>" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>

            <input type="hidden" name="option" value="<?php echo JRequest::getVar('option'); ?>"/>
            <input type="hidden" name="old_subcatalogue_name" value="<?php if (!empty($this->editsubcatalogue->subcatalogue_name)) {
                    echo $this->editsubcatalogue->subcatalogue_name;
                } ?>"/>
            <input type="hidden" name="subcatalogue_id" value="<?php if (!empty($this->editsubcatalogue->subcatalogue_id)) {
                    echo $this->editsubcatalogue->subcatalogue_id;
                } ?>"/>
            <input type="hidden" name="old_catalogue_name" value="<?php if (!empty($this->editsubcatalogue->category_name)) {
                    echo $this->editsubcatalogue->category_name;
                } ?>"/>
            <input type="hidden" name="old_catalogue_id" value="<?php if (!empty($this->editsubcatalogue->category_id)) {
                    echo $this->editsubcatalogue->category_id;
                } ?>"/>
            <input type="hidden" name="created_date" id="created_date" value="<?php echo date("Y-m-d H:i:s"); ?>"/>
            <input type="hidden" name="task" value="<?php echo JRequest::getVar('task'); ?>"/>
            <input type="hidden" name="cid" value="<?php $cid = JRequest::getVar('cid'); echo $cid[0]; ?>"/>
        </form>
    </table>
</fieldset>