Jump to content

Help With Locating Error In Code


gaspower

Recommended Posts

Hello,

 

I would appreciate the help finding the issue with the below code. What this code does is upload to the database a string of coordinates with a model number to the database in this csv file format (210,427,261,423,279,576,198,575,N50555). The issue I am having is that if I upload a csv file with a low amount of rows, such as 20-30, it uploads fine. I just tried to upload a csv file with 250 rows, it uploaded, but for some reason, data was mis routed to database and coordinates where off. I split the file into quaters and all worked fine after upload. Not sure where the error lies?

 

Thanks JR

 

 

 

if (tep_not_null($action)) {
    switch ($action) {
      case 'bulk_insert':
                   $target = "temp/";
                   $target = $target . basename($_FILES['uploaded']['name']) ;
			   $file_name = basename($_FILES['uploaded']['name']);
                   $ok=1;
                   if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
                   {
				$messageStack->add("The file ".$file_name . " has been uploaded", 'error');
				$image_maps_id = $HTTP_GET_VARS['iID'];
				$handle = fopen($target,"r");
				$num =0;
				while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
/*
					$top_right_x = $data[0];
					if(!$top_right_x)
						break;
					$top_right_y = $data[1];
					$bottom_left_x = $data[2];
					$bottom_left_y = $data[3];
					$product_model = $data[4];
*/
// new upload should take it as follows
//                        $map_type = $data[0];
                        $coord1_x = $data[0];
                        $coord1_y = $data[1];
                        $coord2_x = $data[2];
                        $coord2_y = $data[3];
                        $coord3_x = $data[4];
                        $coord3_y = $data[5];
                        $coord4_x = $data[6];
                        $coord4_y = $data[7];
                        $coord5_x = $data[8];
                        $coord5_y = $data[9];
                        $coord6_x = $data[10];
                        $coord6_y = $data[11];
					$product_model = $data[12];
// check for rectangle will be the fifth point wil not be a number
// check for circle will be the fourth point will not be a number
// otherwise it will be a polygon .. check for 0,0 point.
					if(!is_numeric($data[3])) // circle
					{
					 $map_type = 3;
					 $product_model = $data[3];
					 $coord2_y = -999999;
					 $coord3_x = -999999;
					 $coord3_y = -999999;
					 $coord4_x = -999999;
					 $coord4_y = -999999;
					 $coord5_x = -999999;
					 $coord5_y = -999999;
					 $coord6_x = -999999;
					 $coord6_y = -999999;	
					 echo "<br> this is a circle";	 
					}	
					elseif(!is_numeric($data[4]))
					{
					 $map_type =1;
					 $product_model = $data[4];
					 $coord3_x = -999999;
					 $coord3_y = -999999;
					 $coord4_x = -999999;
					 $coord4_y = -999999;
					 $coord5_x = -999999;
					 $coord5_y = -999999;
					 $coord6_x = -999999;
					 $coord6_y = -999999;						 
					 echo "<br> this is a rectagle";
					}
					else // polygon
					{
					  $map_type =2;
					if(!is_numeric($data[6]))  // has 3 points
					 {
					 $product_model = $data[6];
					 $coord4_x = -999999;
					 $coord4_y = -999999;
					 $coord5_x = -999999;
					 $coord5_y = -999999;
					 $coord6_x = -999999;
					 $coord6_y = -999999;						 
					 }
					 if(!is_numeric($data[8])) // has 4 points
					 {
					  $product_model = $data[8];
					  $coord5_x = -999999;
					  $coord5_y = -999999;
					  $coord6_x = -999999;
					  $coord6_y = -999999;						   						 
					 }
					 elseif(!is_numeric($data[10])) // has 5 points
					 {
					  $product_model = $data[10];
					  $coord6_x = -999999;
					  $coord6_y = -999999;							 
					 }
					 elseif(!is_numeric($data[12])) // has 6 points
					 {
					  $product_model = $data[12];						 
					 }					
					 echo "<br> this is a polygon";
					}						                        					
				  /* find the products_id */
				 $products_id_q = tep_db_query("select products_id from ". TABLE_PRODUCTS . " where products_model = '". $product_model ."'");
				 //$products_id_arr_chk = tep_db_fetch_array($products_id_q);					 
				if(tep_db_num_rows($products_id_q) == 0)
				{
					$messageStack->add("Product with such a product model: ". $product_model . " does not exist. Please check !!", 'error');
				}
				else
				 while($products_id_arr = tep_db_fetch_array($products_id_q))
					{
					 $products_id = $products_id_arr['products_id'];
					 //check if the value exists
//						 $image_coord_exist = tep_db_query('select image_maps_id from '.TABLE_IMAGE_MAPS_TO_PRODUCTS . ' where image_maps_id = '. $image_maps_id .' and products_id = '. $products_id . ' and top_right_x = ' . $top_right_x . ' and top_right_y = ' . $top_right_y . ' and bottom_left_x = '. $bottom_left_x . ' and bottom_left_y = '. $bottom_left_y);
// modified code for the value existing check.. 
					 $image_coord_exist = tep_db_query('select image_maps_id from '.TABLE_IMAGE_MAPS_TO_PRODUCTS . ' where map_type = '. $map_type .' and coord1_x = '. $coord1_x . ' and coord1_y = ' . $coord1_y .' and coord2_x = '. $coord2_x . ' and coord2_y = ' . $coord2_y .' and coord3_x = '. $coord3_x . ' and coord3_y = ' . $coord3_y .' and coord4_x = '. $coord4_x . ' and coord4_y = ' . $coord4_y .' and coord5_x = '. $coord5_x . ' and coord5_y = ' . $coord5_y .' and coord6_x = '. $coord6_x . ' and coord6_y = ' . $coord6_y . ' and image_maps_id = '. $image_maps_id .' and products_id = '. $products_id);

					 $image_coord_exist_arr = tep_db_fetch_array($image_coord_exist);
					 if(!$image_coord_exist_arr) // insert if the coord doesnot exist
						{
						 // find the new coordinate id
						 $image_map_coord_id_count_q = tep_db_query("select count(image_map_coord_id) val from ". TABLE_IMAGE_MAPS_TO_PRODUCTS );
						 $image_map_coord_id_count_v = tep_db_fetch_array($image_map_coord_id_count_q);
						 if($image_map_coord_id_count_v['val'] == 0)
							{
						   $image_map_coord_id = 1;
							}
						 else
							{
						 $image_map_coord_id_q = tep_db_query("select max(image_map_coord_id) val from ". TABLE_IMAGE_MAPS_TO_PRODUCTS );
						 $image_map_coord_id_v = tep_db_fetch_array($image_map_coord_id_q);
						 $image_map_coord_id = (int)$image_map_coord_id_v['val'] + 1;
						}
						echo $map_type;
						 $sql_data_array = array('image_map_coord_id' => $image_map_coord_id,
												 'image_maps_id' =>$image_maps_id,
												 'products_id' => $products_id,
/*													 'top_right_x' =>  $top_right_x,
												 'top_right_y' =>  $top_right_y,
												 'bottom_left_x' =>  $bottom_left_x,
												 'bottom_left_y' =>  $bottom_left_y, */
												 'map_type' => $map_type,
												 'coord1_x' => $coord1_x,
												 'coord1_y' => $coord1_y,
												 'coord2_x' => $coord2_x,
												 'coord2_y' => $coord2_y,
												 'coord3_x' => $coord3_x,
												 'coord3_y' => $coord3_y,
												 'coord4_x' => $coord4_x,
												 'coord4_y' => $coord4_y,
												 'coord5_x' => $coord5_x,
												 'coord5_y' => $coord5_y,
												 'coord6_x' => $coord6_x,
												 'coord6_y' => $coord6_y,
												 'status' => 1,		 
												 'coord_date_added' => 'now()',
												 'coord_last_modified' => 'now()'
												  );
						  tep_db_perform(TABLE_IMAGE_MAPS_TO_PRODUCTS, $sql_data_array); 
						  $num ++;
						}
						else
						{
                              $messageStack->add("Product with such a product model: ". $product_model . " already exists. Please check !!", 'error');
						}
					}
				}
				fclose($handle);
								   }
                   else {
				$messageStack->add("Sorry, there was a problem uploading your file.", 'error');
                   }
			   break;
      case 'setflag':
        if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
          if (isset($HTTP_GET_VARS['pID'])) {
            tep_set_coord_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag'],$HTTP_GET_VARS['iID']);
          }
        }
        tep_redirect(tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $HTTP_GET_VARS['pID']. '&type=coord'));
        break;
      case 'insert_image_map':
      case 'update_image_map':
        if (isset($HTTP_POST_VARS['iID'])) 
	{
	   $image_maps_id = tep_db_prepare_input($HTTP_POST_VARS['iID']);	   
	   $image_maps_id = $HTTP_POST_VARS['iID'];
	}
	elseif(isset($HTTP_GET_VARS['iID']))
	{
	   $image_maps_id = tep_db_prepare_input($HTTP_GET_VARS['iID']);	   
	   $image_maps_id = $HTTP_GET_VARS['iID'];
	}

        if($action == 'insert_image_map')
	{
	  $image_map_q = tep_db_query("select max(image_maps_id) val from ". TABLE_IMAGE_MAPS );
	  $image_map_v = tep_db_fetch_array($image_map_q);
	  $image_maps_id = (int)$image_map_v['val'] + 1;
	}
        $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

        $sql_data_array = array('sort_order' => $sort_order);

        if ($action == 'insert_image_map') {
          $insert_sql_data = array('image_maps_id' => $image_maps_id,
		                       'parent_id' => '0',
                                   'date_added' => 'now()');

          $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

          tep_db_perform(TABLE_IMAGE_MAPS, $sql_data_array);
        } elseif ($action == 'update_image_map') {
          $update_sql_data = array('last_modified' => 'now()');

          $sql_data_array = array_merge($sql_data_array, $update_sql_data);

          tep_db_perform(TABLE_IMAGE_MAPS, $sql_data_array, 'update', "image_maps_id = '" . (int)$image_maps_id . "'");
        }

        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
	  $sql_data_array =array();
	  $insert_sql_data = array();
          $image_maps_title_array = $HTTP_POST_VARS['image_maps_title'];

          $language_id = $languages[$i]['id'];

          $sql_data_array = array('image_maps_title' => tep_db_prepare_input($image_maps_title_array[$language_id]));
