<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.9 www.exoops.info 2006/05
//v1.8 www.exoops.info 2006/03
// 
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Pascal Le Boustouller
// Author Website : http://www.perso-search.com/e-xoopsien/
// Licence Type   : GPL
// ------------------------------------------------------------------------- //
include("admin_header.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
#  function Index
#####################################################
function Index() {
    global $hlpfile, $db, $bcoosConfig, $xoopsModule, $monnaie, $moderated, $ynprice, $classm, $myts;
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/include/functions.php");
include_once(XOOPS_ROOT_PATH."/modules/MyAnnonces/class/arbre.php");
$mytree = new XoopsArbre($db->prefix("ann_categories"),"cid","pid");
	xoops_cp_header();
	
	    $result = $db->query("select lid, title, date from ".$db->prefix("ann_annonces")." WHERE valid='No' order by lid");
    $numrows = $db->getRowsNum($result);
    if ($numrows>0) {
		OpenTable();
	echo "<B>"._CLA_WAIT."</B><br><br>";
	echo _CLA_THEREIS." <b>$numrows</b> "._CLA_WAIT."<br><br>";
	
	echo "<TABLE WIDTH=100% CELLPADDING=2 CELLSPACING=0 BORDER=0>";
	$rank = 1;
	while(list($lid, $title, $date) = $db->fetchRow($result)) {
	$title = $myts->makeTboxData4Edit($title);
	$date2 = formatTimestamp($date,"s");
	if(is_integer($rank/2)) $color="bg3";
	else $color="bg4";
	
	   echo "<TR class='$color'><TD><A HREF=\"index.php?op=IndexView&lid=$lid\">$title</A></TD><TD align=right> $date2</TD></TR>";
$rank++;
	}
	
	echo "</TABLE>";
	
		CloseTable();
	echo "<br />";
    } else {
	OpenTable();
	echo _CLA_NOANNVAL;
	CloseTable();
	echo "<br />";
    }
	
// Modify Annonces
	
	list($numrows) = $db->fetchRow($db->query("SELECT COUNT(*) FROM ".$db->prefix("ann_annonces").""));
    if ($numrows>0) {
    OpenTable();
    echo "<form method=\"post\" action=\"index.php\">"
	."<b>"._CLA_MODANN."</b><br><br>"
	.""._CLA_NUMANN." <input type=\"text\" class=\"text\" name=\"lid\" size=\"12\" maxlength=\"11\">&nbsp;&nbsp;"
	."<input type=\"hidden\" name=\"op\" value=\"AnnoncesModAnnonce\">"
	."<input type=\"submit\" class=\"button\" value=\""._CLA_MODIF."\">"
	."<br><br>"._CLA_ALLMODANN.""
	."</form><center><A HREF=\"../index.php\">"._CLA_ACCESMYANN."</A></center>";
    CloseTable();
    echo "<br>";
    }
    OpenTable();
	echo "<A HREF=\"map.php\">"._CLA_GESTCAT."</A>";
	CloseTable();
	echo "<br />";
   
// Add Type
    OpenTable();
    echo "<form method=\"post\" action=\"index.php\">
		<b>"._CLA_ADDTYPE."</b><br><br>
		"._CLA_TYPE."	<input type=\"text\" class=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">	
				<input type=\"hidden\" name=\"op\" value=\"AnnoncesAddType\">
				<input type=\"submit\" class=\"button\" value=\""._CLA_ADD."\">
		</form>";
    echo "<br>";
	
	
// Modify Type
	list($numrows) = $db->fetchRow($db->query("SELECT COUNT(*) FROM ".$db->prefix("ann_type").""));
    if ($numrows>0) {	
	echo "<form method=\"post\" action=\"index.php\">
	 <b>"._CLA_MODTYPE."</b></font><br><br>";
	$result = $db->query("select id_type, nom_type from ".$db->prefix("ann_type")." order by nom_type");
	echo ""._CLA_TYPE." <select name=\"id_type\" class=\"select\">";	
	while(list($id_type, $nom_type) = $db->fetchRow($result)) {
	
	$nom_type = $myts->makeTboxData4Edit($nom_type);
	
	    echo "<option value=\"$id_type\">$nom_type</option>";
	  	}
	echo "</select>
	    <input type=\"hidden\" name=\"op\" value=\"AnnoncesModType\"> 
		<input type=\"submit\" value=\""._CLA_MODIF."\" class=\"button\">
	    </form>";
	CloseTable();
	echo "<br>";
    }
// Add Prix
    OpenTable();
    echo "<form method=\"post\" action=\"index.php\">
		<b>"._CLA_ADDPRIX."</b><br><br>
		"._CLA_TYPE."	<input type=\"text\" class=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">	
				<input type=\"hidden\" name=\"op\" value=\"AnnoncesAddPrix\">
				<input type=\"submit\" value=\""._CLA_ADD."\" class=\"button\">
		</form>";
    echo "<br>";
	
	
// Modify Prix
	list($numrows) = $db->fetchRow($db->query("SELECT COUNT(*) FROM ".$db->prefix("ann_prix").""));
    if ($numrows>0) {	
	echo "<form method=\"post\" action=\"index.php\">
	 <b>"._CLA_MODPRIX."</b></font><br><br>";
	$result = $db->query("select id_prix, nom_prix from ".$db->prefix("ann_prix")." order by nom_prix");
	echo "Type : <select name=\"id_prix\" class=\"select\">";	
	while(list($id_prix, $nom_prix) = $db->fetchRow($result)) {
	
	$nom_prix = $myts->makeTboxData4Edit($nom_prix);
	
	    echo "<option value=\"$id_prix\">$nom_prix</option>";
	  	}
	echo "</select>
	    <input type=\"hidden\" name=\"op\" value=\"AnnoncesModPrix\"> 
		<input type=\"submit\" value=\""._CLA_MODIF."\" class=\"button\">
	    </form>";
	CloseTable();
	echo "<br>";
    }
	
xoops_cp_footer();
	}
	
	
#  function IndexView
#####################################################
function IndexView($lid) {
    global $db, $bcoosConfig, $xoopsModule, $myts, $ynprice, $monnaie;
	
include_once(XOOPS_ROOT_PATH."/modules/MyAnnonces/class/arbre.php");
$mytree = new XoopsArbre($db->prefix("ann_categories"),"cid","pid");
	
	xoops_cp_header();
	
    $result = $db->query("select lid, cid, title, type, description, tel, price, typeprix, date, email, submitter, town, country, photo from ".$db->prefix("ann_annonces")." WHERE valid='No' AND lid='$lid'");
    $numrows = $db->getRowsNum($result);
    if ($numrows>0) {
	OpenTable();
	echo "<B>"._CLA_WAIT."</B><br><br>";
	list($lid, $cid, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $photo) = $db->fetchRow($result);
	$date2 = formatTimestamp($date,"s");
	
	$title = $myts->makeTboxData4Edit($title);
	$type = $myts->makeTboxData4Edit($type);
	$description = $myts->makeTboxData4Edit($description);
	$tel = $myts->makeTboxData4Edit($tel);
	$price = $myts->makeTboxData4Edit($price);
	$typeprix = $myts->makeTboxData4Edit($typeprix);
	$submitter = $myts->makeTboxData4Edit($submitter);	
	$town = $myts->makeTboxData4Edit($town);
	$country = $myts->makeTboxData4Edit($country);
	
	    echo "<form action=\"index.php\" method=\"post\">
		<TABLE><TR>
		<TD>"._CLA_NUMANN." </TD><TD>$lid "._CLA_DU." $date2</TD>
		</TR><TR>
		<TD>"._CLA_SENDBY." </TD><TD>$submitter</TD>
		</TR><TR>
		<TD>"._CLA_EMAIL." </TD><TD><input type=\"text\" class=\"text\" name=\"email\" size=\"50\" value=\"$email\"></TD>
		</TR><TR>
		<TD>"._CLA_TEL." </TD><TD><input type=\"text\" class=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></TD>
		</TR><TR>
		<TD>"._CLA_TOWN." </TD><TD><input type=\"text\" class=\"text\" name=\"town\" size=\"50\" value=\"$town\"></TD>
		</TR><TR>
		<TD>"._CLA_COUNTRY." </TD><TD><input type=\"text\" class=\"text\" name=\"country\" size=\"50\" value=\"$country\"></TD>
		</TR><TR>
		<TD>"._CLA_TITLE2." </TD><TD><input type=\"text\" class=\"text\" name=\"title\" size=\"50\" value=\"$title\"></TD>
		</TR><TR>
		<TD>"._CLA_TYPE." </TD><TD><select name=\"type\" class=\"select\">";
		
		$result5=$db->query("select nom_type from ".$db->prefix("ann_type")." order by nom_type");
		while(list($nom_type) = $db->fetchRow($result5)) {
    	    	    $sel = "";
		    if ($nom_type == $type) {
			$sel = "selected";
		    }
		    echo "<option value=\"$nom_type\" $sel>$nom_type</option>";
		}
		
		echo "</select></TD>
		</TR><TR>
		<TD>"._CLA_PHOTO2." </TD><TD><input type=\"text\" class=\"text\" name=\"photo\" size=\"50\" value=\"$photo\"></TD>
		</TR><TR>
		<TD>"._CLA_ANNONCE." </TD><TD><textarea name=\"description\" class=\"textarea\" cols=\"60\" rows=\"10\">$description</textarea></TD>
		</TR><TR>";
		
		if ($ynprice == 1) {
		echo "<TD>"._CLA_PRICE2." </TD><TD><input type=\"text\" class=\"text\" name=\"price\" size=\"10\" value=\"$price\"> $monnaie";
	$result3 = $db->query("select nom_prix from ".$db->prefix("ann_prix")." order by id_prix");
	echo " <select name=\"typeprix\" class=\"select\"><option value=\"$typeprix\">$typeprix</option>";
	while(list($nom_prix) = $db->fetchRow($result3)) {
	echo "<option value=\"$nom_prix\">$nom_prix</option>";
	    }
	echo "</select></TD>";
		}
		
		echo "</TR><TR>
		<TD>"._CATEGORY." </TD><TD>";
	    $mytree->makeMySelBox("title", "title", $cid);
		echo "</TD>
		</TR><TR>
		<TD>&nbsp;</TD><TD><SELECT NAME=\"op\" class=\"select\">
		<OPTION VALUE=\"AnnoncesValid\"> "._CLA_OK."
		<OPTION VALUE=\"AnnoncesDel\"> "._DELETE."
		</SELECT><input type=\"submit\" value=\""._CLA_GO."\" class=\"button\"></TD>
		</TR></TABLE>";
		echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
	    echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
	    echo "<input type=\"hidden\" name=\"date\" value=\"$date\">";
	    echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
		</form>";
		
		if ($photo) {
		echo "<BR /><BR /><CENTER><IMG SRC=\"".XOOPS_URL."/modules/MyAnnonces/images_ann/$photo\" BORDER=0></CENTER>";
		}
	CloseTable();
	echo "<br />";
    } 
	
xoops_cp_footer();
}
	
	
	
	
	
	
	
	
	
	
#  function AnnoncesModAnnonce
#####################################################
function AnnoncesModAnnonce($lid) {
    global $db, $xoopsModule, $bcoosConfig, $ynprice, $monnaie, $myts;
	
include_once(XOOPS_ROOT_PATH."/modules/MyAnnonces/class/arbre.php");
$mytree = new XoopsArbre($db->prefix("ann_categories"),"cid","pid");
	
	xoops_cp_header();
    $result = $db->query("select lid, cid, title, type, description, tel, price, typeprix, date, email, submitter, town, country, valid, photo from ".$db->prefix("ann_annonces")." where lid=$lid");
    OpenTable();
    echo "<b>"._CLA_MODANN."</b><br><br>";
	
    while(list($lid, $cid, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo) = $db->fetchRow($result)) {
	
	$title = $myts->makeTboxData4Edit($title);
	$type = $myts->makeTboxData4Edit($type);
	$description = $myts->makeTboxData4Edit($description);
	$tel = $myts->makeTboxData4Edit($tel);
	$price = $myts->makeTboxData4Edit($price);
	$typeprix = $myts->makeTboxData4Edit($typeprix);
	$submitter = $myts->makeTboxData4Edit($submitter);	
	$town = $myts->makeTboxData4Edit($town);
	$country = $myts->makeTboxData4Edit($country);
		
	$date2 = formatTimestamp($date,"s");
		
    	echo "<form action=\"index.php\" method=post>
	    <TABLE border=0><TR>
		<TD>"._CLA_NUMANN." </TD><TD>$lid du $date2</TD>
		</TR><TR>
		<TD>"._CLA_SENDBY." </TD><TD>$submitter</TD>
		</TR><TR>
		<TD>"._CLA_EMAIL." </TD><TD><input type=\"text\" class=\"text\" name=\"email\" size=\"50\" value=\"$email\"></TD>
		</TR><TR>
		<TD>"._CLA_TEL." </TD><TD><input type=\"text\" class=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></TD>
		</TR><TR>
		<TD>"._CLA_TOWN." </TD><TD><input type=\"text\" class=\"text\" name=\"town\" size=\"50\" value=\"$town\"></TD>
		</TR><TR>
		<TD>"._CLA_COUNTRY." </TD><TD><input type=\"text\" class=\"text\" name=\"country\" size=\"50\" value=\"$country\"></TD>
		</TR><TR>
		<TD>"._CLA_TITLE2." </TD><TD><input type=\"text\" class=\"text\" name=\"title\" size=\"50\" value=\"$title\"></TD>
		</TR><TR>
				<TD>"._CLA_TYPE." </TD><TD><select name=\"type\" class=\"select\">";
		
		$result5=$db->query("select nom_type from ".$db->prefix("ann_type")." order by nom_type");
		while(list($nom_type) = $db->fetchRow($result5)) {
    	    	    $sel = "";
		    if ($nom_type == $type) {
			$sel = "selected";
		    }
		    echo "<option value=\"$nom_type\" $sel>$nom_type</option>";
		}
		echo "</select></TD>
		</TR><TR>
		<TD>"._CLA_CAT2." </TD><TD>";
		$mytree->makeMySelBox("title", "title", $cid);
		echo "</TD>
		</TR><TR>
		<TD>"._CLA_ANNONCE." </TD><TD><textarea name=\"description\" class=\"textarea\" cols=\"60\" rows=\"10\">$description</textarea></TD>
		</TR><TR>
		<TD>"._CLA_PHOTO2." </TD><TD><input type=\"text\" class=\"text\" name=\"photo\" size=\"50\" value=\"$photo\"></TD>
		</TR><TR>";
		
		if ($ynprice == 1) {
		echo "<TD>"._CLA_PRICE2." </TD><TD><input type=\"text\" class=\"text\" name=\"price\" size=\"20\" value=\"$price\"> $monnaie";
$result = $db->query("select nom_prix from ".$db->prefix("ann_prix")." order by nom_prix");
	echo " <select name=\"id_prix\" class=\"select\"><option value=\"$typeprix\">$typeprix</option>";	
	while(list($nom_prix) = $db->fetchRow($result)) {
	
	$nom_prix = $myts->makeTboxData4Edit($nom_prix);
	
	    echo "<option value=\"$nom_prix\">$nom_prix</option>";
	  	}
	echo "</select></TD>";
		}
		
		$time = time();
		
		echo "</TR><TR>
		<TD>&nbsp;</TD><TD><SELECT NAME=\"op\" class=\"select\">
		<OPTION VALUE=\"AnnoncesModAnnonceS\"> "._CLA_MODIF."
		<OPTION VALUE=\"AnnoncesDel\"> "._DELETE."
		</SELECT><input type=\"submit\" value=\""._CLA_GO."\" class=\"button\"></TD>
		</TR></TABLE>";
		echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
	    echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
	    echo "<input type=\"hidden\" name=\"date\" value=\"$time\">";
	    echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
		</form><br>";
    CloseTable();
xoops_cp_footer();
         }    
		 }
		 
#  function AnnoncesModAnnonceS
#####################################################
function AnnoncesModAnnonceS($lid, $cat, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo) {
    global $db, $bcoosConfig, $myts;
	
	
	$title = $myts->makeTboxData4Save($title);
	$type = $myts->makeTboxData4Save($type);
	$description = $myts->makeTboxData4Save($description);
	$tel = $myts->makeTboxData4Save($tel);
	$price = $myts->makeTboxData4Save($price);
	$typeprix = $myts->makeTboxData4Save($typeprix);
	$submitter = $myts->makeTboxData4Save($submitter);	
	$town = $myts->makeTboxData4Save($town);
	$country = $myts->makeTboxData4Save($country);
	
    $db->query("update ".$db->prefix("ann_annonces")." set cid='$cat', title='$title', type='$type', description='$description', tel='$tel', price='$price', typeprix='$typeprix', date='$date', email='$email', submitter='$submitter', town='$town', country='$country', valid='$valid', photo='$photo' where lid=$lid");
redirect_header("index.php",1,_CLA_ANNMOD);
exit();
}
#  function AnnoncesDel
#####################################################
function AnnoncesDel($lid, $photo) {
    global $db;
	
    $db->query("delete from ".$db->prefix("ann_annonces")." where lid=$lid");
	
	$destination = XOOPS_ROOT_PATH."/modules/MyAnnonces/images_ann";
		if ($photo) {
		if (file_exists("$destination/$photo")) {
			 unlink("$destination/$photo");
			}
		}
	
redirect_header("index.php",1,_CLA_ANNDEL);
exit();
}
#  function AnnoncesValid
#####################################################
function AnnoncesValid($lid, $cat, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo) {
    global $db, $bcoosConfig, $myts;
	
	$title = $myts->makeTboxData4Save($title);
	$type = $myts->makeTboxData4Save($type);
	$description = $myts->makeTboxData4Save($description);
	$tel = $myts->makeTboxData4Save($tel);
	$price = $myts->makeTboxData4Save($price);
	$typeprix = $myts->makeTboxData4Save($typeprix);
	$submitter = $myts->makeTboxData4Save($submitter);	
	$town = $myts->makeTboxData4Save($town);
	$country = $myts->makeTboxData4Save($country);
	
    $db->query("update ".$db->prefix("ann_annonces")." set cid='$cat', title='$title', type='$type', description='$description', tel='$tel', price='$price', typeprix='$typeprix', date='$date', email='$email', submitter='$submitter', town='$town', country='$country', valid='$valid', photo='$photo'  where lid=$lid");
if ($email=="") {
	} else {	
	$message = ""._CLA_HELLO." $submitter,\n\n "._CLA_ANNACCEPT." :\n\n$type $title\n $description\n\n\n "._CLA_CONSULTTO."\n ".XOOPS_URL."/modules/MyAnnonces/index.php?pa=viewannonces&lid=$lid\n\n "._CLA_THANK."\n\n"._CLA_TEAMOF." ".$bcoosConfig['title']."\n".XOOPS_URL."";
	$subject = ""._CLA_ANNACCEPT."";
	$mail =& getMailer();
	$mail->useMail();
	$mail->setFromName($bcoosConfig['title']);
	$mail->setFromEmail($bcoosConfig['adminmail']);
	$mail->setToEmails($email);
	$mail->setSubject($subject);
	$mail->setBody($message);
	$mail->send();
	echo $mail->getErrors();
	}
redirect_header("index.php",1,_CLA_ANNVALID);
exit();
    }
#  function AnnoncesAddType
#####################################################
function AnnoncesAddType($type) {
    global $db, $bcoosConfig, $myts;
	
	
list($numrows) = $db->fetchRow($db->query("SELECT  COUNT(*)  FROM ".$db->prefix("ann_type")." where nom_type='$type'"));
    if ($numrows>0) {
xoops_cp_header();
	OpenTable();
	echo "<br><center><b>"._CLA_ERRORTYPE." $nom_type "._CLA_EXIST."</b><br><br>";
echo "<form method=\"post\" action=\"index.php\">
		<b>"._CLA_ADDTYPE."</b><br><br>
		"._CLA_TYPE."	<input type=\"text\" class=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">	
				<input type=\"hidden\" name=\"op\" value=\"AnnoncesAddType\">
				<input type=\"submit\" value=\""._CLA_ADD."\" class=\"button\">
		</form>";
	CloseTable();
xoops_cp_footer();
    } else {
	
	$type = $myts->makeTboxData4Save($type);
	
	if ($type == "") { $type = "! ! ? ! !";}
	
	$db->query("insert into ".$db->prefix("ann_type")." values (NULL, '$type')");
	
redirect_header("index.php",1,_CLA_ADDTYPE2);
exit();
    }
}
#  function AnnoncesModType
#####################################################
function AnnoncesModType($id_type, $nom_type) {
    global $db, $bcoosConfig, $xoopsModule, $myts;
	
	
xoops_cp_header();
    OpenTable();
	echo "<b>"._CLA_MODTYPE."</b><br><br>";
	$result = $db->query("select id_type, nom_type from ".$db->prefix("ann_type")." where id_type=$id_type");
	list($id_type, $nom_type) = $db->fetchRow($result);
	
	$nom_type = $myts->makeTboxData4Edit($nom_type);
	echo "<form action=\"index.php\" method=\"post\">"
	    .""._CLA_TYPE." <input type=\"text\" class=\"text\" name=\"nom_type\" value=\"$nom_type\" size=\"51\" maxlength=\"50\"><br>"
		."<input type=\"hidden\" name=\"id_type\" value=\"$id_type\">"
	    ."<input type=\"hidden\" name=\"op\" value=\"AnnoncesModTypeS\">"
	    ."<table border=\"0\"><tr><td>"
	    ."<input type=\"submit\" value=\""._CLA_SAVMOD."\" class=\"button\"></form></td><td>"
	    ."<form action=\"index.php\" method=\"post\">"
		."<input type=\"hidden\" name=\"id_type\" value=\"$id_type\">"
	    ."<input type=\"hidden\" name=\"op\" value=\"AnnoncesDelType\">"
	    ."<input type=\"submit\" value=\""._DELETE."\" class=\"button\"></form></td></tr></table>";
		
    CloseTable();
xoops_cp_footer();		
		    } 
#  function AnnoncesModTypeS
#####################################################
function AnnoncesModTypeS($id_type, $nom_type) {
    global $db,$bcoosConfig, $myts;
	
	$nom_type = $myts->makeTboxData4Save($nom_type);
    
	$db->query("update ".$db->prefix("ann_type")." set nom_type='$nom_type' where id_type='$id_type'");
   
redirect_header("index.php",1,_CLA_TYPEMOD);
exit();
}
#  function AnnoncesDelType
#####################################################
function AnnoncesDelType($id_type) {
    global $db;
	
    $db->query("delete from ".$db->prefix("ann_type")." where id_type='$id_type'");
	
redirect_header("index.php",1,_CLA_TYPEDEL);
exit();
}
	
#  function AnnoncesAddPrix
#####################################################
function AnnoncesAddPrix($type) {
    global $db, $bcoosConfig, $myts;
	
	
list($numrows) = $db->fetchRow($db->query("SELECT  COUNT(*)  FROM ".$db->prefix("ann_prix")." where nom_prix='$type'"));
    if ($numrows>0) {
xoops_cp_header();
	OpenTable();
	echo "<br><center><b>"._CLA_ERRORPRIX." $nom_prix "._CLA_EXIST."</b><br><br>";
echo "<form method=\"post\" action=\"index.php\">
		<b>"._CLA_ADDPRIX."</b><br><br>
		"._CLA_TYPE."	<input type=\"text\" class=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">	
				<input type=\"hidden\" name=\"op\" value=\"AnnoncesAddPrix\">
				<input type=\"submit\" value=\""._CLA_ADD."\" class=\"button\">
		</form>";
	CloseTable();
xoops_cp_footer();
    } else {
	
	$type = $myts->makeTboxData4Save($type);
	
	if ($type == "") { $type = "! ! ? ! !";}
	
	$db->query("insert into ".$db->prefix("ann_prix")." values (NULL, '$type')");
	
redirect_header("index.php",1,_CLA_ADDPRIX2);
exit();
    }
}
#  function AnnoncesModPrix
#####################################################
function AnnoncesModPrix($id_prix, $nom_type) {
    global $db, $bcoosConfig, $xoopsModule, $myts;
	
	
xoops_cp_header();
    OpenTable();
	echo "<b>"._CLA_MODPRIX."</b><br><br>";
	$result = $db->query("select nom_prix from ".$db->prefix("ann_prix")." where id_prix=$id_prix");
	list($nom_prix) = $db->fetchRow($result);
	
	$nom_prix = $myts->makeTboxData4Edit($nom_prix);
	echo "<form action=\"index.php\" method=\"post\">"
	    .""._CLA_TYPE." <input type=\"text\" class=\"text\" name=\"nom_prix\" value=\"$nom_prix\" size=\"51\" maxlength=\"50\"><br>"
		."<input type=\"hidden\" name=\"id_prix\" value=\"$id_prix\">"
	    ."<input type=\"hidden\" name=\"op\" value=\"AnnoncesModPrixS\">"
	    ."<table border=\"0\"><tr><td>"
	    ."<input type=\"submit\" value=\""._CLA_SAVMOD."\" class=\"button\"></form></td><td>"
	    ."<form action=\"index.php\" method=\"post\">"
		."<input type=\"hidden\" name=\"id_prix\" value=\"$id_prix\">"
	    ."<input type=\"hidden\" name=\"op\" value=\"AnnoncesDelPrix\">"
	    ."<input type=\"submit\" value=\""._DELETE."\" class=\"button\"></form></td></tr></table>";
		
    CloseTable();
xoops_cp_footer();		
		    } 
#  function AnnoncesModPrixS
#####################################################
function AnnoncesModPrixS($id_prix, $nom_prix) {
    global $db, $bcoosConfig, $myts;
	
	$nom_prix = $myts->makeTboxData4Save($nom_prix);
    
	$db->query("update ".$db->prefix("ann_prix")." set nom_prix='$nom_prix' where id_prix='$id_prix'");
   
redirect_header("index.php",1,_CLA_PRIXMOD);
exit();
}
#  function AnnoncesDelPrix
#####################################################
function AnnoncesDelPrix($id_prix) {
    global $db;
	
    $db->query("delete from ".$db->prefix("ann_prix")." where id_prix='$id_prix'");
	
redirect_header("index.php",1,_CLA_PRIXDEL);
exit();
}
switch ($op) {
    case "IndexView":
    IndexView($lid);
    break;
    case "AnnoncesDelPrix":
    AnnoncesDelPrix($id_prix);
    break;
    case "AnnoncesModPrix":
    AnnoncesModPrix($id_prix, $nom_prix);
    break;
    case "AnnoncesModPrixS":
    AnnoncesModPrixS($id_prix, $nom_prix);
    break;
    case "AnnoncesAddPrix":
    AnnoncesAddPrix($type);
    break;
    case "AnnoncesDelType":
    AnnoncesDelType($id_type);
    break;
    case "AnnoncesModType":
    AnnoncesModType($id_type, $nom_type);
    break;
    case "AnnoncesModTypeS":
    AnnoncesModTypeS($id_type, $nom_type);
    break;
    case "AnnoncesAddType":
    AnnoncesAddType($type);
    break;
    case "AnnoncesDel":
    AnnoncesDel($lid, $photo);
    break;
    case "AnnoncesValid":
    AnnoncesValid($lid, $cid, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $town, $country, $valid, $photo);
    break;
		    
    case "AnnoncesModAnnonce":
    AnnoncesModAnnonce($lid);
    break;
    case "AnnoncesModAnnonceS":
    AnnoncesModAnnonceS($lid, $cid, $title, $type, $description, $tel, $price, $id_prix, $date, $email, $submitter, $town, $country, $valid, $photo);
    break;
    default:
    Index();
    break;
}
?>
