function pintarTabla($dir, $fotos, $server, $uid, $pwd) { $html = "<table class='table'><tr><th>Codigo</th><th>Nombre</th><th>Descripcion</th><th>Nombre_en</th><th>Descripcion_en</th><th>Precio</th><th>Precio Oferta</th><th>Precio Outlet</th><th>Outlet</th><th>Stock</th><th>Fotos</th><th><input type='checkbox' onClick='toggle(this)' /> Todos</th></tr>"; $i = 0; foreach ($fotos as $cod => $fotosArticulo) { $query = "SELECT DISTINCT T0.CODARTICULO AS CODIGO, T0.DESCRIPCION AS NOMBRE, T0.DESCRIPADIC AS DESCRIPCION, T2.CAMPO1 AS NOMBRE_ENGLISH, T2.CAMPO3 AS DESCRIPCION_ENGLISH, T4.PNETO AS PRECIO, T4.PNETO2 AS PRECIO_OFERTA, T5.PNETO2 AS PRECIO_OUTLET, T0.VISIBLEWEB AS OUTLET,isnull((select sum(T20.STOCK) from STOCKS T20 WHERE T0.CODARTICULO = T20.CODARTICULO and len(codalmacen)>=2 AND (CODALMACEN like 'A[0-9]' or CODALMACEN like 'A[0-9][0-9]') and cast(SUBSTRING(Codalmacen,2,len(codalmacen)-1) as int) between 3 and 50),0) AS STOCK FROM ARTICULOS T0 LEFT JOIN REFERENCIASPROV T1 ON T0.CODARTICULO = T1.CODARTICULO LEFT JOIN ARTICULOSLIN T3 ON T0.CODARTICULO=T3.CODARTICULO LEFT JOIN ARTICULOSCAMPOSLIBRES T2 ON T0.CODARTICULO=T2.CODARTICULO LEFT JOIN PRECIOSVENTA T4 ON T4.IDTARIFAV = 4 AND T4.CODARTICULO = T0.CODARTICULO LEFT JOIN PRECIOSVENTA T5 ON T5.IDTARIFAV = 8 AND T5.CODARTICULO = T0.CODARTICULO WHERE T3.CODBARRAS='{$cod}'"; $consulta = new ConexionManager(); $result = $consulta->getQuery($server, $uid, $pwd, $query); foreach ($result as $row) { $html .= "<tr><td>" . $row['CODIGO'] . "</td><td>" . $row['NOMBRE'] . "</td><td>" . $row['DESCRIPCION'] . "</td><td>" . $row['NOMBRE_ENGLISH'] . "</td><td>" . $row['DESCRIPCION_ENGLISH'] . "</td><td>" . $row['PRECIO'] . "</td><td>" . $row['PRECIO_OFERTA'] . "</td><td>" . $row['PRECIO_OUTLET'] . "</td><td>" . $row['OUTLET'] . "</td><td>" . $row['STOCK'] . "</td>"; $html .= "<td>"; foreach ($fotosArticulo as $foto) { $html .= "<img src='" . $dir . "resize.php?file=" . $foto . "&width=50' width='50px'/>"; } $html .= "</td>"; $html .= "<td><input type='checkbox' name='foo{$i}' value='{$cod}' class='subido'/></td></tr>"; } $i++; } $html .= "</table>"; return $html; }
$carpeta_inbox = "inbox" . "-" . $hoy['mday'] . "-" . $hoy['mon'] . "-" . $hoy['year'] . "-" . $numinbox; $enviado = true; foreach ($fotosParaSubir as $foto) { if ($enviado) { //Controlamos que se envíen correctamente todas las imágenes $enviado = $enviar->subirftp($conn, $ftpdir, $carpeta_inbox, $foto, $inbox . $foto); ob_flush(); } } ftp_close($conn); if ($enviado) { $enviar->enviarEmailExitoso($carpeta_inbox, count($fotosParaSubir)); ?> <p>Actualizando artículos en Manager</p> <?php $conexionManager = new ConexionManager(); $currentdate = date('Y-m-d'); foreach ($_GET as $item) { $codarticulo = substr($item, 0, -1); $query = "UPDATE ARTICULOSCAMPOSLIBRES SET FOTOGRAFIA='T',FECHA_FOTO='{$currentdate}' WHERE CODARTICULO={$codarticulo}"; $conexionManager->updateQuery($server, $uid, $pwd, $query); } ?> <p>Se han actualizado los artículos en Manager correctamente</p> <p>Moviendo Fotografías a NAS <?php foreach ($fotosParaSubir as $fichero) { $salida = exec('mover_foto.bat ' . $fichero); echo '<p>'; print_r($salida); echo '</p>';
<p>selecciona las cuartas fotos que desea publicar:</p> <form> <?php echo $rastreador->pintarTabla($outbox, $fotos, $server, $uid, $pwd); ?> <input type="submit" value="Subir Items" class="btn btn-danger"/> </form> <?php } else { ob_start(); $proxy = new SoapClient('http://www.elitestore.es/api/soap/?wsdl=1'); $user = "******"; $password = "******"; $sessionId = $proxy->login($user, $password); foreach ($_GET as $item) { $consulta = new ConexionManager(); $codarticulo = substr($item, 0, -1); $query = "select T0.REFPROVEEDOR,T1.FOTOGRAFIA_4 from referenciasprov T0 LEFT JOIN ARTICULOSCAMPOSLIBRES T1 ON T0.CODARTICULO=T1.CODARTICULO where T1.codarticulo={$codarticulo}"; $result = $consulta->getQuery($server, $uid, $pwd, $query); $productSku = $result[0]['REFPROVEEDOR']; if ($result[0]['FOTOGRAFIA_4'] != '') { $rutafoto = "http://www.elitestore.es" . $result[0]['FOTOGRAFIA_4']; echo "<p>Subiendo Cuarta foto del artículo {$productSku} ubicada en {$rutafoto}</p>"; ob_flush(); $file_headers = @get_headers($rutafoto); if ($file_headers[0] != 'HTTP/1.1 404 Not Found') { $newImage = array('file' => array('name' => 'file_name', 'content' => base64_encode(file_get_contents($rutafoto)), 'mime' => 'image/jpeg'), 'position' => 3, 'exclude' => 0); echo $productSku; $imageFilename = $proxy->call($sessionId, 'product_media.create', array((string) $productSku, $newImage, 'admin', 'sku')); $result = $proxy->call($sessionId, 'catalog_product.update', array($productSku, array('has_four_images' => 1), 'admin', 'sku')); echo "<p>Imagen subida correctamente: Sku: " . $productSku . "</br> Imagen:</br> <img src='" . $rutafoto . "' width='50px' />";