//tep_db_query("the new value is ".tep_db_prepare_input($image_maps_title_array[$language_id]));
          if ($action == 'insert_image_map') {
            $insert_sql_data = array('image_maps_id' => $image_maps_id,
                                     'language_id' => $languages[$i]['id']);

            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

            tep_db_perform(TABLE_IMAGE_MAPS_DESCRIPTION, $sql_data_array);
          } elseif ($action == 'update_image_map') {
            tep_db_perform(TABLE_IMAGE_MAPS_DESCRIPTION, $sql_data_array, 'update', "image_maps_id = '" . (int)$image_maps_id . "' and language_id = '" . (int)$language_id . "'");
          }
        }

        $maps_main_image = new upload('maps_main_image');
        $maps_main_image->set_destination(DIR_FS_CATALOG_IMAGES);

        if ($maps_main_image->parse() && $maps_main_image->save()) {
          tep_db_query("update " . TABLE_IMAGE_MAPS . " set maps_main_image = '" . tep_db_input($maps_main_image->filename) . "' where image_maps_id = '" . (int)$image_maps_id . "'");
        }
        tep_redirect(tep_href_link(FILENAME_IMAGE_MAPS),'type=IM');
        break;
      case 'delete_image_map_confirm':
        if (isset($HTTP_POST_VARS['iID'])) $image_maps_id = tep_db_prepare_input($HTTP_POST_VARS['iID']);
        if (isset($HTTP_GET_VARS['iID'])) $image_maps_id = tep_db_prepare_input($HTTP_GET_VARS['iID']);
	if($image_maps_id)
	{
//			 tep_db_query("get something from somwhere ". $image_maps_id);
  	    tep_remove_image_map($image_maps_id);
	}
        tep_redirect(tep_href_link(FILENAME_IMAGE_MAPS),'type=IM');
        break;
      case 'delete_coord_confirm':
        if (isset($HTTP_GET_VARS['pID'])) {		   
  		   $coord_id =  tep_db_prepare_input($HTTP_GET_VARS['pID']);
           tep_db_query("delete from " . TABLE_IMAGE_MAPS_TO_PRODUCTS . " where image_map_coord_id = '" . (int)$coord_id . "'");
       }
           tep_redirect(tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID']. '&type=coord'));
        break;
      
      case 'insert_coord':
      case 'update_coord':
//        if (isset($HTTP_POST_VARS['right_top_x']) || isset($HTTP_POST_VARS['right_top_y']) || isset($HTTP_POST_VARS['left_bottom_x']) || isset($HTTP_POST_VARS['left_bottom_y'])) {
//          $action = 'new_coord';
  //      } else {
          if (isset($HTTP_GET_VARS['pID'])) $image_map_coord_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
	  if (isset($HTTP_GET_VARS['iID'])) $image_maps_id = tep_db_prepare_input($HTTP_GET_VARS['iID']);
//		  tep_db_query("select soemthign from somewhere ".$image_maps_id);
          $sql_data_array = array('image_maps_id' =>$image_maps_id,
			                      'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']),
