Index: /extensions/MyPiwiShop/admin/MyPiwiShopBatch.php
===================================================================
--- /extensions/MyPiwiShop/admin/MyPiwiShopBatch.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/MyPiwiShopBatch.php	(revision 27781)
@@ -4,21 +4,30 @@
 global $template;
 
-  $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
+//set batch manager 
+  $query='
+  SELECT `id`, `product`, `noteAdmin`, `price`
+  FROM '.MPS_PRODUCT_TABLE.' 
+  ORDER BY `order`
+  ;';
   $result = pwg_query($query);
-  $product = array();
   
-  while($row = pwg_db_fetch_assoc($result)){
-  $product[]= $row;
+  while($row = pwg_db_fetch_assoc($result)) {
+   $product[]= $row;
   }
   
-  $query='SELECT * FROM '.MPS_CONF_TABLE.';';
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.'
+  ;';
   $result 	= pwg_query($query);
-  while($row = pwg_db_fetch_assoc($result)){
+  
+  while($row = pwg_db_fetch_assoc($result)) {
    $config = $row ;
   }
 
- $template->assign(array(
-  'mps_product'	=> $product,
-  'mps_conf'	=> $config
+//tempate assign
+  $template->assign(array(
+   'mps_product' => $product,
+   'mps_conf'	 => $config
   ));  
 
Index: /extensions/MyPiwiShop/admin/MyPiwiShopBatchUnit.php
===================================================================
--- /extensions/MyPiwiShop/admin/MyPiwiShopBatchUnit.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/MyPiwiShopBatchUnit.php	(revision 27781)
@@ -1,40 +1,42 @@
 <?php
 defined('MPS_PATH') or die('Hacking attempt!');
-/*	*
-*** submit change
-**/	
+
+//change product check	
+  if(isset($_POST['imgid'])) {
+   $imgid = $_POST['imgid'];
+   $imgen = array($imgid);
+   
+	if (!isset($_POST['productcheck'])) {
+	 delet_Allproduct_Thisimage($imgid);
+	} else {
+	 $product_id = $_POST['productcheck'];
+	 add_product_Thisimage($product_id, $imgen);
+    }
+  }	
 	
-if(isset($_POST['imgid']))
-	{
-	$imgid = $_POST['imgid'];
-	$imgen = array($imgid);
-	if (!isset($_POST['productcheck'])) {
-		deletThis_image_Allproduct($imgid);
-	}
-	else{	
-
-	$product_id = $_POST['productcheck'];
-	add_product_Thisimage($product_id, $imgen);
-  }
-}	
-	
-
-global $template, $element_ids;
+//set batch manager unit
+  global $template, $element_ids;
  
- $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
+  $query='
+  SELECT `id`, `product`, `noteAdmin`, `price`
+  FROM '.MPS_PRODUCT_TABLE.'
+  ORDER BY `order`
+  ;';
   $result = pwg_query($query);
-  $products = array();
   
   while($row = pwg_db_fetch_assoc($result)){
-  $products[]= $row;
+   $products[]= $row;
   }
 
-  $query='SELECT * FROM '.MPS_CONF_TABLE.';';
-    $result 	= pwg_query($query);
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.';';
+  $result 	= pwg_query($query);
+  
   while($row = pwg_db_fetch_assoc($result)){
     $config = $row ;
   }
 
- $query='
+  $query='
   SELECT i.id, pi.image_id, pi.product_id
   FROM '.IMAGES_TABLE.' AS i
@@ -43,16 +45,15 @@
   ;';
   $result = pwg_query($query);
-  $productcheck = array();
   
   while($row = pwg_db_fetch_assoc($result)){
-	$productcheck[] = $row;
+   $productcheck[] = $row;
   }
 		
-  
-	$template->assign(array(
-	'mps_products'	   => $products,
-	'mps_conf'		   => $config,
-	'mps_productcheck' => $productcheck,
-	));
+//template assign 
+  $template->assign(array(
+   'mps_products'	  => $products,
+   'mps_conf'		  => $config,
+   'mps_productcheck' => $productcheck,
+));
 
 
Index: /extensions/MyPiwiShop/admin/config.php
===================================================================
--- /extensions/MyPiwiShop/admin/config.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/config.php	(revision 27781)
@@ -2,63 +2,65 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
+  $select_options_currency = array(
+   'AUD'=>'Australian Dollar(AUD)',
+   'BRL'=>'Brazilian Real(BRL)',
+   'CAD'=>'Canadian Dollar(CAD)',
+   'CZK'=>'Czech Koruna(CZK)',
+   'DKK'=>'Danish Krone(DKK)',
+   'EUR'=>'Euro(EUR)',
+   'HKD'=>'Hong Kong Dollar(HKD)',
+   'HUF'=>'Hungarian Forint(HUF)',
+   'ILS'=>'Israeli New Sheqel(ILS)',
+   'JPY'=>'Japanese Yen(JPY)',
+   'MYR'=>'Malaysian Ringgit(MYR)',
+   'MXN'=>'Mexican Peso(MXN)',
+   'NOK'=>'Norwegian Krone(NOK)',
+   'NZD'=>'New Zealand Dollar(NZD)',
+   'PHP'=>'Philippine Peso(PHP)',
+   'PLN'=>'Polish Zloty(PLN)',
+   'GBP'=>'Pound Sterling(GBP)',
+   'SGD'=>'Singapore Dollar(SGD)',
+   'SEK'=>'Swedish Krona(SEK)',
+   'CHF'=>'Swiss Franc(CHF)',
+   'TWD'=>'Taiwan New Dollar(TWD)',
+   'THB'=>'Thai Baht(THB)',
+   'USD'=>'U.S. Dollar(USD)'
+  );
 
-  $select_options_currency=array(
-  'AUD'=>'Australian Dollar(AUD)',
-  'BRL'=>'Brazilian Real(BRL)',
-  'CAD'=>'Canadian Dollar(CAD)',
-  'CZK'=>'Czech Koruna(CZK)',
-  'DKK'=>'Danish Krone(DKK)',
-  'EUR'=>'Euro(EUR)',
-  'HKD'=>'Hong Kong Dollar(HKD)',
-  'HUF'=>'Hungarian Forint(HUF)',
-  'ILS'=>'Israeli New Sheqel(ILS)',
-  'JPY'=>'Japanese Yen(JPY)',
-  'MYR'=>'Malaysian Ringgit(MYR)',
-  'MXN'=>'Mexican Peso(MXN)',
-  'NOK'=>'Norwegian Krone(NOK)',
-  'NZD'=>'New Zealand Dollar(NZD)',
-  'PHP'=>'Philippine Peso(PHP)',
-  'PLN'=>'Polish Zloty(PLN)',
-  'GBP'=>'Pound Sterling(GBP)',
-  'SGD'=>'Singapore Dollar(SGD)',
-  'SEK'=>'Swedish Krona(SEK)',
-  'CHF'=>'Swiss Franc(CHF)',
-  'TWD'=>'Taiwan New Dollar(TWD)',
-  'THB'=>'Thai Baht(THB)',
-  'USD'=>'U.S. Dollar(USD)'
-  );
- 
-if (isset($_POST['save_config']))
-{
-	$PPid		= $_POST['PPid'];
-    $currency	= $_POST['currency'];
-    $ship		= $_POST['ship'];
-	$comm		= $_POST['comm'];
-	$tprmulti 	= $_POST['tprmulti'];
-	$tpruniq 	= $_POST['tpruniq'];
+// update config  
+  if (isset($_POST['save_config'])) {
+  
+   $PPid		= $_POST['PPid'];
+   $currency	= $_POST['currency'];
+   $ship		= $_POST['ship'];
+   $comm		= $_POST['comm'];
+   $tprmulti 	= $_POST['tprmulti'];
+   $tpruniq 	= $_POST['tpruniq'];
 	
-	$query='UPDATE '.MPS_CONF_TABLE.' 
-	SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\'
-	WHERE id=1;';
-	$result=pwg_query($query);
-   if($result==1)
+   pwg_query('
+   UPDATE '.MPS_CONF_TABLE.' 
+   SET PPid = \''.$PPid.'\',currency = \''.$currency.'\',ship = \''.$ship.'\',comm = \''.$comm.'\' ,tprmulti = \''.$tprmulti.'\',tpruniq = \''.$tpruniq.'\'
+   WHERE id = 1
+   ;');
+	
     $page['infos']=l10n('Your configuration settings are saved');
-   else
-    $page['errors']=l10n('Error');
+  }
 
-}
+//set config
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.'
+  ;';
+  $result 	= pwg_query($query);
+  
+  while($row = pwg_db_fetch_assoc($result)) {
+   $config = $row ;
+  }
 
- $query='SELECT * FROM '.MPS_CONF_TABLE.';';
-    $result 	= pwg_query($query);
-     while($row = pwg_db_fetch_assoc($result)){
-    $config = $row ;
-   }
-
-
-
-$template->assign(array(
-  'mps_currency' 	=> $select_options_currency,
-  'mps_conf'		=> $config
+//template assign
+  $template->assign(array(
+   'mps_currency' 	=> $select_options_currency,
+   'mps_conf'		=> $config
   ));
 
-$template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl'));
+  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/config.tpl'));
Index: /extensions/MyPiwiShop/admin/home.php
===================================================================
--- /extensions/MyPiwiShop/admin/home.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/home.php	(revision 27781)
@@ -2,17 +2,20 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
+// set home
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.'
+  ;';
+  $result = pwg_query($query);
+  
+  while($row = pwg_db_fetch_assoc($result)) {
+   $config = $row ;
+  }
 
-
- $query='SELECT * FROM '.MPS_CONF_TABLE.';';
-    $result 	= pwg_query($query);
-     while($row = pwg_db_fetch_assoc($result)){
-    $config = $row ;
-   }
-
-
-$template->assign(array(
-  'mps_conf' 			=> $config,
-  'INTRO_CONTENT' 		=> load_language('intro.html', MPS_PATH, array('return'=>true)),
+//template assign
+  $template->assign(array(
+   'mps_conf' 	   => $config,
+   'INTRO_CONTENT' => load_language('intro.html', MPS_PATH, array('return'=>true)),
   ));
 
-$template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl'));
+  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/home.tpl'));
Index: /extensions/MyPiwiShop/admin/options.php
===================================================================
--- /extensions/MyPiwiShop/admin/options.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/options.php	(revision 27781)
@@ -2,5 +2,5 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
-
+// define type option
   $select_type_opt=array(
   'select'   =>'select',
@@ -10,166 +10,173 @@
   'checkbox' =>'checkbox',
   );
+ 
+// delete option
+  if(isset($_POST['check'])) {
   
-  if(isset($_POST['check'])){
    foreach($_POST['check'] AS $delete_id){
    
-   $query='DELETE FROM '.MPS_OPTION_TABLE.' 
-   WHERE id = '.$delete_id.';';
-   pwg_query($query);
+   pwg_query('
+   DELETE FROM '.MPS_OPTION_TABLE.' 
+   WHERE `id` = '.$delete_id.';
+   ');
    
-    $query='DELETE FROM '.MPS_PROD_OPT_TABLE.' 
-   WHERE opt_id = '.$delete_id.';';
-   pwg_query($query);
+   pwg_query('
+   DELETE FROM '.MPS_PROD_OPT_TABLE.' 
+   WHERE `opt_id` = '.$delete_id.';
+   ');
   
-   $query='DELETE FROM '.MPS_OPT_VAL_TABLE.' 
-   WHERE select_id = '.$delete_id.';';
-   pwg_query($query);
+   pwg_query('
+   DELETE FROM '.MPS_OPT_VAL_TABLE.' 
+   WHERE `select_id` = '.$delete_id.';
+   ');
+   
    $page['infos']=l10n('deleted');
    }
-   }   
+   
+  }   
 
-if (isset($_POST['option_add']))
-{
-if(empty($_POST['id']))
-	{
+// add/edit option
+  if (isset($_POST['option_add'])) {
+
+  //add option
+	if(empty($_POST['id'])) {
+	 $order = array();
+	 
+	 $query ='SELECT * 
+	 FROM '.MPS_OPTION_TABLE.';';
+	 $result = pwg_query($query);
+	 
+	 while($row = pwg_db_fetch_assoc($result)) {
+       $order[] = $row['order'];
+	 }
+	 
+	 if (count($order) == 0) {
+	  $order = 1;
+	 } else {
+	  $order = max($order)+1;
+	 }
 	
-	$order = array();
-	$query ='SELECT * FROM '.MPS_OPTION_TABLE.';';
-	$result = pwg_query($query);
-	while($row = pwg_db_fetch_assoc($result)){
-    	$order[] = $row['order'];
-	}
-	if (count($order) == 0) {
-	$order = 1;
-	}else{
-	$order = max($order)+1;
+	 $name		= $_POST['name'];
+     $type		= $_POST['type'];
+     $title		= $_POST['title'];
+	 
+	 if(isset($_POST['requi'])) {
+	  $requi = $_POST['requi'];
+	 } else {
+	  $requi = 0;
+	 }
+	
+	 pwg_query('
+	 INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 
+	 VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\')
+	 ;');
+   
+	 $select_id = pwg_db_insert_id();			
+			
+	 if(isset($_POST['val'])) {
+	 $val		= $_POST['val'];
+	 
+      foreach($val as $val_ele) {
+	   pwg_query('
+	   INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 
+	   VALUE (\''.$val_ele.'\',\''.$select_id.'\')
+	   ;');
+      }
+	  
+	 }
+	 $page['infos']=l10n('Option registered');
 	}
 	
-	$name		= $_POST['name'];
-    $type		= $_POST['type'];
-    $title		= $_POST['title'];
+  //edit option
+    if(!empty($_POST['id'])) {
+
+	 $name	= $_POST['name'];
+     $type	= $_POST['type'];
+     $title	= $_POST['title'];
+	 $id	= $_POST['id'];
 	
-	if(isset($_POST['requi'])){
-	 $requi = $_POST['requi'];
-	 }else{
-	 $requi = 0;
+	 if(isset($_POST['requi'])) {
+	   $requi = $_POST['requi'];
+	  } else {
+	   $requi = 0;
+	  }
+
+	 pwg_query('	
+	 UPDATE '.MPS_OPTION_TABLE.' 
+	 SET `name` = \''.$name.'\', `type` = \''.$type.'\', `titre` = \''.$title.'\', `requi` = \''.$requi.'\'
+	 WHERE `id` = '.$id.'
+	 ;');
+	
+	 pwg_query('
+	 DELETE FROM '.MPS_OPT_VAL_TABLE.' 
+	 WHERE `select_id` =  '.$id.'
+	 ;');
+   
+	 if(isset($_POST['val'])){
+	 $val		= $_POST['val'];
+	 
+      foreach($val as $val_ele)
+      {
+	   pwg_query('
+	   INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 
+	   VALUE (\''.$val_ele.'\',\''.$id.'\')
+	   ;');
+      }
+	  
 	 }
+	 
+    $page['infos']=l10n('Option registered');
+	}
+  }
+
+// change option order
+  if(isset($_POST['newOrder']))	{
+  
+   $newOrder = explode(",", $_POST['newOrder']);
+   $ex 	 	 = array_pop($newOrder);
+   
+	foreach( $newOrder as $order => $id ) {
 	
+	 $order = $order +1;
+     pwg_query('
+	 UPDATE '.MPS_OPTION_TABLE.' 
+	 SET `order` = \''.$order.'\' 
+	 WHERE `id` = '.$id.'
+	 ;');
+     }  
+	 
+	$page['infos']=l10n('the order is changed');
+  }
+
+// set option
+  $query='
+  SELECT o.id, o.titre, o.name, o.type, o.requi, o.order, ov.val
+  FROM '.MPS_OPTION_TABLE.' AS o
+  LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
+  ORDER BY o.order 
+  ;';
+  
+  $result = pwg_query($query);
+   while($row = pwg_db_fetch_assoc($result)) {
+   
+ 	if (!isset($option[ $row['id']])) {
+     $option[$row['id']] = array(
+	  'id'	  => $row['id'],
+	  'title' => $row['titre'],
+	  'name'  => $row['name'],
+	  'type'  => $row['type'],
+	  'requi' => $row['requi'],
+	 );
+	}
+	$option[$row['id']]['val'][]=$row['val'];
 	
-	$query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 
-			values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');';
-   
-	pwg_query($query);		
-	$select_id = pwg_db_insert_id();			
-			
-	if(isset($_POST['val'])){
-	$val		= $_POST['val'];
-
-
-    foreach($val as $val_ele)
-    {
-	 $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 
-			values (\''.$val_ele.'\',\''.$select_id.'\');';
-	 $result = pwg_query($query);
-    }
-	if($result==1)
-	$page['infos']=l10n('Option registered');
-	else
-	$page['errors']=l10n('Error');
-	}
-	}
-
-if(!empty($_POST['id']))
-	{
-
-	$name		= $_POST['name'];
-    $type		= $_POST['type'];
-    $title		= $_POST['title'];
-	$id			= $_POST['id'];
-	
-	if(isset($_POST['requi'])){
-	 $requi = $_POST['requi'];
-	 }else{
-	 $requi = 0;
-	 }
-
-	$query='UPDATE '.MPS_OPTION_TABLE.' 
-	SET name = \''.$name.'\', type = \''.$type.'\', titre = \''.$title.'\', requi = \''.$requi.'\'
-	WHERE id = '.$id.'
-	;';
-    pwg_query($query);
-	
-	$query='DELETE FROM '.MPS_OPT_VAL_TABLE.' 
-	WHERE select_id =  '.$id.'
-	;';
-	pwg_query($query);
-   
-	if(isset($_POST['val'])){
-	$val		= $_POST['val'];
-
-    foreach($val as $val_ele)
-    {
-	
-	 $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 
-			values (\''.$val_ele.'\',\''.$id.'\');';
-	 $result = pwg_query($query);
-    }
-	}
-   $page['infos']=l10n('Option registered');
-
-	}
-
-}
-
-if(isset($_POST['newOrder']))
-	{
-	$newOrder = explode(",", $_POST['newOrder']);
-	$ex = array_pop($newOrder);
-	
-	foreach( $newOrder as $order => $id )
-	{
-	$order = $order +1;
-
-      $query='UPDATE '.MPS_OPTION_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';';
-	$result = pwg_query($query);
-    
-    $page['infos']=l10n('the order is changed');
-
-    }
-}
-
-  $query='
-  SELECT *  FROM '.MPS_OPTION_TABLE.' ORDER BY `order` ;';
-
-  $option = array();
-  $result = pwg_query($query);
-  while($row = pwg_db_fetch_assoc($result)){
-	 $query='
-	 SELECT *
-	 FROM '.MPS_OPT_VAL_TABLE.' 
-     WHERE select_id = '.$row['id'].'
-	 ;';
-	$val = array();	
-	$res = pwg_query($query);
-	 while($row1 = pwg_db_fetch_assoc($res)){
-	 $val[]= $row1['val'];
-	 }
-	$opt = array("id"	 =>$row['id'],
-				 "title" =>$row['titre'],
-				 "name"  =>$row['name'],
-				 "type"  =>$row['type'],
-				 "requi" =>$row['requi'],
-				 "val"   =>$val
-					);
-	$option[$row['id']] = $opt;
-	
- }		
-
-
-   $template->assign(array(
+   }
+  
+//template assign
+  $template->assign(array(
 	 'mps_option'   => $option,
 	 'mps_type_opt' => $select_type_opt
 	 ));
 
-
-$template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl'));
+  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/options.tpl'));
+  
Index: /extensions/MyPiwiShop/admin/product.php
===================================================================
--- /extensions/MyPiwiShop/admin/product.php	(revision 27780)
+++ /extensions/MyPiwiShop/admin/product.php	(revision 27781)
@@ -2,207 +2,235 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
-
-  if(isset($_POST['check'])){
-   foreach($_POST['check'] AS $delete_id){
-   
-   $query='DELETE FROM '.MPS_PRODUCT_TABLE.' 
-   WHERE id = '.$delete_id.';';
-   pwg_query($query);
+// delete option
+  if(isset($_POST['check'])) {
+  
+   foreach($_POST['check'] AS $delete_id) {
+   
+    pwg_query('
+    DELETE FROM '.MPS_PRODUCT_TABLE.' 
+    WHERE id = '.$delete_id.'
+    ;');
+   
+    pwg_query('
+    DELETE FROM '.MPS_PROD_OPT_TABLE.' 
+    WHERE product_id = '.$delete_id.'
+    ;');
+   }   
+   
    $page['infos']=l10n('deleted');
-   
-   $query='DELETE FROM '.MPS_PROD_OPT_TABLE.' 
-   WHERE product_id = '.$delete_id.';';
-   pwg_query($query);
-   
-
+  }   
+
+//Add/Edit product
+  if(isset($_POST['product_add'])) {
+  
+  //Add product
+    if (empty($_POST['id'])) {
+	
+	 $order = array();
+	 $query ='
+	 SELECT `order`
+	 FROM '.MPS_PRODUCT_TABLE.'
+	 ;';
+	 
+	 $result = pwg_query($query);
+	 while($row = pwg_db_fetch_assoc($result)) {
+      $order[] = $row['order'];
+	 }
+	 if (count($order) == 0) {
+	  $order = 1;
+	 } else {
+	  $order = max($order)+1;
+	 }
+	
+	 $product	= $_POST['product'];
+	 $noteAdmin	= $_POST['noteAdmin'];
+	 $price		= $_POST['price'];
+
+	
+     pwg_query('
+	 INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`) 
+	 VALUE (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\');
+	 ');
+	 $prod = pwg_db_insert_id();
+   
+     if(isset($_POST['opt'])) {
+	  $opt = $_POST['opt'];
+      $inserts = array();
+	  
+      foreach ($opt as $opt_id) {
+       $inserts[] = array(
+        'opt_id' => $opt_id,
+        'product_id' => $prod,
+       );
+      }
+	  
+      mass_inserts(
+      MPS_PROD_OPT_TABLE,
+      array_keys($inserts[0]),
+      $inserts
+      );
+     }
+	 
+	 $page['infos']=l10n('Product registered');
+    }
+	
+  //Edit product	
+    if(!empty($_POST['id'])) {
+	
+	 $id 		= $_POST['id'];
+	 $product	= $_POST['product'];
+	 $noteAdmin	= $_POST['noteAdmin'];
+	 $price		= $_POST['price'];
+
+	 pwg_query('
+	 UPDATE '.MPS_PRODUCT_TABLE.' 
+	 SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\'
+	 WHERE id = '.$id.'
+	 ;');
+   
+     pwg_query('
+	 DELETE FROM '.MPS_PROD_OPT_TABLE.' 
+	 WHERE `product_id` IN ('.$id.')
+	 ;');
+	
+	 if(isset($_POST['opt'])) {
+	  $opt		= $_POST['opt'];
+      $inserts 	= array();
+	  
+      foreach ($opt as $opt_id) {
+       $inserts[] = array(
+        'opt_id' 	 => $opt_id,
+        'product_id' => $id,
+       );
+      }
+	  
+     mass_inserts(
+     MPS_PROD_OPT_TABLE,
+     array_keys($inserts[0]),
+     $inserts
+     );
+     }
+
+    $page['infos']=l10n('Edit');
+    }
+
+  }
+  
+// Change order
+  if(isset($_POST['newOrder'])) {
+   $newOrder = explode(",", $_POST['newOrder']);
+   $ex 		 = array_pop($newOrder);
+	
+	foreach( $newOrder as $order => $id ) {
+	 $order = $order +1;
+
+     pwg_query('
+	 UPDATE '.MPS_PRODUCT_TABLE.' 
+	 SET `order` = \''.$order.'\' 
+	 WHERE id = '.$id.'
+	;');
+    }
+	
+    $page['infos']=l10n('the order is changed');
+  }
+
+if (isset($_POST['option_add'])) {
+	 $order = array();
+	 
+	 $query ='SELECT * 
+	 FROM '.MPS_OPTION_TABLE.';';
+	 $result = pwg_query($query);
+	 
+	 while($row = pwg_db_fetch_assoc($result)) {
+       $order[] = $row['order'];
+	 }
+	 
+	 if (count($order) == 0) {
+	  $order = 1;
+	 } else {
+	  $order = max($order)+1;
+	 }
+	
+	 $name		= $_POST['name'];
+     $type		= $_POST['type'];
+     $title		= $_POST['title'];
+	 
+	 if(isset($_POST['requi'])) {
+	  $requi = $_POST['requi'];
+	 } else {
+	  $requi = 0;
+	 }
+	
+	 pwg_query('
+	 INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 
+	 VALUE (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\')
+	 ;');
+   
+	 $select_id = pwg_db_insert_id();			
+			
+	 if(isset($_POST['val'])) {
+	 $val		= $_POST['val'];
+	 
+      foreach($val as $val_ele) {
+	   pwg_query('
+	   INSERT into '.MPS_OPT_VAL_TABLE.' (`val` , `select_id`) 
+	   VALUE (\''.$val_ele.'\',\''.$select_id.'\')
+	   ;');
+      }
+	  
+	 }
+	
+	echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>');
+  }
+
+// set product    
+  $query='
+  SELECT p.id, p.order, p.product, p.noteAdmin, p.price, o.name 
+  FROM '.MPS_PRODUCT_TABLE.' AS p
+  LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS op ON op.product_id = p.id
+  LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = op.opt_id
+  ORDER BY p.order
+  ;';
+  $result = pwg_query($query);
+  
+  while($row = pwg_db_fetch_assoc($result)) {
+  
+   if (!isset($products[ $row['id']])) {
+	$products[$row['id']] = array(
+	 'id'	     => $row['id'],
+     'product'   => $row['product'],
+     'noteAdmin' => $row['noteAdmin'],
+     'price'     => $row['price'],
+	  );
    }
-   }   
-
-if(isset($_POST['product_add']))
-{
-if(!empty($_POST['id']))
-	{
-	$id 		= $_POST['id'];
-	$product	= $_POST['product'];
-	$noteAdmin	= $_POST['noteAdmin'];
-	$price		= $_POST['price'];
-
-	$query='UPDATE '.MPS_PRODUCT_TABLE.' 
-	SET product = \''.$product.'\',noteAdmin = \''.$noteAdmin.'\',price=\''.$price.'\'
-	WHERE id = '.$id.';';
-   pwg_query($query);
-   
-    $query = 'DELETE FROM '.MPS_PROD_OPT_TABLE.' WHERE product_id IN ('.$id.');';
-	pwg_query($query);
-	
-	if(isset($_POST['opt']))
-    {
-	$opt		= $_POST['opt'];
-    $inserts 	= array();
-    foreach ($opt as $opt_id)
-    {
-      $inserts[] = array(
-          'opt_id' 	   => $opt_id,
-          'product_id' => $id,
-        );
-    }
-    mass_inserts(
-    MPS_PROD_OPT_TABLE,
-    array_keys($inserts[0]),
-    $inserts
-    );
-   }
-
-   $page['infos']=l10n('Edit');
-  }
-  
-
-if (empty($_POST['id'])and isset($_POST['product'])and isset($_POST['price'])and is_numeric($_POST['price'])) 
-	{
-	$order = array();
-	$query ='SELECT * FROM '.MPS_PRODUCT_TABLE.';';
-	$result = pwg_query($query);
-	while($row = pwg_db_fetch_assoc($result)){
-    	$order[] = $row['order'];
-	}
-	if (count($order) == 0) {
-	$order = 1;
-	}else{
-	$order = max($order)+1;
-	}
-	
-	$product	= $_POST['product'];
-	$noteAdmin	= $_POST['noteAdmin'];
-	$price		= $_POST['price'];
-
-	
-   $query='INSERT into '.MPS_PRODUCT_TABLE.' (`order`,`product`,`noteAdmin`,`price`) 
-			values (\''.$order.'\',\''.$product.'\',\''.$noteAdmin.'\',\''.$price.'\');';
-   $result=pwg_query($query);
-	$prod = pwg_db_insert_id();
-   
-   if(isset($_POST['opt']))
-   {
-	$opt = $_POST['opt'];
-    $inserts = array();
-    foreach ($opt as $opt_id)
-    {
-      $inserts[] = array(
-          'opt_id' => $opt_id,
-          'product_id' => $prod,
-        );
-    }
-    mass_inserts(
-    MPS_PROD_OPT_TABLE,
-    array_keys($inserts[0]),
-    $inserts
-    );
-   }
-	$page['infos']=l10n('Product registered');
-  }
-}
-
-if(isset($_POST['newOrder']))
-	{
-	$newOrder = explode(",", $_POST['newOrder']);
-	$ex = array_pop($newOrder);
-	
-	foreach( $newOrder as $order => $id )
-	{
-	$order = $order +1;
-
-      $query='UPDATE '.MPS_PRODUCT_TABLE.' SET `order` = \''.$order.'\' WHERE id = '.$id.';';
-	$result = pwg_query($query);
-    
-    $page['infos']=l10n('the order is changed');
-
-    }
-}
-
-  $select_type_opt=array(
-  'select'   =>'select',
-  'radio'    =>'radio',
-  'text'     =>'text',
-  'textarea' =>'textarea',
-  'checkbox' =>'checkbox',
-  );
-  
-if (isset($_POST['option_add']))
-{
-	$order = array();
-	$query ='SELECT * FROM '.MPS_OPTION_TABLE.';';
-	$result = pwg_query($query);
-	while($row = pwg_db_fetch_assoc($result)){
-    	$order[] = $row['order'];
-	}
-	
-	if (count($order) == 0) {
-	$order = 1;
-	}else{
-	$order = max($order)+1;
-	}
-
-	$name		= $_POST['name'];
-    $type		= $_POST['type'];
-    $title		= $_POST['title'];
-	
-	if(isset($_POST['requi'])){
-	 $requi = $_POST['requi'];
-	 }else{
-	 $requi = 0;
-	 }
-	
-	
-	$query='INSERT into '.MPS_OPTION_TABLE.' (`name`,`type`,`titre`,`requi`,`order`) 
-			values (\''.$name.'\',\''.$type.'\',\''.$title.'\',\''.$requi.'\',\''.$order.'\');';
-   
-	pwg_query($query);		
-	$select_id = pwg_db_insert_id();			
-			
-	if(isset($_POST['val'])){
-	$val = $_POST['val'];
-     foreach($val as $val_ele)
-      {
-	  $query='INSERT into '.MPS_OPT_VAL_TABLE.' (val,select_id) 
-			values (\''.$val_ele.'\',\''.$select_id.'\');';
-	  pwg_query($query);
-     }
-	}
-	
-	 echo('<div><div id="idlastopt" data-idlo="'.$select_id.'"></div></div>');
-	
-}
-  
- $query='SELECT * FROM '.MPS_PRODUCT_TABLE.' ORDER BY `order`;';
-  $result = pwg_query($query);
-  $products = array();
-  while($row = pwg_db_fetch_assoc($result)){
-  	$query='
-	SELECT *
-	FROM '.MPS_PROD_OPT_TABLE.' AS op
-	JOIN '.MPS_OPTION_TABLE.' AS p ON p.id = op.opt_id
-	WHERE product_id = '.$row['id'].'
-	;';
-	$res = pwg_query($query);
-	$opt = array();
-	while($row1 = pwg_db_fetch_assoc($res)){
-    $opt[] = $row1['name'];
-	}
-	$row['option'] = $opt ;
-	$products[$row['id']]=$row;
-  }
-  
-
-  $query='SELECT * FROM '.MPS_OPTION_TABLE.' ;';
+   
+   $products[$row['id']]['option'][]=$row['name'];
+  }
+
+  $query='
+  SELECT `id`, `name`
+  FROM '.MPS_OPTION_TABLE.' 
+  ;';
   $result = pwg_query($query);
   $option = array();
-  while($row = pwg_db_fetch_assoc($result)){
+  
+  while($row = pwg_db_fetch_assoc($result)) {
    $option[$row['id']] = $row['name'];
   }
-
-$template->assign(array(
-  'mps_product'	=> $products,
-  'mps_option' 	=> $option,
-  'mps_type_opt'		=> $select_type_opt,
+  
+  $select_type_opt=array(
+   'select'   =>'select',
+   'radio'    =>'radio',
+   'text'     =>'text',
+   'textarea' =>'textarea',
+   'checkbox' =>'checkbox',
+  );
+  
+//template assign
+  $template->assign(array(
+   'mps_product'	 => $products,  
+   'mps_option' 	 => $option,
+   'mps_type_opt' => $select_type_opt,
   ));
-$template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl'));
+  
+  $template->set_filename('mps_content', realpath(MPS_PATH . 'admin/template/product.tpl'));
Index: /extensions/MyPiwiShop/admin/template/product.tpl
===================================================================
--- /extensions/MyPiwiShop/admin/template/product.tpl	(revision 27780)
+++ /extensions/MyPiwiShop/admin/template/product.tpl	(revision 27781)
@@ -442,5 +442,5 @@
 			<td><span>{$product.product}</span> <a title="{'edit'|translate|escape:'javascript'}" class="prodEdit icon-pencil tabact">{'edit'|translate}</a> <a title="{'duplicate'|translate|escape:'javascript'}" class="prodDupli icon-pencil tabact">{'duplicate'|translate}</a></td>
 			<td>{$product.noteAdmin} </td>
-			<td>{foreach from=$product.option item=option name=option}{$option}/{/foreach}</td>
+			<td>{foreach from=$product.option item=option name=option}{if !empty($option)}{$option}/{/if}{/foreach}</td>
 			<td>{$product.price} {$mps_conf.currency}</td>
 		</tr>
Index: /extensions/MyPiwiShop/include/admin_events.inc.php
===================================================================
--- /extensions/MyPiwiShop/include/admin_events.inc.php	(revision 27780)
+++ /extensions/MyPiwiShop/include/admin_events.inc.php	(revision 27781)
@@ -2,7 +2,6 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
-/**
- * admin plugins menu link
- */
+
+// admin plugins menu link
 function mps_admin_plugin_menu_links($menu) 
 {
@@ -15,9 +14,5 @@
 }
 
-
-/**
- * add an action to the Batch Manager unit
-*/
-
+//add an action to the Batch Manager unit
 function mps_loc_end_element_set_unit()
 {
@@ -25,66 +20,51 @@
   
   global $template;
-	$template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl'));
-	$template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit');
-
-	$template->set_prefilter('batch_manager_unit', 'batch_unit_form');
+  $template->set_filename('mps_batch_unit', realpath(MPS_PATH.'admin/template/MyPiwiShopBatchUnit.tpl'));
+  $template->assign_var_from_handle('MPS_BATCH_UNIT', 'mps_batch_unit');
+  $template->set_prefilter('batch_manager_unit', 'batch_unit_form');
 }
 
 function batch_unit_form($content)
 {
-
-	$search = '#</table>(\s*)</fieldset>#s';
-	$replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"}
-	{include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>';
+  $search = '#</table>(\s*)</fieldset>#s';
+  $replace ='</table>$1<div class="MyPiwiShopBatchUnit" style="text-align:left">{combine_script id="batchmanagerunit" load="footer" path="'.MPS_PATH.'/admin/template/js/batchmanagerunit.js"}
+  {include file="'.realpath(MPS_PATH).'/admin/template/MyPiwiShopBatchUnit.tpl" imgid=$element.id}</div>$1</fieldset>';
 
   return preg_replace($search, $replace, $content);
 }
 
-/**
- * add an action to the Batch Manager
- */
-
+//add an action to the Batch Manager
 function mps_loc_end_element_set_global()
 {
-	 include_once(MPS_PATH.'admin/MyPiwiShopBatch.php');
+  include_once(MPS_PATH.'admin/MyPiwiShopBatch.php');
 
-	global $template;
-	
-	$template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl'));
-  
-	$template->append('element_set_global_plugins_actions', array(
-    'ID' => 'mps', 
-    'NAME' => l10n('MyPiwiShop'), 
-    'CONTENT' => $template->parse('mps_batch_global', true)
-    ));
+  global $template;
+  $template->set_filename('mps_batch_global', (MPS_PATH.'admin/template/MyPiwiShopBatch.tpl'));
+  $template->append('element_set_global_plugins_actions', array(
+   'ID' => 'mps', 
+   'NAME' => l10n('MyPiwiShop'), 
+   'CONTENT' => $template->parse('mps_batch_global', true)
+  ));
 }
 
-/**
- * perform added action
-*/ 
+// perform added action
 function mps_element_set_global_action($action, $collection)
 {
-	if ($action == 'mps')
-	{
-	global $page;
+  if ($action == 'mps')	{
+   global $page;
 	
-		if (empty($_POST['productcheck']))
-		{
-		$page['errors'][] = l10n('Select at least one product');
-		}
-		else if ($_POST['thisprod']=='del')
-		{
-		$product_id = $_POST['productcheck'];
-		deletAll_product_image($product_id, $collection);
-		$page['infos'][] = l10n('Products have been removed for these pictures');	
-		}
-		else
-		{
-		$product_id = $_POST['productcheck'];
-		add_product_image($product_id, $collection);
-		$page['infos'][] = l10n('products have been added to these images');	
-		}
+   if (empty($_POST['productcheck'])) {
+	$page['errors'][] = l10n('Select at least one product');
+   } else if ($_POST['thisprod']=='del') {
+	$product_id = $_POST['productcheck'];
+	deletAll_product_image($product_id, $collection);
+	$page['infos'][] = l10n('Products have been removed for these pictures');	
+   } else {
+    $product_id = $_POST['productcheck'];
+    add_product_image($product_id, $collection);
+	$page['infos'][] = l10n('products have been added to these images');	
+   }
+   
   } 
-  
 }
 
Index: /extensions/MyPiwiShop/include/functions.inc.php
===================================================================
--- /extensions/MyPiwiShop/include/functions.inc.php	(revision 27780)
+++ /extensions/MyPiwiShop/include/functions.inc.php	(revision 27781)
@@ -2,7 +2,5 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
-/**
-*product/image
-**/
+//add a product to all selected image
 function add_product_image($product, $images)
 {
@@ -12,48 +10,41 @@
   }
 
-  $query = '
-	DELETE
-	FROM '.MPS_PROD_IMG_TABLE.'
-	WHERE image_id IN ('.implode(',', $images).')
-	AND product_id IN ('.implode(',', $product).')
+  pwg_query('
+  DELETE
+  FROM '.MPS_PROD_IMG_TABLE.'
+  WHERE image_id IN ('.implode(',', $images).')
+  AND product_id IN ('.implode(',', $product).')
+  ;');
 
-	;';
-  pwg_query($query);
-
-  $inserts = array();
-  foreach ($images as $image_id)
-  {
-    foreach ( array_unique($product) as $product_id)
-    {
-      $inserts[] = array(
-          'image_id' => $image_id,
-          'product_id' => $product_id,
-        );
-    }
+  foreach ($images as $image_id) {
+  
+   foreach ( array_unique($product) as $product_id) {
+    $inserts[] = array(
+     'image_id' => $image_id,
+     'product_id' => $product_id,
+    );
+   }
   }
-    mass_inserts(
-    MPS_PROD_IMG_TABLE,
-    array_keys($inserts[0]),
-    $inserts
-    );
+  
+  mass_inserts(
+   MPS_PROD_IMG_TABLE,
+   array_keys($inserts[0]),
+   $inserts
+  );
 }
 
-/**
-*product/image
-**/
+//delet all product for all selected image
 function deletAll_product_image($product, $images)
 {
-  $query = '
-	DELETE
-	FROM '.MPS_PROD_IMG_TABLE.'
-	WHERE image_id IN ('.implode(',', $images).')
-	AND product_id IN ('.implode(',', $product).')
-
-	;';
-  pwg_query($query);
-
+  pwg_query('
+  DELETE
+  FROM '.MPS_PROD_IMG_TABLE.'
+  WHERE image_id IN ('.implode(',', $images).')
+  AND product_id IN ('.implode(',', $product).')
+  ;');
 }
 
-function deletThis_image_Allproduct($images)
+//delet all product to specific image
+function delet_Allproduct_Thisimage($images)
 {
   $query = '
@@ -67,4 +58,5 @@
 }
 
+//add a product to specific image
 function add_product_Thisimage($product, $images)
 {
Index: /extensions/MyPiwiShop/include/public_events.inc.php
===================================================================
--- /extensions/MyPiwiShop/include/public_events.inc.php	(revision 27780)
+++ /extensions/MyPiwiShop/include/public_events.inc.php	(revision 27781)
@@ -2,79 +2,78 @@
 defined('MPS_PATH') or die('Hacking attempt!');
 
-/*
- * button on album and photos pages
- */
+//button on album and photos pages
 function mps_add_button()
 {
   global $template, $conf;
   
- $query='SELECT * FROM '.MPS_CONF_TABLE.';';
-    $result 	= pwg_query($query);
-    while($row = pwg_db_fetch_assoc($result)){
-    $config = $row ;
-   }
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.'
+  ;';
+  $result 	= pwg_query($query);
+  
+  while($row = pwg_db_fetch_assoc($result)){
+   $config = $row ;
+  }
 
-	$template->assign(array(
-    'mps_conf'	=> $config,
-	'MPS_PATH'	=> MPS_PATH,
-    ));   
-//  $template->assign('MPS_PATH', MPS_PATH);
+  $template->assign(array(
+   'mps_conf'	=> $config,
+   'MPS_PATH'	=> MPS_PATH,
+  ));   
+
   $template->set_filename('mps_button', realpath(MPS_PATH.'template/button_basket.tpl'));
-//  $template->assign('mps_conf' , $config);
-
   $button = $template->parse('mps_button', true);
   
-  if (script_basename()=='index')
-  {
+  if (script_basename()=='index') {
     $template->add_index_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL);
-  }
-  else
-  {
+  } else {
     $template->add_picture_button($button, EVENT_HANDLER_PRIORITY_NEUTRAL);
   }
 }
 
-/**
- * add a forms on photo page
- */
-function mps_loc_end_picture()
+// add a forms on photo page
+function mps_init_form_picture()
 {
   global $template;
-	$template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl'));
-	$template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop');
+  
+  $template->set_filename('MyPiwiShop', realpath(MPS_PATH.'template/MyPiwiShop.tpl'));
+  $template->assign_var_from_handle('MPS_CONTENT', 'MyPiwiShop');
 }
 
+// place on picture page (default theme)
 function mps_picture_form($content)
 {
-	$search = '#</div>(\s*)</div>(\s*){if isset\(\$COMMENT_COUNT\)}#s';
-	$replace =  '</div>$1</div>$2<div id="MyPiwiShop">{$MPS_CONTENT}</div>{if isset(\$COMMENT_COUNT)}';
+  $search = '#</div>(\s*)</div>(\s*){if isset\(\$COMMENT_COUNT\)}#s';
+  $replace =  '</div>$1</div>$2<div id="MyPiwiShop">{$MPS_CONTENT}</div>{if isset(\$COMMENT_COUNT)}';
 
-	return preg_replace($search, $replace, $content);
+  return preg_replace($search, $replace, $content);
 }
 
+// place on picture page (piwitheme theme)
 function mps_picture_form_piwitheme($content)
 {
-	$search = '#{/foreach}(\s*){/foreach}(\s*)</table>(\s*){/if}(\s*)</div>#s';
-	$replace =  '{/foreach}$1{/foreach}$1</table>$1{/if}</div><div class="panelPP"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div>';
+  $search = '#{/foreach}(\s*){/foreach}(\s*)</table>(\s*){/if}(\s*)</div>#s';
+  $replace =  '{/foreach}$1{/foreach}$1</table>$1{/if}</div><div class="panelPP"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div>';
 
-	$newcont = preg_replace($search, $replace, $content);
+  $newcont = preg_replace($search, $replace, $content);
 
-	$search = '#<a class="trigger" href="\#">(\s*)infos(\s*)</a>(\s*)#s';
-	$replace =  '<a class="trigger" href="#">infos</a>$1<a class="triggerPP" href="#" >{\'Shop\'|@translate}</a>{footer_script}{literal}$(document).ready(function(){$(".triggerPP").click(function(){$(".panelPP").toggle("fast");$(this).toggleClass("active");return false;});});{/literal}{/footer_script}';
+  $search = '#<a class="trigger" href="\#">(\s*)infos(\s*)</a>(\s*)#s';
+  $replace =  '<a class="trigger" href="#">infos</a>$1<a class="triggerPP" href="#" >{\'Shop\'|@translate}</a>{footer_script}{literal}$(document).ready(function(){$(".triggerPP").click(function(){$(".panelPP").toggle("fast");$(this).toggleClass("active");return false;});});{/literal}{/footer_script}';
 
-	return preg_replace($search, $replace, $newcont);
+  return preg_replace($search, $replace, $newcont);
 }
 
+// place on picture page (stripped theme)
 function mps_picture_form_stripped($content)
 {
-	$search = '#<div style="clear: both;"></div>(\s*)</div>(\s*)</div>(\s*)</div>(\s*){/if}(\s*)</div>#s';
-	$replace =  '<div style="clear: both;"></div></div>$1</div></div>$2{/if}<div id="Tmps" class="tabBlock"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div></div>';
+  $search = '#<div style="clear: both;"></div>(\s*)</div>(\s*)</div>(\s*)</div>(\s*){/if}(\s*)</div>#s';
+  $replace =  '<div style="clear: both;"></div></div>$1</div></div>$2{/if}<div id="Tmps" class="tabBlock"><div id="MyPiwiShop">{$MPS_CONTENT}</div></div></div>';
 
-	$newcont = preg_replace($search, $replace, $content);
+  $newcont = preg_replace($search, $replace, $content);
 
-	$search = '#{/if}(\s*)</ul>(\s*)#s';
-	$replace =  '{/if}$2<li id="tabTmps" class="tabTitle" title="{\'Shop\'|@translate}" name="shop">{\'Shop\'|@translate}</li></ul>';
+  $search = '#{/if}(\s*)</ul>(\s*)#s';
+  $replace =  '{/if}$2<li id="tabTmps" class="tabTitle" title="{\'Shop\'|@translate}" name="shop">{\'Shop\'|@translate}</li></ul>';
 
-	return preg_replace($search, $replace, $newcont);
+  return preg_replace($search, $replace, $newcont);
 }
 
@@ -82,75 +81,78 @@
 {
   global $conf, $template, $picture, $user;
-	$image_id = $picture['current']['id'];
+  
+  $image_id = $picture['current']['id'];
   	
-   $query='SELECT * FROM '.MPS_CONF_TABLE.';';
-      $result 	= pwg_query($query);
-      while($row = pwg_db_fetch_assoc($result)){
-      $config = $row ;
-     }
+  $query='
+  SELECT * 
+  FROM '.MPS_CONF_TABLE.'
+  ;';
+  $result = pwg_query($query);
+  
+  while($row = pwg_db_fetch_assoc($result)) {
+   $config = $row ;
+  }
 
-   $query = '
-	SELECT *
-    FROM '.MPS_PROD_IMG_TABLE.' AS pi
-    INNER JOIN '.MPS_PRODUCT_TABLE.' AS p ON pi.product_id = p.id
-    WHERE image_id = '.$image_id .'
-	ORDER BY `order`
+  $query = '
+  SELECT *
+  FROM '.MPS_PROD_IMG_TABLE.' AS pi
+  INNER JOIN '.MPS_PRODUCT_TABLE.' AS p ON pi.product_id = p.id
+  WHERE image_id = '.$image_id .'
+  ORDER BY `order`
     ;';
-  	$result = pwg_query($query);
-  	$num_rows = pwg_db_num_rows($result);
-     if ($num_rows != 0){
-      while($row = pwg_db_fetch_assoc($result)){
-	  $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency'];
-      $price[] = $row['price'];
-     } 
+  $result = pwg_query($query);
+  $num_rows = pwg_db_num_rows($result);
+  
+  if ($num_rows != 0) {
+   while($row = pwg_db_fetch_assoc($result)) {
+    $product[$row['product']] = $row['product'].' '. $row['price'].' '. $config['currency'];
+    $price[] = $row['price'];
+   } 
 
   
-  $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val  
+   $query='SELECT pi.product_id, po.product_id, p.price, p.product, o.name, o.type, o.requi, o.order, po.opt_id, ov.val  
    FROM '.MPS_PROD_IMG_TABLE.' AS pi
-    LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id
-	LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id
-	LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id
-	LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
-	WHERE image_id = '.$image_id .'
-	AND po.opt_id IS NOT NULL
-	 ;';
-
-	 $result = pwg_query($query);
-	while($row = pwg_db_fetch_assoc($result)){
-	{
-		if (!isset($products[ $row['product']]['options'][ $row['order'] ]))
-		{
-			$products[ $row['product'] ]['options'][ $row['order'] ] = array(
-			'name'   => $row['name'],
-			'type'   => $row['type'],
-			'requi'  => $row['requi'],
-			'values' => array(),
-			);
-		}
+   LEFT JOIN '.MPS_PRODUCT_TABLE.' AS p ON p.id = pi.product_id
+   LEFT JOIN '.MPS_PROD_OPT_TABLE.' AS po ON po.product_id = p.id
+   LEFT JOIN '.MPS_OPTION_TABLE.' AS o ON o.id = po.opt_id
+   LEFT JOIN '.MPS_OPT_VAL_TABLE.' AS ov ON ov.select_id = o.id
+   WHERE image_id = '.$image_id .'
+   AND po.opt_id IS NOT NULL
+   ;';
+   $result = pwg_query($query);
+	 
+   while($row = pwg_db_fetch_assoc($result)) {
+    {
+	 if (!isset($products[ $row['product']]['options'][ $row['order'] ])) {
+	  $products[ $row['product'] ]['options'][ $row['order'] ] = array(
+	   'name'   => $row['name'],
+	   'type'   => $row['type'],
+	   'requi'  => $row['requi'],
+	   'values' => array(),
+	  );
+	 }
+	 $products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val'];
+   
+    }
+   }
   
-	$products[ $row['product'] ]['options'][ $row['order'] ]['values'][] = $row['val'];
-	}
-    }
-	if(isset($products)){
-     $template->assign(array(
-	 'mps_options'  		=> $products,
-  	 ));
-	}
-  
-  	$template->assign(array(
-  	'mps_conf'	  		=> $config,
-	'mps_price'			=> $price,
-	'mps_product'		=> $product,
-  	));
+   if(isset($products)) {
+    $template->assign(array(
+     'mps_options'  => $products,
+    ));
+   }
+   
+   $template->assign(array(
+    'mps_conf'  	=> $config,
+    'mps_price'   => $price,
+    'mps_product' => $product,
+   ));
 	
-
-	
-	
-	$theme = $user['theme'];
-	
- switch ($theme) {
+   $theme = $user['theme'];
+   
+   switch ($theme) {
     case 'stripped':
-        $template->set_prefilter('picture', 'mps_picture_form_stripped');
-        break;
+     $template->set_prefilter('picture', 'mps_picture_form_stripped');
+     break;
 	case 'PwgCarbon_dft':
 	case 'PwgCarbon':
@@ -159,14 +161,12 @@
 	case 'Slimi':
 	case 'Slim':
-        $template->set_prefilter('picture', 'mps_picture_form_piwitheme');
-		$template->assign(array('bypiwitheme'=> 'bypiwitheme'));
-        break;
+     $template->set_prefilter('picture', 'mps_picture_form_piwitheme');
+	 $template->assign(array('bypiwitheme'=> 'bypiwitheme'));
+     break;
     default:
-        $template->set_prefilter('picture', 'mps_picture_form');
-        break;
-}
-
-
+     $template->set_prefilter('picture', 'mps_picture_form');
+     break;
    }
+  }
 }
 
Index: /extensions/MyPiwiShop/main.inc.php
===================================================================
--- /extensions/MyPiwiShop/main.inc.php	(revision 27780)
+++ /extensions/MyPiwiShop/main.inc.php	(revision 27781)
@@ -35,6 +35,5 @@
 add_event_handler('init', 'mps_init');
 
-if (defined('IN_ADMIN'))
-{
+if (defined('IN_ADMIN')) {
   include_once(MPS_PATH . 'include/admin_events.inc.php');
   
@@ -47,8 +46,5 @@
   add_event_handler('element_set_global_action', 'mps_element_set_global_action', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
   add_event_handler('loc_end_element_set_unit', 'mps_loc_end_element_set_unit');
-
-}
-else
-{
+} else {
   // file containing all public handlers functions
   include_once(MPS_PATH . 'include/public_events.inc.php');
@@ -60,5 +56,5 @@
   // form on photo page
   add_event_handler('loc_end_picture', 'mps_prepar_tpl');
-  add_event_handler('loc_end_picture', 'mps_loc_end_picture');
+  add_event_handler('loc_end_picture', 'mps_init_form_picture');
 }
 
@@ -66,6 +62,5 @@
 include_once(MPS_PATH . 'include/functions.inc.php');
 
- function mps_init()
-{
+ function mps_init() {
   global $prefixeTable;
   
@@ -75,17 +70,20 @@
   $maintain->autoUpdate(MPS_VERSION, 'install');
   
-  	$query='SELECT * FROM '.MPS_CONF_TABLE.';';
-	if(pwg_db_num_rows(pwg_query($query))==0){
-      single_insert(
-       $prefixeTable."mps_conf",
-       array(
-        'currency' => 'EUR',
-        )
-      );
-	}
+  $query='
+  SELECT *
+  FROM '.MPS_CONF_TABLE.'
+  ;';
+	
+  if(pwg_db_num_rows(pwg_query($query))==0) {
+   single_insert(
+    $prefixeTable."mps_conf",
+    array(
+     'currency' => 'EUR',
+    )
+   );
+  }
   
   // load plugin language file
   load_language('plugin.lang', MPS_PATH);
-  
 }
 
Index: /extensions/MyPiwiShop/maintain.inc.php
===================================================================
--- /extensions/MyPiwiShop/maintain.inc.php	(revision 27780)
+++ /extensions/MyPiwiShop/maintain.inc.php	(revision 27781)
@@ -74,19 +74,12 @@
 	;');
 	
-	    $this->installed = true;
-
+	$this->installed = true;
   }  
 	
-
-  /**
-   * plugin activation
-   */
-   function activate($plugin_version, &$errors=array())
+  function activate($plugin_version, &$errors=array())
   {
-
-   if (!$this->installed)
-    {
-      $this->install($plugin_version, $errors);
-    }
+   if (!$this->installed) {
+    $this->install($plugin_version, $errors);
+   }
   }
  
@@ -95,8 +88,4 @@
   }
 
-
-  /**
-   * plugin uninstallation
-   */
   function uninstall()
   {
@@ -109,5 +98,5 @@
     pwg_query('DROP TABLE `'. $prefixeTable .'mps_opt_val`;');
     pwg_query('DROP TABLE `'. $prefixeTable .'mps_prod_opt`;');
- }
+  }
 }
 
