ÿØÿà JFIF ` ` ÿþxØ
| Server IP : 109.234.164.53 / Your IP : 216.73.216.110 Web Server : Apache System : Linux cervelle.o2switch.net 4.18.0-553.32.1.lve.el8.x86_64 #1 SMP Thu Dec 19 13:14:03 UTC 2024 x86_64 User : computer3 ( 1098) PHP Version : 7.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/computer3/litsolide.com/cp-admin/ |
Upload File : |
<?php
include_once('includes/header.php');
// Duplication du produit.
if (isset($_POST['form']))
{
$id_product= $_POST['num'];
$titre_new = $_POST['titre'];
$qidd = $bdd->query("SELECT id FROM " . $GLOBALS['db_table']['products'] . " WHERE titre='$titre_new'");
$prodd = $qidd->fetch();
$doublon = $prodd['id'];
if ($doublon >0) { echo'Doublon !'; } else {
//////////////////////////////////////////////////////
$sqlu = $GLOBALS['bdd']->prepare('SELECT company, meta_caption, meta_keywords FROM info WHERE id = :id');
$sqlu->execute(array('id' => 1));
$metau = $sqlu->fetch();
$meta_cap = $metau['meta_caption'];
$meta_key = $metau['meta_keywords'];
$meta_company = $metau['company'];
$meta_captionu = $meta_company . ' : ' . $titre_new . ' - ' . $meta_cap;
$meta_keywordsu = $titre_new . ' ' . $meta_key;
$qid = $bdd->query("SELECT * FROM " . $GLOBALS['db_table']['products'] . " WHERE id = $id_product");
$prod = $qid->fetch();
$qid = $bdd->prepare("INSERT INTO " . $GLOBALS['db_table']['products'] . " (reference, name, short_desc, titre, status, long_desc, date_insere, date_edit, price, weight, tva, cle_tva, meta_caption, meta_keywords)
VALUES (:reference, :name, :short_desc, :titre, :status, :long_desc, :date_insere, :date_edit, :price, :weight, :tva, :cle_tva, :meta_caption, :meta_keywords)");
$qid->execute(array(
'reference' => $prod['reference'],
'name' => $prod['name'],
'short_desc' => $prod['short_desc'],
'titre' => $titre_new,
'status' => '1',
'long_desc' => $prod['long_desc'],
'date_insere' => date('Y-m-d'),
'date_edit' => date('Y-m-d'),
'price' => $prod['price'],
'weight' => $prod['weight'],
'tva' => $prod['tva'],
'cle_tva' => $prod['cle_tva'],
'meta_caption' => $meta_captionu,
'meta_keywords' => $meta_keywordsu
));
$id_product_new = $bdd->lastInsertId();
///////////////////////////////////////////////////////
// SEO et STOCK
$qid = $bdd->prepare("UPDATE " . $GLOBALS['db_table']['products'] . " SET seo = :seo, hstock = :hstock, stock = :stock WHERE id = :id");
$qid->execute(array( 'seo' => text2url($id_product_new.'-'.$prod['name']),
'stock' => $prod['stock'],
'hstock' => $prod['hstock'],
'id' => $id_product_new));
///////////////////////////////////////////////////////
/*
$qidbb = $bdd->prepare("INSERT INTO " . $GLOBALS['db_table']['products_categories'] . " (id_category, id_product) VALUES (:id_category, :id_product)");
$qidbb->execute(array(
'id_category' => '1',
'id_product' => $id_product_new
));
*/
///// Cat
$qid = $bdd->prepare("SELECT * FROM " . $GLOBALS['db_table']['products_categories'] . " WHERE id_product = :id_product");
$qid->execute(array('id_product' => $prod['id']));
if($row = $qid->fetch()) {
$sql = $bdd->prepare("INSERT INTO " . $GLOBALS['db_table']['products_categories'] . " (id_product, id_category) VALUES (:id_product, :id_category)");
do {
$sql->execute(array(
'id_product' => $id_product_new,
'id_category' => $row['id_category']
));
} while($row = $qid->fetch());
} else {
}
/////////////////////////////////////////////////////
///// Pictures
$qid = $bdd->prepare("SELECT * FROM " . $GLOBALS['db_table']['products_pictures'] . " WHERE id_product = :id_product");
$qid->execute(array('id_product' => $prod['id']));
if($row = $qid->fetch()) {
$sql = $bdd->prepare("INSERT INTO " . $GLOBALS['db_table']['products_pictures'] . " (id_product, picture, position) VALUES (:id_product, :picture, :position)");
do {
$sql->execute(array(
'id_product' => $id_product_new,
'picture' => $row['picture'],
'position' => $row['position']
));
} while($row = $qid->fetch());
} else {
}
echo'Enregistrement OK !';
////////////////////////////////////////////////////
}
}
////////////////////////////////////////////////////
?>
<div class="container">
<form class="form-horizontal" method="POST" action="">
<div class="row">
<div class="span12">
<div class="page-header">
<h1>Clônes art. : <?php echo$id_product ?></h1>
<div class="pull-right">
<button type="submit" name="edit" class="btn btn-success"><i class="icon-ok"></i> Enregistrer</button>
</div>
<?php
echo '<input name="form" type="hidden" value="1">';
echo '<div class="control-group">';
echo '<label class="control-label" for="name">Num. article :</label>';
echo '<div class="controls">';
echo '<input required style="width:287px" name="num" type="text" value="">';
echo '</div>';
echo '</div>';
echo '<div class="control-group">';
echo '<label class="control-label" for="name">Titre GG :</label>';
echo '<div class="controls">';
echo '<input required style="width:287px" name="titre" type="text" value="">';
echo '</div>';
echo '</div>';
?>
</div>
</div>
</div>
</form>
</div>
<?php
include_once('includes/footer.php');
?>