///////////////////////////////////////////////////////////
///////////////variables globales
if ($_POST[id_prod]) { $id_prod = $_POST[id_prod]; } elseif ($_GET[id_prod]) { $id_prod = $_GET[id_prod]; }
if ($_POST['cliente']) { $cliente = $_POST['cliente']; } elseif ($_GET['cliente']) { $cliente = $_GET['cliente']; }
if ($_POST[n3]) { $n3 = $_POST[n3]; } elseif ($_GET[n3]) { $n3 = $_GET[n3]; }
if ($_POST[pag]) { $pag = $_POST[pag]; } elseif ($_GET[pag]) { $pag = $_GET[pag]; }/*
if ($_POST[campo]) { $campo = $_POST[campo]; } elseif ($_GET[campo]) { $campo = $_GET[campo]; }
if ($_POST[donde]) { $donde = $_POST[donde]; } elseif ($_GET[donde]) { $donde = $_GET[donde]; }
*/
//////////////////////////////////
//////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
////////////////post
$nombre_prod = $_POST[nombre_prod];
$descrip = $_POST[descrip];
$direccion = $_POST[direccion];
$int = $_POST[int];
$dormitorios = $_POST[dormitorios];
$precio = $_POST[precio];
$moneda = $_POST[moneda];
$destacado = $_POST[destacado];
$oculto = $_POST[oculto];
$chk_cat = $_POST[chk_cat];
$foto_prin = $_POST[foto_prin];
$vid_prin = $_POST[vid_prin];
$video = $_POST[video];/*
*/
///////////////////
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
////////////////get
$delvid = $_GET[delvid];
$delfot = $_GET[delfot];/*
$keyyy = $_GET[keyyy];
*/
///////////////////
/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
//////////////Archivos
$file = $_FILES["file"];
// print_r($file);
/*
$fondo = $_FILES["fondo"];
*/
/////////////////////
////////////////////////////////////////////////////////
if(!$f) {
$a = $_SERVER['PHP_SELF'];
$ar = split('/',$a);
$i = count($ar);
$i=$i-1;
$f='';
for($x=1; $x<$i; $x++){
$f.= "../";
}
}
require_once ($f."contabilidad/permiso.php");
require ($f."contabilidad/cook.php");
$stp=1;
require ($f."contabilidad/conex/webcatalog.php");
require_once ($f."contabilidad/usuarios/classes/Empresas.php");
$Empresas=new Empresas();
if (!$id_prod && $nombre_prod) {
/* ASIGNAMOS UNA CONTRASEÑA AL AZAR */
$id2 = $id2 . chr(mt_rand(97, 122));
$id2 = $id2 . chr(mt_rand(97, 122));
$id2 = $id2 . chr(mt_rand(97, 122));
$id2 = $id2 . chr(mt_rand(97, 122));
$id2 = $id2 . chr(mt_rand(97, 122));
$id2 = $id2 . chr(mt_rand(97, 122));
$xxsql = "insert into productos (nombre, keyy, id_cliente, empresa, ingresadopor, ingresado) values ('".$nombre_prod."', '".$id2."', '".$cliente."', '".$_COOKIE['EMPRXX22']."', '".$rowx2x9_ID_USER."', '".date("Y-m-d H:i:s")."')";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
$id_prod = mysql_insert_id();
}
if ($delfot && $id_prod) {
$result = mysql_query("select * from producto_foto where id_foto = '".$delfot."' and id_producto='".$id_prod."'");
if ($row = mysql_fetch_array($result)) {
if ($row["principal"]=='1') {
$result1 = mysql_query("select * from producto_foto where id_producto='".$id_prod."' and principal != '1'");
if ($row1 = mysql_fetch_array($result1)) {
$sql="update producto_foto set principal = '1' where id_producto = '".$id_prod."' and id_foto = '".$row1["id_foto"]."'";
mysql_query($sql) or die (mysql_error() . " " .$sql);
$delok=1;
}
} else {
$delok=1;
}
//echo 'aca';
if ($delok==1) {
$id_ftp=ftp_connect('sentidos.cl');
ftp_login($id_ftp, 'fotocatalog@sentidos.cl', 'vinculo3');
$pasivo_destino = false;
ftp_pasv($id_ftp,$pasivo_destino);
if($row["fotoa"] != '') {
ftp_delete ( $id_ftp , '/'. $row["fotoa"] );
}
$fotoweb = "/home/csentid/public_html/contabilidad/web1/fotos/".$row["fotoa"];
unlink($fotoweb);
if($row["fotob"] != '') {
ftp_delete ( $id_ftp , '/'. $row["fotob"] );
}
$fotoweb = "/home/csentid/public_html/contabilidad/web1/fotos/".$row["fotob"];
unlink($fotoweb);
if($row["fotoc"] != '') {
ftp_delete ( $id_ftp , '/'. $row["fotoc"] );
}
$fotoweb = "/home/csentid/public_html/contabilidad/web1/fotos/".$row["fotoc"];
unlink($fotoweb);
if($row["fotod"] != '') {
ftp_delete ( $id_ftp , '/'. $row["fotod"] );
}
$fotoweb = "/home/csentid/public_html/contabilidad/web1/fotos/".$row["fotod"];
unlink($fotoweb);
mysql_query("delete from producto_foto where id_foto = '".$delfot."'");
ftp_close($id_ftp);
}
}
}
if ($delvid && $id_prod) {
$result = mysql_query("select * from producto_youtube where id_video = '".$delvid."' and id_producto='".$id_prod."'");
if ($row = mysql_fetch_array($result)) {
if ($row["principal"]=='1') {
$result1 = mysql_query("select * from producto_youtube where id_producto='".$id_prod."' and principal != '1'");
if ($row1 = mysql_fetch_array($result1)) {
$sql="update producto_youtube set principal = '1' where id_producto = '".$id_prod."' and id_video = '".$row1["id_video"]."'";
mysql_query($sql) or die (mysql_error() . " " .$sql);
}
$delok=1;
} else {
$delok=1;
}
if ($delok==1) {
mysql_query("delete from producto_youtube where id_video = '".$delvid."'");
}
}
}
if ($nombre_prod && $id_prod ) {
$precio=preg_replace("/[^0-9]/i","",$precio);
$dormitorios=preg_replace("/[^0-9]/i","",$dormitorios);
$nombre_prod=str_replace("'","",$nombre_prod);
$descrip=str_replace("'","",$descrip);
$int=str_replace("'","",$int);
$direccion=str_replace("'","",$direccion);
$valoruf="";
$valorpeso="";
$existe = mysql_query("SELECT * FROM monedas WHERE id = '2'") or die ("Error al leer monedas");
$obj = mysql_fetch_object($existe);
if ($moneda == "1") {
$valoruf=$precio / $obj->valor_pesos;
$valorpeso=$precio;
}else{
$valoruf=$precio;
$valorpeso=$precio * $obj->valor_pesos;
}
if ($oculto != '1') {
$xxsql = "update productos set nombre = '".$nombre_prod."', descripcion = '".$descrip."', desc_inter = '".$int."', Direccion = '".$direccion."', valor = '".$precio."', moneda= '".$moneda."', destacado = '".$destacado."', Dormitorios = '".$dormitorios."', Valorpeso = '".$valorpeso."', Valoruf = '".$valoruf."', oculto = '".$oculto."', publicado = '".date("Y-m-d H:i:s")."' where id = '".$id_prod."'";
} else {
$xxsql = "update productos set nombre = '".$nombre_prod."', descripcion = '".$descrip."', desc_inter = '".$int."', Direccion = '".$direccion."', valor = '".$precio."', moneda= '".$moneda."', destacado = '".$destacado."', Dormitorios = '".$dormitorios."', Valorpeso = '".$valorpeso."', Valoruf = '".$valoruf."', oculto = '".$oculto."' where id = '".$id_prod."'";
}
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
mysql_query("Delete from producto_categoria where id_producto = '".$id_prod."'") or die("
Error44
\n");
for($i=0; $ivalor + 1;
$xxsql = "update correlativos_id set valor = '".$correlativo."' where id = '2'";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
// Obtenemos la información de la imagen
$im_info = getimagesize($_FILES["file"]["tmp_name"][$fr]);
// Evaluamos si es GIF(1) o JPEG(2)
// y creamos la imagen en GD
switch($im_info[2]) {
case 1:
$imagen = imagecreatefromgif($_FILES["file"]["tmp_name"][$fr]); break;
case 2:
$imagen = imagecreatefromjpeg($_FILES["file"]["tmp_name"][$fr]); break;
case 3:
$imagen = imagecreatefrompng($_FILES["file"]["tmp_name"][$fr]); break;
}
// Evaluamos si la imagen es horizontal ancho mayor que alto a escala 4/3
$valll=$im_info[0]/$im_info[1];
if($valll>(4/3)) {
// Definimos las medidas de las imagenes
$web_max = $im_info[0]; // ancho maximo de la foto A (Ficha prod foto grande)
$th_max = 267; // ancho maximo de la foto B (Listado de productos)
$det_max = 100; // ancho maximo de la foto C (Listado miniatura)
$detweb_max = 800; // ancho maximo de la imagen grande que se abre sola
if ($detweb_max > $im_info[0]) { $detweb_max = $im_info[0];}
$web_w = $web_max;
$web_h = ($im_info[1]/$im_info[0])*$web_max;
$th_w = $th_max;
$th_h = ($im_info[1]/$im_info[0])*$th_max;
$det_w = $det_max;
$det_h = ($im_info[1]/$im_info[0])*$det_max;
$detweb_w = $detweb_max;
$detweb_h = ($im_info[1]/$im_info[0])*$detweb_max;
} else {
$web_max = $im_info[1]; // alto maximo de la foto A (Ficha prod foto grande)
$th_max = 200; // alto maximo de la foto B (Listado de productos)
$det_max = 75; // alto maximo de la foto C (Listado miniatura)
$detweb_max = 600; // alto maximo de la imagen grande que se abre sola
if ($detweb_max > $im_info[1]) { $detweb_max = $im_info[1];}
$web_w = ($im_info[0]/$im_info[1])*$web_max;
$web_h = $web_max;
$th_w = ($im_info[0]/$im_info[1])*$th_max;
$th_h = $th_max;
$det_w = ($im_info[0]/$im_info[1])*$det_max;
$det_h = $det_max;
$detweb_w = ($im_info[0]/$im_info[1])*$detweb_max;
$detweb_h = $detweb_max;
}
// Creamos las imágenes
$webimage = imagecreatetruecolor($web_w,$web_h);
$thumb = imagecreatetruecolor($th_w,$th_h);
$detalle = imagecreatetruecolor($det_w,$det_h);
$detwebgrande = imagecreatetruecolor($detweb_w,$detweb_h);
// Copiamos la original escalada
imagecopyresampled($webimage,$imagen,0,0,0,0, $web_w,$web_h,imagesx($imagen),imagesy($imagen));
imagecopyresampled($thumb,$imagen,0,0,0,0, $th_w,$th_h,imagesx($imagen),imagesy($imagen));
imagecopyresampled($detalle,$imagen,0,0,0,0, $det_w,$det_h,imagesx($imagen),imagesy($imagen));
imagecopyresampled($detwebgrande,$imagen,0,0,0,0, $detweb_w,$detweb_h,imagesx($imagen),imagesy($imagen));
// Destruimos la imagen original
imagedestroy($imagen);
// Damos salida a nuestros archivos
$ac = $_FILES["file"]["name"][$fr];
$extension = explode(".",$ac);
$num = count($extension)-1;
$extension[$num] = strtolower($extension[$num]);
$fotoweb_name=$id_prod.'-A-'.$correlativo.'.'.$extension[$num];
$fotothumb_name=$id_prod.'-B-'.$correlativo.'.'.$extension[$num];
$fotodetalle_name=$id_prod.'-C-'.$correlativo.'.'.$extension[$num];
$fotodetwebgrande_name=$id_prod.'-D-'.$correlativo.'.'.$extension[$num];
$fotoweb = "/home/csentid/public_html/contabilidad/web1/fotos/".$fotoweb_name;
$foto = "/home/csentid/public_html/contabilidad/web1/fotos/".$fotothumb_name;
$foto_grande = "/home/csentid/public_html/contabilidad/web1/fotos/".$fotodetalle_name;
$fotowebgrande = "/home/csentid/public_html/contabilidad/web1/fotos/".$fotodetwebgrande_name;
//////////////////////////////////
//agregamos texto a fotos
unset ($busca);
$busca["B_id"]='csentid';
$busca["id"]=$_COOKIE['EMPRXX22'];
if ($row_emp=$Empresas->getEmpresa($f,$busca)) {
$texto = $row_emp["empresa"];
}
require ($f."contabilidad/conex/webcatalog.php");
$long = strlen($texto)*imagefontwidth(5);
$ancho = imagesx($detwebgrande);
$alto = imagesy($detwebgrande);
$blanco = imagecolorallocate($detwebgrande,255,255,255);
imagestring($detwebgrande, 5, $ancho-$long-25, $alto-35,$texto,$blanco);
$long = strlen($texto)*imagefontwidth(5);
$ancho = imagesx($webimage);
$alto = imagesy($webimage);
$blanco = imagecolorallocate($webimage,255,255,255);
imagestring($webimage, 5, $ancho-$long-25, $alto-35,$texto,$blanco);
imagejpeg($webimage,$fotoweb,90);
imagejpeg($thumb,$foto,90);
imagejpeg($detalle,$foto_grande,90);
imagejpeg($detwebgrande,$fotowebgrande,90);
/////////////////////////
//////////////////////////////////////
// Destruimos las imagenes temporales
imagedestroy($webimage);
imagedestroy($thumb);
imagedestroy($detalle);
imagedestroy($detwebgrande);
$id_ftp=ftp_connect('sentidos.cl');
ftp_login($id_ftp, 'fotocatalog@sentidos.cl', 'vinculo3');
$pasivo_destino = false;
ftp_pasv($id_ftp,$pasivo_destino);
ftp_put($id_ftp, '/'.$fotoweb_name, $fotoweb, FTP_BINARY);
ftp_put($id_ftp, '/'.$fotothumb_name, $foto, FTP_BINARY);
ftp_put($id_ftp, '/'.$fotodetalle_name, $foto_grande, FTP_BINARY);
ftp_put($id_ftp, '/'.$fotodetwebgrande_name, $fotowebgrande, FTP_BINARY);
ftp_close($id_ftp);
$xxsql = "select * from producto_foto where id_producto = '".$id_prod."' and principal = '1'";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
if (mysql_num_rows($result)==0) {
$principal=1;
} else {
$principal='0';
}
$xxsql = "insert into producto_foto (id_foto, id_producto, fotoa, fotob, fotoc, fotod, principal) values ('".$correlativo."', '".$id_prod."', '".$fotoweb_name."', '".$fotothumb_name."', '".$fotodetalle_name."', '".$fotodetwebgrande_name."', '".$principal."')";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
}
}
if ($foto_prin) {
$sql="update producto_foto set principal = '0' where id_producto = '".$id_prod."'";
mysql_query($sql) or die (mysql_error() . " " .$sql);
$sql="update producto_foto set principal = '1' where id_producto = '".$id_prod."' and id_foto = '".$foto_prin."'";
mysql_query($sql) or die (mysql_error() . " " .$sql);
}
if ($video && $video != 'http://www.youtube.com/watch?v') {
$xxsql = "select * from producto_youtube where id_producto = '".$id_prod."' and principal = '1'";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
if (mysql_num_rows($result)==0) {
$principal=1;
} else {
$principal='0';
}
$xxsql = "insert into producto_youtube (id_producto, url_vide, principal) values ('".$id_prod."', '".$video."', '".$principal."')";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
}
}
if ($id_prod) {
$xxsql = "select * from productos where id = '".$id_prod."'";
$result=mysql_query($xxsql) or die(mysql_error().' consulta: '.$xxsql);
if ($row=mysql_fetch_array($result)) {
$nombre_prod=$row["nombre"];
$descrip=$row["descripcion"];
$int=$row["desc_inter"];
$direccion=$row["Direccion"];
$precio=$row["valor"];
$moneda=$row["moneda"];
$destacado=$row["destacado"];
$dormitorios=$row["Dormitorios"];
$oculto=$row["oculto"];
$cliente=$row["id_cliente"];
mysql_free_result($result);
$categorias = mysql_query("select id_categoria from producto_categoria where id_producto = '".$id_prod."'");
$i = 0;
while($cat = mysql_fetch_array($categorias)) {
$chk_cat[$i] = $cat["id_categoria"];
$i++;
}
}
}
?>
require ($f."contabilidad/menu.php"); ?> if ($stp==1) { ?>
} ?>
| include($f."contabilidad/img/footer.php"); ?> |