/*			                      'top_right_x' =>  tep_db_prepare_input($HTTP_POST_VARS['top_right_x']),
		                      'top_right_y' =>  tep_db_prepare_input($HTTP_POST_VARS['top_right_y']),
		                      'bottom_left_x' =>  tep_db_prepare_input($HTTP_POST_VARS['bottom_left_x']),
		                      'bottom_left_y' =>  tep_db_prepare_input($HTTP_POST_VARS['bottom_left_y']),*/
							  'map_type' => tep_db_prepare_input($HTTP_POST_VARS['map_type']),
							  'coord1_x' => tep_db_prepare_input($HTTP_POST_VARS['coord1_x']),
							  'coord1_y' => tep_db_prepare_input($HTTP_POST_VARS['coord1_y']),
							  'coord2_x' => tep_db_prepare_input($HTTP_POST_VARS['coord2_x']),
							  'coord2_y' => tep_db_prepare_input($HTTP_POST_VARS['coord2_y']),
							  'coord3_x' => tep_db_prepare_input($HTTP_POST_VARS['coord3_x']),
							  'coord3_y' => tep_db_prepare_input($HTTP_POST_VARS['coord3_y']),
							  'coord4_x' => tep_db_prepare_input($HTTP_POST_VARS['coord4_x']),
							  'coord4_y' => tep_db_prepare_input($HTTP_POST_VARS['coord4_y']),
							  'coord5_x' => tep_db_prepare_input($HTTP_POST_VARS['coord5_x']),
							  'coord5_y' => tep_db_prepare_input($HTTP_POST_VARS['coord5_y']),
							  'coord6_x' => tep_db_prepare_input($HTTP_POST_VARS['coord6_x']),
							  'coord6_y' => tep_db_prepare_input($HTTP_POST_VARS['coord6_y']),
		                      'status' => tep_db_prepare_input($HTTP_POST_VARS['products_status'])
		                      );
          if($action == 'insert_coord')
	  {
	   $image_map_coord_id_q = tep_db_query("select max(image_map_coord_id) val from ". TABLE_IMAGE_MAPS_TO_PRODUCTS );
	   $image_map_coord_id_v = tep_db_fetch_array($image_map_coord_id_q);
	   $image_map_coord_id = (int)$image_map_coord_id_v['val'] + 1;
	  }
          if ($action == 'insert_coord') {
            $insert_sql_data = array( 'image_map_coord_id' => $image_map_coord_id,
			                      'coord_date_added' => 'now()');
            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
            tep_db_perform(TABLE_IMAGE_MAPS_TO_PRODUCTS, $sql_data_array);
          } elseif ($action == 'update_coord') {
            $update_sql_data = array('coord_last_modified' => 'now()');
            $sql_data_array = array_merge($sql_data_array, $update_sql_data);
            tep_db_perform(TABLE_IMAGE_MAPS_TO_PRODUCTS, $sql_data_array, 'update', "image_map_coord_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and image_maps_id = '" . (int)$HTTP_GET_VARS['iID'] . "'");
          }         
          tep_redirect(tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $image_maps_id . '&pID=' . $image_map_coord_id.'&type=coord'));
//        }
        break;     
    }
  }

