164 lines
4.5 KiB
PHP
164 lines
4.5 KiB
PHP
<?php
|
|
|
|
require_once(dirname(dirname(__FILE__)).'/config/config.inc.php');
|
|
|
|
if (isset($_GET['secure_key']))
|
|
{
|
|
$secureKey = md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME'));
|
|
if (!empty($secureKey) AND $secureKey === $_GET['secure_key'])
|
|
{
|
|
|
|
|
|
$conn = mysql_connect('localhost', 'garanciab_prod', 'yoeLB4Znn1E1');
|
|
mysql_select_db('garanciab_prod');
|
|
|
|
|
|
$sql = "SELECT p.*,pl.name
|
|
FROM ps_product p
|
|
LEFT JOIN ps_product_lang pl ON p.id_product = pl.id_product
|
|
where id_lang = 1 AND name NOT LIKE '%carte%cadeau%';";
|
|
|
|
$res = mysql_query($sql, $conn);
|
|
|
|
$results = array();
|
|
$i=0;
|
|
while($row = mysql_fetch_array($res)){
|
|
$results[]=$row;
|
|
$i++;
|
|
}
|
|
echo '
|
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />';
|
|
echo "<fieldset class='debug'>";
|
|
echo "SQL : ".$sql. "<br/>";
|
|
echo $i.' produits trouvés';
|
|
echo "</fieldset>";
|
|
$txt = '<?xml version="1.0" encoding="UTF-8"?>
|
|
<PRODUITS>';
|
|
|
|
|
|
/*
|
|
CODACTI Code de l'activité
|
|
LIBACTI Nom de l'activité
|
|
CODARTI Référence article
|
|
DS1ARTI Désignation de l'article
|
|
DS2ARTI Complément désignation
|
|
POIDUVC Poids brut de l'UVC
|
|
LONGUVC Longueur de l'UVC
|
|
LARGUVC Largeur de l'UVC
|
|
HAUTUVC Hauteur de l'UVC
|
|
CODFOUR Code fournisseur
|
|
CODMARQ Code marque
|
|
CANARTI Code analyse de l'article
|
|
*/
|
|
|
|
$i=0;
|
|
foreach($results as $row)
|
|
{
|
|
$name=$row['name'];
|
|
$name=str_replace('&','&',$name);
|
|
$CODARTI=strtoupper($row['reference']);
|
|
$DS1ARTI=str_pad(utf8_encode($name), 35, " ", STR_PAD_RIGHT);
|
|
$DS2ARTI=' ';
|
|
$POIDUVC=(int)strtoupper($row['weight']);
|
|
$LONGUVC=(int)strtoupper($row['width']);
|
|
$LARGUVC=(int)strtoupper($row['height']);
|
|
$HAUTUVC=(int)strtoupper($row['depth']);
|
|
$CODFOUR=strtoupper($row['supplier_reference']);
|
|
$CODMARQ=isset($row['manufacturer_reference']) ? strtoupper($row['manufacturer_reference']) : '';
|
|
$EAN=strtoupper($row['ean13']);
|
|
$CANARTI="E"; //E = Article "normal"
|
|
|
|
/*
|
|
Permet de distinguer les produits et les échantillons
|
|
C = Article comptable
|
|
*/
|
|
if($row['id_category_default']==12)
|
|
$CANARTI="C";
|
|
|
|
/*
|
|
$nom=strtoupper(utf8_encode(($rowAdress['firstname'])));
|
|
$address1=str_pad(utf8_encode($rowAdress['address1']), 35, " ", STR_PAD_RIGHT);
|
|
$address2=str_pad(utf8_encode($rowAdress['address2']), 35, " ", STR_PAD_RIGHT);
|
|
if($rowAdress['phone']!=""){
|
|
$telephone=strtoupper($rowAdress['telephone']);
|
|
}else{
|
|
$telephone=strtoupper(utf8_encode($rowAdress['phone_mobile']));
|
|
}
|
|
$instructions=str_pad(nl2br(utf8_encode($rowAdress['other'])), 35, " ", STR_PAD_RIGHT);
|
|
$instructions=str_replace('\n',' ',$instructions);
|
|
$instructions=str_replace('\r',' ',$instructions);
|
|
*/
|
|
|
|
$txt.='
|
|
<PRODUIT>
|
|
<CODACTI>GAR</CODACTI>
|
|
<LIBACTI>Garancia-GAR</LIBACTI>
|
|
<CODARTI>'.$CODARTI.'</CODARTI>
|
|
<DS1ARTI>'.$DS1ARTI.'</DS1ARTI>
|
|
<DS2ARTI>'.$DS2ARTI.'</DS2ARTI>
|
|
<POIDUVC>'.$POIDUVC.'</POIDUVC>
|
|
<LONGUVC>'.$LONGUVC.'</LONGUVC>
|
|
<LARGUVC>'.$LARGUVC.'</LARGUVC>
|
|
<HAUTUVC>'.$HAUTUVC.'</HAUTUVC>
|
|
<CODFOUR>'.$CODFOUR.'</CODFOUR>
|
|
<CODMARQ>'.$CODMARQ.'</CODMARQ>
|
|
<CANARTI>'.$CANARTI.'</CANARTI>
|
|
';
|
|
|
|
$txt.="
|
|
<DESCAB>
|
|
<CABARTI>".$EAN."</CABARTI>
|
|
<TYPECAB></TYPECAB>
|
|
</DESCAB>
|
|
</PRODUIT>";
|
|
}
|
|
mysql_close($conn);
|
|
$txt.="
|
|
</PRODUITS>
|
|
";
|
|
|
|
if($txt!='')
|
|
{
|
|
|
|
$file = "REFART".date('YmdHis').".xml";
|
|
$ar = fopen('archives/'.$file,'w') or die("Probleme de création");
|
|
fputs($ar,$txt);
|
|
fclose($ar);
|
|
echo "<br/><a href='archives/".$file."' target='_blank'>Voir le XML local</a>";
|
|
|
|
$fileFTP = "REFART".date('YmdHis').".xml";
|
|
echo $fileFTP."<br/><br/>";
|
|
|
|
$serv_ftp = "ftp.l4-logistics.fr";
|
|
|
|
if($id_con = ftp_connect($serv_ftp))
|
|
echo "<br/><br/>ftp_connect OK<br/>";
|
|
else
|
|
echo "<br/><br/>ftp_connect NOK<br/>";
|
|
|
|
|
|
/*// DEV*/
|
|
// $ftp_user = "Gar_test";
|
|
// $ftp_pw = "Rsk33As*!";
|
|
/* PROD */
|
|
$ftp_user = "Gar_log";
|
|
$ftp_pw = "ZAnP49*!";
|
|
|
|
$ftp_dossier_local = 'archives/';
|
|
$ftp_dossier_distant = "/IN/";
|
|
|
|
if($result_login = ftp_login($id_con, $ftp_user, $ftp_pw))
|
|
echo "<br/>ftp_login OK<br/>";
|
|
else
|
|
echo "<br/>ftp_login NOK<br/>";
|
|
|
|
if(ftp_put($id_con, $ftp_dossier_distant.$fileFTP, $ftp_dossier_local.$file, FTP_BINARY))
|
|
echo "<br/><br/>Le fichier ".$file." a bien été ajouté dans le dossier /IN sur le FTP de L4LOGISTICS";
|
|
else
|
|
echo "<br/><br/>Problème dans la copie du backup dans le ftp distant IN<br>";
|
|
|
|
ftp_close($id_con);
|
|
}
|
|
}
|
|
}
|