Jump to content

Redirection après update


Recommended Posts

bonjour ,

j'ai un problème de redirection après une requête update

quand je clique sur modifier produit normalement je vais vers une page qui permet au modification mais il ne prend en considération que la fonction header du contrôleur et ça redirige directement vers la page déclarée dedans

voila le code php:

<?php
/*
Formulaire spécifique pour Prestashop 1.4
CrCom - Franck Mercier
http://www.crcom.fr
*/
class ModifProductControllerCore extends FrontController
{
   public function postProcess()
   {

  global $cookie; global $smarty;
   $id_product= $_GET['id_product'];
		    $customer=$cookie->id_customer;
			 self::$smarty->assign('customer',$customer);			  
  $sql = 'SELECT p.*, pl.*
   FROM `'._DB_PREFIX_.'product` p

   INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`)
   WHERE pl.`id_product` = '.(int)$id_product.'

   ';

if ($results = Db::getInstance()->ExecuteS($sql))
foreach ($results as $row)
$smarty->assign('results',$results);
//On vérifie le bouton submit du formulaire
	 }
	 public function modif()
   {

		    // On va commencer en premier par récupérer l'id customer avec la variable cookie
		    // et vérifier que la personnes est bien loggée
		   $id_product= $_GET['id_product'];
$titre=Tools::getValue('titre');$prix=Tools::getValue('prix');$desc=Tools::getValue('desc');
				    $photo=$_FILES['photo'];$resume=Tools::getValue('resume');$ref=Tools::getValue('ref');$categorie=Tools::getValue('categorie_choisie');

    $sql='UPDATE '._DB_PREFIX_.'product_lang
		    SET `description` = "'.$desc.'",
 `description_short` = "'.$resume.'",
 `name` = "'.$titre.'"
 WHERE `id_product` = '.(int)$id_product.'
   ';
   $result=Db::getInstance()->ExecuteS($sql);

   $sql='UPDATE '._DB_PREFIX_.'product
		    SET `price` = "'.$prix.'",
 `wholesale_price` = "'.$prix.'",
 `reference` = "'.$ref.'",
 `id_category_default` = "'.$categorie.'"
 WHERE `id_product` = '.(int)$id_product.'
   ';
   $result1=Db::getInstance()->ExecuteS($sql);

$sql='UPDATE '._DB_PREFIX_.'category_product
		    SET `id_category` = "'.$categorie.'"
 WHERE `id_product` = '.(int)$id_product.' AND `id_category` != 55
   ';
   $result2=Db::getInstance()->ExecuteS($sql);

  $sql='UPDATE '._DB_PREFIX_.'product_shop
		    SET `price` = "'.$prix.'",
 `wholesale_price` = "'.$prix.'",
 `id_category_default` = "'.$categorie.'"
 WHERE `id_product` = '.(int)$id_product.'
   ';
   $result1=Db::getInstance()->ExecuteS($sql); 
   Formulaire::upload_image($photo,$titre,$customer);			   
		   header("Location: index.php?controller=my-account");
  exit();  


  }



   public function process()
   {
    parent::process();
    $this->postProcess();
 $this->modif();



   }
   public function displayContent()
   {
 global $cookie;
    parent::displayContent();
 $mes_categories=Category::getHomeCategories($cookie->id_lang);
   self::$smarty->assign('mes_categories',$mes_categories);
    self::$smarty->display(_PS_THEME_DIR_.'modifproduct.tpl');

   }
}

et voila le formulaire du modification:

<div class="form-div">
{foreach $results as $r}
<form action="{$request_uri}" method="post" enctype="multipart/form-data" class="std" id="myForm" name="myForm">
  <div class="cfg-contactform" id="cfg-contactform-21">
<div class="cfg-contactform-content">
<div class="cfg-element-container">
  <label class="cfg-label" id="cfg-element-21-1-label" for="titre" ><span class="cfg-label-value">Nom du produit:</span><span class="cfg-required">*</span></label>
  <div class="cfg-element-set" id="cfg-element-21-1-set" >
<div class="cfg-element-content">
	   <input type="text" name="titre" value="{$r.name}" class="cfg-type-text cfg-form-value" style="width:230px;" id="cfg-element-21-1" />
	  </div>
</div>
   <div class="cfg-clear"></div>
</div>
	    <div class="cfg-element-container">
<label class="cfg-label" id="cfg-element-21-2-label" for="ref" ><span class="cfg-label-value">Réference:</span><span class="cfg-required">*</span></label>
<div class="cfg-element-set" id="cfg-element-21-2-set" >
 <div class="cfg-element-content">
    <input type="text" name="ref" value="{$r.reference}" class="cfg-type-text cfg-form-value" style="width:230px;" id="cfg-element-21-2" />
    </div>
</div>
<div class="cfg-clear"></div>
</div>
<div class="cfg-element-container">
	    <label class="cfg-label" id="cfg-element-21-3-label" for="categorie_choisie" ><span class="cfg-label-value">Catégorie:</span><span class="cfg-required">*</span></label>
<div class="cfg-element-set" id="cfg-element-21-3-set" >
 <div class="cfg-element-content">
	    <select name="categorie_choisie" class="cfg-type-select cfg-form-value " id="cfg-element-21-3" >
		 {foreach from=$mes_categories item=category}
			 <option value="{$category.id_category}">{$category.name}</option>
		    {/foreach}
	   </select>
	   </div>
</div>

<div class="cfg-clear"></div>
</div>
<div class="cfg-element-container">
	    <label class="cfg-label" id="cfg-element-21-4-label" for="contenu" ><span class="cfg-label-value">Résumé: </span><span class="cfg-required">*</span></label>
<div class="cfg-element-set" id="cfg-element-21-4-set" >
 <div class="cfg-element-content">
	   <textarea name="resume" id="cfg-element-21-4" style="width:230px; height:200px;"  class="cfg-type-textarea cfg-form-value ">{$r.description_short}</textarea>
	   </div>
</div>

<div class="cfg-clear"></div>
</div>

		 <label style="font-family:'Arial';
font-weight:normal;
font-style:normal;
font-size:14px;
color:#000000;
width:310px;
float: left;
text-align: right;

height:22px;" id="cfg-element-21-5-label" for="desc" ><span class="cfg-label-value">Description de votre produit:</span></label><br/><br/>

	    <textarea name="desc" id="desc" style="width:750px">{$r.description}</textarea><br/>


   <div class="cfg-element-container">
	   <label class="cfg-label" id="cfg-element-21-6-label" for="prix" ><span class="cfg-label-value">Prix:</span><span class="cfg-required">*</span></label>
	  <div class="cfg-element-set" id="cfg-element-21-6-set" >
 <div class="cfg-element-content">
    <input type="text" name="prix" value="{$r.price}" class="cfg-type-text cfg-form-value" style="width:230px;"   id="cfg-element-21-6" />
	 </div>
</div>
<div class="cfg-clear"></div>
   </div>

<div class="cfg-element-container">
<label class="cfg-label" id="cfg-element-21-7-label" for="photo"  ><span class="cfg-label-value">Ajouter une photo du produit:</span></label>
	  <div class="cfg-element-set" id="cfg-element-21-7-set" >
 <div class="cfg-element-content">

	    <input type="file" name="photo"  style="width:220px; height:auto"  accept="image/*"/>
	    </div></div>
	    <div class="cfg-clear"></div>
</div>
   <p class="cart_navigation required submit">
	   <input type="submit" name="modifierr" value="modifier" class="exclusive" style="width:120px; font-size:12px" /></p>

   </div><!-- cfg-contactform-content -->
</div><!-- cfg-contactform -->	  

</form>{/foreach}   </div><br/>

pouvez vous m'aider svp

merci d'avance

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...