// check if the catalog image directory exists
  if (is_dir(DIR_FS_CATALOG_IMAGES)) {
    if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
  } else {
    $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top">
<?php
  if ($action == 'new_coord') {/*
	'image_maps_id' => tep_db_prepare_input($HTTP_POST_VARS['iID']),
			                      'products_id' => tep_db_prepare_input($HTTP_POST_VARS['products_id']),
		                      'right_top_x' =>  tep_db_prepare_input($HTTP_POST_VARS['right_top_x']),
		                      'right_top_y' =>  tep_db_prepare_input($HTTP_POST_VARS['right_top_y']),
		                      'left_bottom_x' =>  tep_db_prepare_input($HTTP_POST_VARS['left_bottom_x']),
		                      'left_bottom_y' =>  tep_db_prepare_input($HTTP_POST_VARS['left_bottom_y']),
		                      'status' =>  '1'*/
    $parameters = array(
	               'products_id' => '',
/*                       'top_right_x' => '',
                       'top_right_y' => '',
                       'bottom_left_x' => '',
                       'bottom_left_y' => '',*/
				   'map_type' =>'',
				   'coord1_x' =>'',
				   'coord1_y' =>'',
				   'coord2_x' =>'',
				   'coord2_y' =>'',
				   'coord3_x' =>'',
				   'coord3_y' =>'',
				   'coord4_x' =>'',
				   'coord4_y' =>'',
				   'coord5_x' =>'',
				   'coord5_y' =>'',
				   'coord6_x' =>'',
				   'coord6_y' =>'',
                       'status' => '',
                       'coord_date_added' => '',
                       'coord_last_modified' => '',
                       'image_maps_id' => '');

    $pInfo = new objectInfo($parameters);

    if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
	$coords_query = tep_db_query( "select im2p.image_map_coord_id, im2p.image_maps_id, im2p.products_id, im2p.map_type, im2p.coord1_x,im2p.coord1_y, im2p.coord2_x,im2p.coord2_y, im2p.coord3_x,im2p.coord3_y, im2p.coord4_x,im2p.coord4_y, im2p.coord5_x,im2p.coord5_y, im2p.coord6_x,im2p.coord6_y, im2p.status,im2p.coord_date_added, im2p.coord_last_modified, imd.image_maps_title,p.products_model from ". TABLE_IMAGE_MAPS_TO_PRODUCTS ." im2p, " . TABLE_IMAGE_MAPS_DESCRIPTION . " imd, ". TABLE_PRODUCTS . " p where p.products_id = im2p.products_id and imd.image_maps_id = im2p.image_maps_id and language_id = '". (int)$languages_id . "' and im2p.image_map_coord_id = " . (int)$HTTP_GET_VARS['pID']);
        $coord = tep_db_fetch_array($coords_query);

        $pInfo->objectInfo($coord);
    } elseif (tep_not_null($HTTP_POST_VARS)) {
      $pInfo->objectInfo($HTTP_POST_VARS);
    }

    $languages = tep_get_languages();

    if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
    switch ($pInfo->products_status) {
      case '0': $in_status = false; $out_status = true; break;
      case '1':
      default: $in_status = true; $out_status = false;
    }
?>

  <?php echo tep_draw_form('new_coord', FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_coord_preview', 'post', 'enctype="multipart/form-data"'); ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT_COORD, "in ".$pInfo->image_maps_title); ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_STATUS; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_COORD_AVAILABLE . ' ' . tep_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_COORD_NOT_AVAILABLE; ?></td>
          </tr>			
          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_PRODUCT_SELECT; ?> </td>
		<?php
          $products_array = array();
              $products_query = tep_db_query("select products_id, products_model from " . TABLE_PRODUCTS . " order by products_model");
              while ($products = tep_db_fetch_array($products_query)) {
                   $products_array[] = array('id' => $products['products_id'],
                                             'text' => $products['products_model']);
                 }    
        ?>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '  ' . tep_draw_pull_down_menu('products_id', $products_array, $pInfo->products_id); ?></td>
          </tr>
          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
<!--
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_TOP_CORNER_TEXT; ?> </td>
		<td class="main"><?php
	      //                     echo '   x:  ' . tep_draw_input_field('top_right_x', $pInfo->top_right_x);
	        //                   echo '   y:  ' . tep_draw_input_field('top_right_y', $pInfo->top_right_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>

          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_BOTTOM_CORNER_TEXT; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('bottom_left_x', $pInfo->bottom_left_x);
	                           echo '   y:  ' . tep_draw_input_field('bottom_left_y', $pInfo->bottom_left_y);
	                      ?></td>
          </tr>
          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>       
	  -->
<!-- enter the 6 coordinates -->
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_CHOOSE_COORD_TYPE; ?> </td>
		<td class="main">
						<?php
//			                $map_type_array[] = array(('id' => '1' , 'text'=> 'Rectangle'),('id'=> '2' , 'text'=>'Polygon'),( 'id' => '3' , 'text' => 'Circle'));       
	                    $map_type_array = array();
                            $map_type_array[] = array('id'=>'1','text'=>'Rectangle');
                            $map_type_array[] = array('id'=>'2','text'=>'Polygon');
                            $map_type_array[] = array('id'=>'3','text'=>'Circle');
						echo tep_draw_pull_down_menu('map_type', $map_type_array,$pInfo->map_type);
	  ?>
		</td>

	  </tr>
          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr> 
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_1; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord1_x', $pInfo->coord1_x);
	                           echo '   y:  ' . tep_draw_input_field('coord1_y', $pInfo->coord1_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_2; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord2_x', $pInfo->coord2_x);
	                           echo '   y:  ' . tep_draw_input_field('coord2_y', $pInfo->coord2_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_3; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord3_x', $pInfo->coord3_x);
	                           echo '   y:  ' . tep_draw_input_field('coord3_y', $pInfo->coord3_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_4; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord4_x', $pInfo->coord4_x);
	                           echo '   y:  ' . tep_draw_input_field('coord4_y', $pInfo->coord4_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_5; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord5_x', $pInfo->coord5_x);
	                           echo '   y:  ' . tep_draw_input_field('coord5_y', $pInfo->coord5_y);
	                      ?></td>
          </tr>

          <tr>
            <td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
          <tr>
            <td class="main" align="right"><?php echo TEXT_COORD_6; ?> </td>
		<td class="main"><?php
	                           echo '   x:  ' . tep_draw_input_field('coord6_x', $pInfo->coord6_x);
	                           echo '   y:  ' . tep_draw_input_field('coord6_y', $pInfo->coord6_y);
	                      ?></td>
          </tr>

          <tr>
            

Link to comment
Share on other sites

Hello,

 

Sorry, I had to break up the post, code was too long. Here is the second half,

 

Thanks JR

 

<td colspan="1"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '  <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'].'&type=coord' : '&type=coord')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
      </tr>
    </table></form>
<?php
  } elseif ($action == 'new_coord_preview') {
    if (tep_not_null($HTTP_POST_VARS)) {
      $pInfo = new objectInfo($HTTP_POST_VARS);
  $products_id = $HTTP_POST_VARS['products_id'];
//      $bottom_left_x = $HTTP_POST_VARS['bottom_left_x'];
//      $bottom_left_y = $HTTP_POST_VARS['bottom_left_y'];
//      $top_right_x = $HTTP_POST_VARS['top_right_x'];
//      $top_right_y = $HTTP_POST_VARS['top_right_y'];
$map_type= $HTTP_POST_VARS['map_type'];
$coord1_x = $HTTP_POST_VARS['coord1_x'];
$coord1_y = $HTTP_POST_VARS['coord1_y'];
$coord2_x = $HTTP_POST_VARS['coord2_x'];
$coord2_y = $HTTP_POST_VARS['coord2_y'];
$coord3_x = $HTTP_POST_VARS['coord3_x'];
$coord3_y = $HTTP_POST_VARS['coord3_y'];
$coord4_x = $HTTP_POST_VARS['coord4_x'];
$coord4_y = $HTTP_POST_VARS['coord4_y'];
$coord5_x = $HTTP_POST_VARS['coord5_x'];
$coord5_y = $HTTP_POST_VARS['coord5_y'];
$coord6_x = $HTTP_POST_VARS['coord6_x'];
$coord6_y = $HTTP_POST_VARS['coord6_y'];
      $status = $HTTP_POST_VARS['products_status'];
    } else {
  $coord_query = tep_db_query ("select image_map_coord_id, image_maps_id, products_id,map_type, coord1_x, coord1_y, coord2_x, coord2_y, coord3_x, coord3_y, coord4_x, coord4_y, coord5_x, coord5_y, coord6_x, coord6_y, status, coord_date_added, coord_last_modified from ". TABLE_IMAGE_MAPS_TO_PRODUCTS . " where image_map_coord_id = '" . (int)$HTTP_GET_VARS['pID'] . "'" );
  $coord =  tep_db_fetch_array($coord_query);
      $pInfo = new objectInfo($coord);
    }
    $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_coord' : 'insert_coord';

    echo tep_draw_form($form_action, FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_id; ?></td>
            <td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr> 	    
    <td> New coordinate for <?php echo $pInfo->products_id; ?> </td>
  </tr>
<!--	  <tr> 	    
    <td>Right top corordinate <?php echo 'x: '. $pInfo->top_right_x . '    y :' . $pInfo->top_right_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Left Bottom Cordinate <?php echo 'x: '.$pInfo->bottom_left_x .'    y :'.$pInfo->bottom_left_y;?> </td>
  </tr>
  -->
<!-- the new 6 coordinates --> 
      <tr> 
    <td> Map Type <?php echo $map_type;?><?php if($map_type == 1) echo 'Rectangle'; elseif($map_type == 2) echo 'Polygon'; elseif($map_type == 3) echo 'Circle';?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 1 <?php echo 'x: '. $pInfo->coord1_x . '    y :' . $pInfo->coord1_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 2 <?php echo 'x: '. $pInfo->coord2_x . '    y :' . $pInfo->coord2_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 3 <?php echo 'x: '. $pInfo->coord3_x . '    y :' . $pInfo->coord3_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 4 <?php echo 'x: '. $pInfo->coord4_x . '    y :' . $pInfo->coord4_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 5 <?php echo 'x: '. $pInfo->coord5_x . '    y :' . $pInfo->coord5_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Coordinate 6 <?php echo 'x: '. $pInfo->coord6_x . '    y :' . $pInfo->coord6_y; ?> </td>
  </tr>
  <tr> 	    
    <td>Status <?php echo $pInfo->products_status; ?> </td>
  </tr>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td>
      </tr>

      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
//   }
    if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
        $back_url = FILENAME_IMAGE_MAPS;
        $back_url_params = 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $pInfo->image_map_coord_id . '&type=coord';
?>
      <tr>
        <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
      </tr>
<?php
    } else {
?>
      <tr>
        <td align="right" class="smallText">
<?php
/* Re-Post all POST'ed variables */
      reset($HTTP_POST_VARS);
      while (list($key, $value) = each($HTTP_POST_VARS)) {
        if (!is_array($HTTP_POST_VARS[$key])) {
          echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
        }
      }
      if (isset($HTTP_GET_VARS['pID'])) {
        echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
      } else {
        echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
      }
      echo '  <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'].'&type=coord' : '&type=coord')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?></td>
      </tr>
    </table></form>
<?php
    }
  } else {
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_IMAGE_MAPS_PRODUCTS; ?></td>
                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
              </tr>
<?php
 $show_type = $HTTP_GET_VARS['type'];
//tep_db_query("select seomthing from somewhere " . $show_type);
 if($show_type != 'coord')
  {
        $image_maps_count = 0;
        $rows = 0;

        if (isset($HTTP_GET_VARS['search'])) {
          $search = tep_db_prepare_input($HTTP_GET_VARS['search']);
          /*
          $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . tep_db_input($search) . "%' order by c.sort_order, cd.categories_name");
    	  */
        } else {
    	$image_maps_query = tep_db_query ("select im.image_maps_id, im.maps_main_image, im.parent_id, im.sort_order, im.date_added, im.last_modified, imd.image_maps_title from ". TABLE_IMAGE_MAPS . " im, " . TABLE_IMAGE_MAPS_DESCRIPTION . " imd where im.image_maps_id = imd.image_maps_id and imd.language_id = ". (int)$languages_id ." order by im.sort_order, imd.image_maps_title " );
        }
        while ($image_maps = tep_db_fetch_array($image_maps_query)) 
	{
          $image_maps_count++;
          $rows++;

            if ((!isset($HTTP_GET_VARS['iID']) && !isset($HTTP_GET_VARS['pID']) || (isset($HTTP_GET_VARS['iID']) && ($HTTP_GET_VARS['iID'] == $image_maps['image_maps_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
            $image_map_coords = array('coords_count' => tep_coords_in_image_map_count($image_maps['image_maps_id']));

            $cInfo_array = array_merge($image_maps, $image_map_coords);
            $cInfo = new objectInfo($cInfo_array);
          }

          if ( isset($cInfo) && is_object($cInfo) && ($image_maps['image_maps_id'] == $cInfo->image_maps_id) ) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $image_maps['image_maps_id'].'&type=IM') . '\'">' . "\n";
          } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $image_maps['image_maps_id'].'&type=IM') . '\'">' . "\n";
          }
?>
         <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS,'iID=' . $image_maps['image_maps_id'].'&type=coord') . '">' . tep_image(DIR_WS_ICONS . 'file_download.gif', ICON_FOLDER) . '</a> <b>' . $image_maps['image_maps_title'] . '</b>'; ?></td>
         <td class="dataTableContent" align="center"> </td>
         <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($image_maps['image_maps_id'] == $cInfo->image_maps_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $image_maps['image_maps_id']) .'&type=IM">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
         </tr>
<?php
	} // end of while
    } // end of if
    else
  {
        $coords_count = 0;
        $image_maps_id = (int)$HTTP_GET_VARS['iID'];
        if (isset($HTTP_GET_VARS['search'])) {
    	  $coords_query = tep_db_query( "select im2p.image_map_coord_id, im2p.image_maps_id, im2p.products_id,im2p.map_type, im2p.coord1_x,im2p.coord1_y,im2p.coord2_x,im2p.coord2_y,im2p.coord3_x,im2p.coord3_y,im2p.coord4_x,im2p.coord4_y,im2p.coord5_x,im2p.coord5_y,im2p.coord6_x,im2p.coord6_y, im2p.status,im2p.coord_date_added, im2p.coord_last_modified, imd.image_maps_title,p.products_model from ". TABLE_IMAGE_MAPS_TO_PRODUCTS ." im2p, " . TABLE_IMAGE_MAPS_DESCRIPTION . " imd, ". TABLE_PRODUCTS . " p where p.products_id = im2p.products_id and imd.image_maps_id = im2p.image_maps_id and language_id = '". (int)$languages_id . "' and im2p.image_maps_id = " . (int)$HTTP_GET_VARS['iID']);
        } else {
      	  $image_maps_id = $HTTP_GET_VARS['iID'];
    	  $coords_query = tep_db_query( "select im2p.image_map_coord_id, im2p.image_maps_id, im2p.products_id,im2p.map_type, im2p.coord1_x,im2p.coord1_y,im2p.coord2_x,im2p.coord2_y,im2p.coord3_x,im2p.coord3_y,im2p.coord4_x,im2p.coord4_y,im2p.coord5_x,im2p.coord5_y,im2p.coord6_x,im2p.coord6_y, im2p.status,im2p.coord_date_added, im2p.coord_last_modified, imd.image_maps_title,p.products_model from ". TABLE_IMAGE_MAPS_TO_PRODUCTS ." im2p, " . TABLE_IMAGE_MAPS_DESCRIPTION . " imd , ". TABLE_PRODUCTS . " p where p.products_id = im2p.products_id and imd.image_maps_id = im2p.image_maps_id and language_id = '". (int)$languages_id . "' and im2p.image_maps_id = " . (int)$HTTP_GET_VARS['iID']);
        }

        while ($coords = tep_db_fetch_array($coords_query)) {
          $coords_count++;
          $rows++;

    // Get categories_id for product if search
    //      if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id'];

          if ( (!isset($HTTP_GET_VARS['pID']) && !isset($HTTP_GET_VARS['iID']) || (isset($HTTP_GET_VARS['pID']) && ($HTTP_GET_VARS['pID'] == $coords['image_map_coord_id']))) && !isset($pInfo) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
    // find out the rating average from customer reviews
    //        $reviews_query = tep_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . (int)$products['products_id'] . "'");
     //      $reviews = tep_db_fetch_array($reviews_query);
            $pInfo_array = $coords;
            $pInfo = new objectInfo($pInfo_array);
          }

          if (isset($pInfo) && is_object($pInfo) && ($coords['image_map_coord_id'] == $pInfo->image_map_coord_id) ) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $coords['image_map_coord_id'] .'&type=coord') . '\'">' . "\n";
          } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $coords['image_map_coord_id'].'&type=coord') . '\'">' . "\n";
          }
