<?php

/**

* @version		1.1

* @package		DJ Classifieds

* @subpackage	DJ Classifieds Component

* @copyright	Copyright (C) 2010 Blue Constant Media LTD, All rights reserved.

* @license		http://www.gnu.org/licenses GNU/GPL

* @autor url    http://design-joomla.eu

* @autor email  contact@design-joomla.eu

* @Developer    Lukasz Ciastek - lukasz.ciastek@design-joomla.eu

* 

* 

* DJ Classifieds is free software: you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation, either version 3 of the License, or

* (at your option) any later version.

*

* DJ Classifieds is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

* GNU General Public License for more details.

*

* You should have received a copy of the GNU General Public License

* along with DJ Classifieds. If not, see <http://www.gnu.org/licenses/>.

* 

*/



defined ('_JEXEC') or die('Restricted access');



$main_id= JRequest::getVar('cid','0','int');

$order = JRequest::getVar('order', 'name', '', 'string');

$menus	= &JSite::getMenu();



foreach($menus->_items as $m){

	if($m->link == 'index.php?option=com_djclassifieds&view=show&cid=0'){

		$itemid=$m->id;

		break;

	}

}

?>

<div id="dj-classifieds" class="clearfix">

<div class="user_items">

<table width="100%" class="dj-items">

<tr class="main_title">

<th class="name" >

	<span><?php echo JText::_('Title'); ?></span> 

</th>

<th>

	<span><?php echo JText::_('Intro description'); ?></span> 

</th>

<th>

	<span><?php echo JText::_('Added'); ?></span>

	 / <br />

	<span><?php echo JText::_('Ad expires'); ?></span>

</th>

<th>

	<span><?php echo JText::_('Status'); ?></span>

</th>

<th>

	<span><?php echo JText::_('Edit'); ?></span>

</th>

<th>

	<span><?php echo JText::_('Renew'); ?></span>

</th>

<th>

	<span><?php echo JText::_('Delete'); ?></span>

</th>

</tr>

<?php	

	$r=TRUE;

	foreach($this->items as $i){

		$row = $r==TRUE ? '0' : '1';

		$r=!$r;

		if($i->special==1){$row.=' special';}

		echo '<tr class="row'.$row.'">';

		echo '<td class="name">';

		if($i->image_url!=''){

			$images=explode(';',$i->image_url);

			echo '<a class="icon" href="index.php?option=com_djclassifieds&view=showitem&cid='.$i->cat_id.'&id='.$i->id.'&Itemid='.$itemid.'">';			

			echo '<img src="'.JURI::base().'/components/com_djclassifieds/images/'.$images[0].'.ths.jpg"  />';

			echo '</a>';

		}else{

			echo '<img src="'.JURI::base().'/components/com_djclassifieds/images/no-image.png"  />';

		}		

		echo '<br />';

		echo '<a class="title'.$i->special.'" href="index.php?option=com_djclassifieds&view=showitem&cid='.$i->cat_id.'&id='.$i->id.'&Itemid='.$itemid.'">'.$i->name.'</a>';

		echo '</td>';

		echo '<td class="description">'.$i->intro_desc.'</td>';

		echo '<td class="date_start_exp">'.$i->date_start;

		echo '<br />'.$i->date_exp.'</td>';

		echo '<td class="status">';

			$date_now =& JFactory::getDate();

			$date_exp = strtotime($i->date_exp);

			if($date_now->_date<$date_exp && $i->published ==1){

				echo JText::_('Active');

			}else{

				echo JText::_('Non-active');

			}

		echo '</td>';

		echo '<td class="user_edit">';

		echo '<a class="button2" href="index.php?option=com_djclassifieds&view=edititem&id='.$i->id.'&Itemid='.$itemid.'">>></a>';

		echo '</td>';

		echo '<td class="user_renew">';

		echo '<a class="button2" href="index.php?option=com_djclassifieds&view=renew&id='.$i->id.'&Itemid='.$itemid.'">>></a>';

		echo '</td>';

		echo '<td class="user_delete">';

		?>

		<form action="index.php?option=com_djclassifieds&view=useritems" method="post" name="djForm<?php echo $i->id;?>" id="djForm<?php echo $i->id;?>">

			<button class="button" type="button" id="submit_b" onclick="confirm_delete('<?php echo $i->name;?>','<?php echo $i->id;?>');"><?php echo JText::_('Delete'); ?></button>

			

			<input type="hidden" name="id" value="<?php echo $i->id;?>" />

			<input type="hidden" name="option" value="com_djclassifieds" />

  			<input type="hidden" name="view" value="deleteAd" />

			<input type="hidden" name="Itemid" value="<?php echo $itemid; ?>" />

		</form>

		<?php

		echo '</td>';					

		echo '</tr>';

	}





?>	

	<?php 

		$row = $r==TRUE ? '0' : '1';

		echo '<tr class="row'.$row.'"><td class="pag" colspan="8" >';	    

		echo $this->pagination->getPagesLinks(); 

		echo '</td></tr>';

	?>

</table>

</div>	

</div>

<script type="text/javascript">

	function confirm_delete(title,id){

		var answer = confirm ('<?php echo JText::_('DELETE_CONFIRM');?>'+' "'+title+'"');

		if (answer){

			document.getElementById("djForm"+id).submit();

		}

	}

</script>

