<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="edit">
    <h3 style="position:relative;left:-185px;"><?php echo 'MY DESIGNS'; ?></h3>
	<hr style="margin-left:-190px;">
	 <div style="font-family:candara;font-size:14px;"> <?php echo $text_page_content; ?> </div>
	 <div class="image">  <input type="hidden" value="" id="designs" /></div>
	 <div style="font-family:candara;font-size:14px;margin-bottom:30px;"> 
		<?php echo $text_page_content2; ?>
		<span style="margin-left:20px;position:relative; top:15px;"><a onclick="image_upload('designs', 'thumb');">  <img width="150px" height="50px;" src="catalog/view/theme/default/image/newimage/addnewdesigns.png" /></a> </span>
	</div>
<!--	
	<div>
		<div style="width:150px;float:left;"> 
			<div><img src="catalog/view/theme/default/image/newimage/mydesign1.png" /></div>
			<div> <span style="position:relative;left:36px;font-family:candara;"> id:113 </span> </div>
			<div> <span  style="position:relative;left:20px;font-family:candara;"> <a>Check Stats</a></span> </div>
			<div><img width="110px" height="45px" src="catalog/view/theme/default/image/newimage/replacecad.png" /></div>
		</div>
		<div style="width:150px;float:left;">
			<div><img src="catalog/view/theme/default/image/newimage/mydesign2.png" /></div>
			<div> <span style="position:relative;left:36px;font-family:candara;"> id:196 </span> </div>
			<div> <span  style="position:relative;left:20px;font-family:candara;"> <a>Check Stats</a></span> </div>
			<div><img width="110px" height="45px" src="catalog/view/theme/default/image/newimage/uploadcad.png" /></div>
		</div>
	</div> -->
	<div>
	

<?php 
$directoryPath = "/home3/silver/public_html/tresorjewellery/image/designers/".$this->designer->getId().'/designs';
		if(is_dir($directoryPath))
		{
 $dir = new DirectoryIterator("/home3/silver/public_html/tresorjewellery/image/designers/".$this->designer->getId().'/designs');
							
							foreach ($dir as $fileinfo) {
							if(strlen($fileinfo->getFilename()) > 4) {
							$image = 'designers/'.$this->designer->getId().'/designs/'.$fileinfo->getFilename();
							$imagequery = $this->db->query("select image from " . DB_PREFIX . "sketches_master where image = '" . $image . "'");
			if(! $imagequery->num_rows)
			{
			$this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "sketches_master SET designer_id = '" . (int)$this->designer->getId() . "', image = '" . $image . "'");
			}
							foreach ($designer_details as $designer_detail) { 
							
							if($designer_detail['image']== $image) { 
							if(substr($fileinfo->getFilename(), 0, 1) != '.')
							{ ?>
					<div style="width:150px;float:left;">
						
			<div><img style="width:110px;height:110px;" src="<?php echo '/image/designers/'.$this->designer->getId().'/designs/'.$fileinfo->getFilename();?>" /></div>
			<?php $_SESSION['views'] = 'designers/'.$this->designer->getId().'/designs/'.$fileinfo->getFilename();?>
			<?php 
		//	$image = 'designers/'.$this->designer->getId().'/designs/'.$fileinfo->getFilename();
		/*	$imagequery = $this->db->query("select image from " . DB_PREFIX . "sketches_master where image = '" . $image . "'");
			if(! $imagequery->num_rows)
			{
			$this->db->query("INSERT IGNORE INTO " . DB_PREFIX . "sketches_master SET designer_id = '" . (int)$this->designer->getId() . "', image = '" . $image . "'");
			} */
			?>
			<div> <span style="position:relative;left:36px;font-family:candara;"> id:<?php echo $designer_detail['sketch_id']; ?> </span> </div>
			<!--<div> <span style="position:relative;left:36px;font-family:candara;"> <?php echo $designerid; ?> </span> </div> --->
			
			<div> <span  style="position:relative;left:20px;font-family:candara;">
			<?php if($designer_detail['product_id']!=0) { ?>
			<a href="http://www.tresorjewellery.com.au/index.php?route=desaccount/coowned&sid=<?php echo $designer_detail['sketch_id']; ?>">Check Stats</a>
			<?php } else { ?>
			&nbsp;&nbsp;&nbsp;
			<?php } ?>
			
			</span> </div>
			
			<div><a href="mailto:support@gemtresor.com?subject=CAD file for Sketch Id# <?php echo $designer_detail['sketch_id']; ?> from <?php echo $this->designer->getFirstName(); ?> (Id# <?php echo $this->designer->getId(); ?>)"><img width="110px" height="45px" src="catalog/view/theme/default/image/newimage/uploadcad.png" /></a></div>
		
		<!--	<?php if($designer_detail['product_id']!=0) { ?>
			<?php echo $designer_detail['image']; ?>
			<?php } ?> -->
		
		</div>			
			<?php } ?>
			<?php  } ?>
			<?php  } ?>
			<?php } } } ?>
	
		
		</div>
  </form>
  <?php echo $content_bottom; ?></div>
<?php echo $footer; ?>

<script type="text/javascript"><!--
function image_upload(field, thumb) {
	$('#dialog').remove();
	$('.image').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="index.php?route=common/filemanager1&field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	var img ='no_image.jpg';
	//alert(img);
	$('#dialog').dialog({
		title: 'Your Designs',
		close: function (event, ui) {
		//	if ($('#' + field).attr('value')) {
		//	var imag = $('#' + field).attr('value');
		//	var imag1 =imag.substr(6);
				$.ajax({
					url: 'index.php?route=common/filemanager1/image&image=' + img,
					dataType: 'text',
					success: function(data) {
						location.reload();
						window.opener.location.reload();
						//$('#' + thumb).replaceWith('<img src="' + data + '" alt="" id="' + thumb + '" />');
					}
				});
			//}
		},	
		bgiframe: false,
		width: 800,
		height: 400,
		resizable: false,
		modal: false
	});
};
//--></script> 