?>
           <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $coords['image_map_coord_id'] . '&type=coord'.'&action=new_coord_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $coords['products_model']; ?></td>
           <td class="dataTableContent" align="center">
<?php
          if ($coords['status'] == '1') {
            echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'action=setflag&flag=0&pID=' . $coords['image_map_coord_id'] . '&iID=' . $HTTP_GET_VARS['iID'] . '&type=coord">') . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
          } else {
            echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'action=setflag&flag=1&pID=' . $coords['image_map_coord_id'] . '&iID=' . $HTTP_GET_VARS['iID']) . '&type=coord">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
          }
?>
            </td>
            <td class="dataTableContent" align="right"><?php if (isset($pInfo) && is_object($pInfo) && ($coords['image_map_coord_id'] == $pInfo->image_map_coord_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $coords['image_map_coord_id']) . '&type=coord">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
          </tr>
<?php
	}//end of while
  } // wnd of else
/*
    $cPath_back = '';
    if (sizeof($cPath_array) > 0) {
      for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) {
        if (empty($cPath_back)) {
          $cPath_back .= $cPath_array[$i];
        } else {
          $cPath_back .= '_' . $cPath_array[$i];
        }
      }
    }

    $cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
*/
?>
              <tr>
                <td colspan="3">
			 <table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText"><?php echo TEXT_COORDS . ' ' . (int)tep_coords_in_image_map_count($HTTP_GET_VARS['iID']); ?></td>
                    <td align="right" class="smallText">
				<?php 
                      if($HTTP_GET_VARS['type'] != 'coord')
				  	  echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'action=new_image_map') . '">' . tep_image_button('button_new_category.gif', IMAGE_NEW_CATEGORY) . '</a>'; 
                      if($HTTP_GET_VARS['type']=='coord')
                     {
                      echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS,'iID=' . $HTTP_GET_VARS['iID'] .'&type=IM') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> '; 
				  	  echo '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&action=new_coord&type=coord') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; 
                     } 
				?> </td>

                  </tr>
                </table></td>
              </tr>
		   <tr>
		     <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
	      <tr>
       	        <?php echo tep_draw_form('csv_upload_input', 'image_map_setup2.php?iID=' . $HTTP_GET_VARS['iID'] . '&type=IM&action=bulk_insert','', 'post', 'enctype="multipart/form-data"'); ?> <!--
                <td class="main"><?php echo "Please choose the image map for which you want to upload the coordinates: "; ?></td>
                <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('image_maps_id', $image_maps_array); ?></td> -->
		    <td class="main" valign="center"><?php echo 'Please choose a file for bulk upload: <input name="uploaded" type="file" />' .'    '. tep_image_submit('button_insert.gif', IMAGE_INSERT); ?></td></form>
		 </tr> 
            </table></td>
