$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."' WHERE idart='$idart' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}else{
//echo "cat: idart: $idart, idcat: $idcat";
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."' WHERE idcat='$idcat' AND idlang='".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
}
if($changetemplate==1&&$idtplcfg!=0){
/* update template conf */
$sql="UPDATE ".$cfg["tab"]["tpl_conf"]." SET idtpl='".Contenido_Security::toInteger($idtpl)."' WHERE idtplcfg='".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
// delete old configured containers
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg='".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
$changetemplate=0;
}else{
//
}
if($changetemplate!=1){
if(isset($idart)&&0!=$idart){
conGenerateCode($idcat,$idart,$lang,$client);
//backToMainArea($send);
}else{
conGenerateCodeForAllartsInCategory($idcat);
if($back=='true'){
backToMainArea($send);
}
}
}
}elseif($idtpl==0){
/* template deselected */
if(isset($idtplcfg)&&$idtplcfg!=0){
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($idtplcfg)."'";
$db->query($sql);
}
$idtplcfg=0;
if(!isset($changetemplate)){
$changetemplate=0;
}
if($idcat!=0&&$changetemplate==1&&!$idart){
/* Category */
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f("idtplcfg");
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="UPDATE ".$cfg["tab"]["cat_lang"]." SET idtplcfg = 0 WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f("idtplcfg");
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="UPDATE ".$cfg["tab"]["art_lang"]." SET idtplcfg = 0 WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
conGenerateCodeForAllartsInCategory($idcat);
//backToMainArea($send);
}
}else{
if($changetemplate==1){
if(!$idart){
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat = '".Contenido_Security::toInteger($idcat)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f("idtplcfg");
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
}else{
$sql="SELECT idtplcfg FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '".Contenido_Security::toInteger($idart)."' AND idlang = '".Contenido_Security::toInteger($lang)."'";
$db->query($sql);
$db->next_record();
$tmp_idtplcfg=$db->f("idtplcfg");
$sql="DELETE FROM ".$cfg["tab"]["tpl_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";
$db->query($sql);
$sql="DELETE FROM ".$cfg["tab"]["container_conf"]." WHERE idtplcfg = '".Contenido_Security::toInteger($tmp_idtplcfg)."'";