1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
public function __construct()
{
$this->table = 'ps_promotions';
$this->className = 'Promotions';
$this->lang=false;
$this->edit = true;
$this->delete = true;
$this->fieldsDisplay = array(
'id_promotion' => array('title' => 'id_promotion', 'width' => 25),
'prix' => array('title' => 'Prix', 'width' => 60),
'pourcentage' => array('title' => 'Pourcentage', 'width' => 40,'align' => 'center'),
'id_product' => array('title' => 'id_produit', 'width' => 100, 'align' => 'center'),
);
$this->identifier='id_promotion';
parent::__construct();
}
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
echo '<form action="'.$currentIndex.'&token='.$this->token.'&my_form=1" method="post">
<label>Produit :</label>
<div class="margin-form">';
echo "<select name='produit'>";
$sql=mysql_query("SELECT distinct(id_product), name FROM ps_product_lang WHERE id_lang=2 AND id_product < 1000 ORDER BY name");
while ($ligne = mysql_fetch_array($sql))
{
echo "<option value='".$ligne['id_product']."'>".$ligne['name']."</option>";
}
echo "</select>";
echo '</div>
<label>Promotion :</label>
<div class="margin-form">
<input type="text" name="prix" />
</div>
<label>Pourcentage :</label>
<div class="margin-form">
<input type="text" name="pourcentage" />
</div>
<div class="margin-form">
<input type="submit" name="submit" value="Valider le produit" />
</div>
</form>';
}
public function postProcess()
{
global $currentIndex, $cookie;
if (Tools::isSubmit('submit'))
{
$sql=mysql_query('INSERT INTO ps_promotions (prix, pourcentage, id_product) VALUES ('.$_POST['prix'].',"'.$_POST['pourcentage'].'",'.$_POST['produit'].')');
}
}
public function displayListContent()
{
$sql=mysql_query("SELECT * FROM ps_promotions");
if (!empty($sql))
{
while($result=mysql_fetch_array($sql))
{
echo $result['id_promotion'];
echo $result['prix'];
echo $result['pourcentage'];
echo $result['id_product'];
}
}
} |
Partager