<?php
    $heading = array();
    $contents = array();
    switch ($action) {
      case 'new_image_map':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_IMAGE_MAP . '</b>');
        $image_map_q = tep_db_query("select max(image_maps_id) val from ". TABLE_IMAGE_MAPS );
	$image_map_v = tep_db_fetch_array($image_map_q);
	$image_maps_id = (int)$image_map_v['val'] + 1;
        $contents = array('form' => tep_draw_form('newimagemap', FILENAME_IMAGE_MAPS, 'action=insert_image_map&iID=' . $image_maps_id, 'post', 'enctype="multipart/form-data"'));
        $contents[] = array('text' => TEXT_NEW_IMAGE_MAP_INTRO);

        $image_map_inputs_string = '';
        $languages = tep_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
          $image_map_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('image_maps_title[' . $languages[$i]['id'] . ']');
        }

        $contents[] = array('text' => '<br>' . TEXT_IMAGE_MAPS_TITLE . $image_map_inputs_string);
        $contents[] = array('text' => '<br>' . TEXT_IMAGE_MAPS_IMAGE . '<br>' . tep_draw_file_field('maps_main_image'));
        $contents[] = array('text' => '<br>' . TEXT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', '', 'size="2"'));
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_IMAGE_MAPS,'iID='.$HTTP_GET_VARS['iID'].'&type=IM') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
      case 'edit_image_map':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_IMAGE_MAP . '</b>');

        $contents = array('form' => tep_draw_form('imagemaps', FILENAME_IMAGE_MAPS, 'action=update_image_map&iID=' . $cInfo->image_maps_id, 'post', 'enctype="multipart/form-data"') . tep_draw_hidden_field('image_maps_id', $cInfo->image_maps_id));
        $contents[] = array('text' => TEXT_EDIT_INTRO);

        $image_map_inputs_string = '';
        $languages = tep_get_languages();
        for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
          $image_map_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('image_maps_title[' . $languages[$i]['id'] . ']', tep_get_image_map_title($cInfo->image_maps_id, $languages[$i]['id']));
        }

        $contents[] = array('text' => '<br>' . TEXT_EDIT_IMAGE_MAPS_TITLE . $image_map_inputs_string);
        $contents[] = array('text' => '<br>' . tep_image(DIR_WS_CATALOG_IMAGES . $cInfo->maps_main_image, $cInfo->image_maps_title) . '<br>' . DIR_WS_CATALOG_IMAGES . '<br><b>' . $cInfo->maps_main_image . '</b>');
        $contents[] = array('text' => '<br>' . TEXT_EDIT_IMAGE_MAPS_IMAGE . '<br>' . tep_draw_file_field('maps_main_image'));
        $contents[] = array('text' => '<br>' . TEXT_EDIT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"'));
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'].'&type=IM') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
      case 'delete_image_map':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_IMAGE_MAP . '</b>');

        $contents = array('form' => tep_draw_form('imagemaps', FILENAME_IMAGE_MAPS, 'action=delete_image_map_confirm&iID=' .$cInfo->image_maps_id) . tep_draw_hidden_field('image_maps_id', $cInfo->image_maps_id));
        $contents[] = array('text' => TEXT_DELETE_IMAGE_MAP_INTRO);
        $contents[] = array('text' => '<br><b>' . $cInfo->image_maps_title . '</b>');
         // if ($cInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count));
        if ($cInfo->coords_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_COORDS, $cInfo->coords_count));
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'].'&type=IM') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
      case 'delete_coord':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_COORD . '</b>');

        $contents = array('form' => tep_draw_form('products', FILENAME_IMAGE_MAPS, 'action=delete_coord_confirm&pID=' . $pInfo->image_map_coord_id . '&iID='.$HTTP_GET_VARS['iID'].'&type=coord') . tep_draw_hidden_field('products_id', $pInfo->image_map_coord_id));
        $contents[] = array('text' => TEXT_DELETE_COORD_INTRO);
        $contents[] = array('text' => '<br><b>' . $pInfo->products_model . '</b>');

        //$product_categories_string = '';
//	$coord_image_maps_string= '';
        //$product_categories = tep_generate_category_path($pInfo->products_id, 'product');
//	tep_db_query();
        $coord_image_maps = //  tep_generate_image_map_path($pInfo->products_id);
		/*
        for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) {
          $category_path = '';
          for ($j = 0, $k = sizeof($product_categories[$i]); $j < $k; $j++) {
            $category_path .= $product_categories[$i][$j]['text'] . ' > ';
          }
          $category_path = substr($category_path, 0, -16);
          $product_categories_string .= tep_draw_checkbox_field('product_categories[]', $product_categories[$i][sizeof($product_categories[$i])-1]['id'], true) . ' ' . $category_path . '<br>';
        }
*/
//        $product_categories_string = substr($product_categories_string, 0, -4);

//        $contents[] = array('text' => '<br>' . $product_categories_string);
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] . '&pID=' . $pInfo->image_map_coord_id . '&type=coord') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
     	/*
      case 'copy_to':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TO . '</b>');

        $contents = array('form' => tep_draw_form('copy_to', FILENAME_CATEGORIES, 'action=copy_to_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id));
        $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO);
        $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_CATEGORIES . '<br><b>' . tep_output_generated_category_path($pInfo->products_id, 'product') . '</b>');
        $contents[] = array('text' => '<br>' . TEXT_CATEGORIES . '<br>' . tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $current_category_id));
        $contents[] = array('text' => '<br>' . TEXT_HOW_TO_COPY . '<br>' . tep_draw_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '<br>' . tep_draw_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE);
        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_copy.gif', IMAGE_COPY) . ' <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $pInfo->products_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
	*/
      default:
        if ($rows > 0) {
          if (isset($cInfo) && is_object($cInfo)) { // category info box contents
            $heading[] = array('text' => '<b>' . $cInfo->image_maps_title . '</b>');

            $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $HTTP_GET_VARS['iID'] .  '&action=edit_image_map&type=IM') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $cInfo->image_maps_id . '&action=delete_image_map&type=IM') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
            $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added));
            if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified));
            $contents[] = array('text' => '<br>' . tep_info_image($cInfo->maps_main_image, $cInfo->image_maps_title, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br>' . $cInfo->maps_main_image);
            $contents[] = array('text' => '<br>' . TEXT_COORDS . ' ' . $cInfo->coords_count);
          } 
	   else//if (isset($pInfo) && is_object($pInfo)) { // product info box contents
	  {
		if((isset($pInfo) && is_object($pInfo)))
            $heading[] = array('text' => 'Select operation on: <b>' . $pInfo->products_model . '</b>');
		else
            $heading[] = array('text' => '<b>' . TEXT_SELECT_COORDINATE_TO_CHANGE . '</b>');

            $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $pInfo->image_maps_id . '&pID=' . $pInfo->image_map_coord_id . '&action=new_coord') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_IMAGE_MAPS, 'iID=' . $pInfo->image_maps_id . '&pID=' . $pInfo->image_map_coord_id . '&action=delete_coord&type=coord') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> ');

            if((isset($pInfo) && is_object($pInfo)))
		  {
                $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($pInfo->coord_date_added));
                if (tep_not_null($pInfo->coord_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($pInfo->coord_last_modified));
		  }
		/*
            $contents[] = array('text' => '<br>' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br>' . $pInfo->products_image);

            $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '<br>' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity);
            $contents[] = array('text' => '<br>' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%');
		*/
          }
        } else { // create category/product info
          $heading[] = array('text' => '<b>' . EMPTY_IMAGE_MAP . '</b>');
          $contents[] = array('text' => TEXT_NO_COORDINATES);
        }
        break;
    }

    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
      echo '            <td width="25%" valign="top">' . "\n";

      $box = new box;
      echo $box->infoBox($heading, $contents);

      echo '            </td>' . "\n";
    }
?>
          </tr>
        </table></td>
      </tr>
    </table>
<?php
  }
?>
    </td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.