<!-- #include file="upload.asp" -->
<!-- #INCLUDE FILE="mini-adovbs.inc" -->

<!--#include file="haut.asp"-->

<%
Dim iReceipe, iImagePath

strAction = Request.Querystring("action")
iReceipeId = Request.Querystring("receipe_id")
resto = Request.Querystring("resto_id")
if strAction = "" then
strAction = "start"
end if



if request.QueryString("act") = "del" then

    if request.QueryString("laphoto") = "5" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path5 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
    elseif request.QueryString("laphoto") = "6" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path6 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
            
    elseif request.QueryString("laphoto") = "7" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path7 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
                              
    elseif request.QueryString("laphoto") = "8" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path8 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
          
    elseif request.QueryString("laphoto") = "2" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path2 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL   
                
    elseif request.QueryString("laphoto") = "3" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path3 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL 
                
    elseif request.QueryString("laphoto") = "4" then
        'myrs("t_img_path4") = File.FileName
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path4 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
          
                                
    else        
          mySQL = "UPDATE tbl_receipe_sante Set t_img_path = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
          cnnrecettes.Execute mySQL
    end if

end if


Select case strAction
case "start"

'cnnrecettes.Open "Driver={MySQL ODBC 3.51 Driver};Server=mysql3.brinkster.com;uid=parisfrance;pwd=veronique;database=parisfrance;"
Set cnnresto = Server.CreateObject("ADODB.Connection")
strSQL = "SELECT t_rec_num, t_receipe, t_img_path, t_img_path2, t_img_path3, t_img_path4, t_img_path5, t_img_path6, t_img_path7, t_img_path8 FROM tbl_receipe_sante WHERE t_rec_num =" & iReceipeId & ";"

'rstresto.Open strSQL, cnnrecettes, adOpenKeyset, adLockPessimistic, adCmdText
'Set rstresto = cnnresto.Execute(strSQL)
Set rstresto = cnnrecettes.Execute(strSQL)
%>

 <BR><p><a href="admin_modify_receipe.asp?action=display&receipe_id=<%= request.QueryString("receipe_id") %>&resto_id=<%= request.QueryString("resto_id") %>">Modifier recette</a> - <a href="../RecettessanteVi.asp?action=display&receipe=<%= request.QueryString("receipe_id") %>&resto_id=<%= request.QueryString("resto_id") %>" target="_blank">Visualiser recette</a>
                                                  </p><BR>


<p><b>Ajout d'une photo de recette.</b></p>
<table>
  <tr>
    <td>
      <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=1" enctype="multipart/form-data" method="post">
          <tr> 
            <td>Nom de la recette :</td>
            <td><%= rstresto("t_receipe") %></td>
          </tr>
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Petite photo 1</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>

      </table>
      
      <p>Photo en cour d'utilisation : <b><%= rstresto("t_img_path") %></b>.
      <br><br>
      <img border=1 src="<%= "../images/sante/" & rstresto("t_img_path") %>">       
      
    <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=2" enctype="multipart/form-data" method="post">
          <tr align="center" valign="top" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Petite photo 2</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path2" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
        <% if rstresto("t_img_path2") <> "" then %>
          <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=2&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path2") %>"></a> 
        <% end if %>      
      
      
    <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=3" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Petite photo 3</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path3" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form> 
      </table>
      
       <% if rstresto("t_img_path3") <> "" then %>
          <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=3&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path3") %>"></a> 
       <% end if %>
      
    <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=4" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Petite photo 4</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path4" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
     <% if rstresto("t_img_path4") <> "" then %>
        <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=4&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path4") %>"></a> 
     <% end if %>     
      
 
  <hr>
  

    <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=5" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" > 
            <td colspan="2" bgcolor="#CCCCCC">              <strong>Grosse photo 1</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path5" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
     <% if rstresto("t_img_path5") <> "" then %>
        <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=5&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path5") %>"></a> 
     <% end if %>   
 
   
      <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=6" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Grosse photo 2</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path6" type="file" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
     <% if rstresto("t_img_path6") <> "" then %>
        <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=6&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path6") %>"></a> 
     <% end if %>   
 
 
       <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=7" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Grosse photo 3</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path7" type="file" id="image_path7" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
     <% if rstresto("t_img_path7") <> "" then %>
        <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=7&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path7") %>"></a> 
     <% end if %> 


       <table>
        <form action="admin_upload_imageFin.php?action=done&receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=8" enctype="multipart/form-data" method="post">
          <tr align="center" valign="middle" bgcolor="#CCCCCC"> 
            <td colspan="2"><strong>Grosse photo 4</strong></td>
          </tr>
          <tr> 
            <td>Photo de la recette :</td>
            <td><input name="image_path8" type="file" id="image_path8" size="50" maxlength="150"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="submit" value="Ajouter"> 
            </td>
          </tr>
        </form>
      </table>
     <% if rstresto("t_img_path8") <> "" then %>
        <a href="admin_upload_image.asp?receipe_id=<%= rstresto("t_rec_num") %>&resto_id=<%= resto %>&laphoto=8&act=del"><img border=1 src="<%= "../images/sante/" & rstresto("t_img_path8") %>"></a> 
     <% end if %>      
      
    </td>
  </tr>
  <tr>
    <td>

    </td>
  </tr>
</table>
<%
'rstresto.Close
'cnnrecettes.Close

case "done"

Dim Uploader
Set Uploader = New FileUploader
Uploader.Upload()
If Uploader.Files.Count = 0 Then
  Response.Write "File(s) not uploaded."
Else
  For Each File In Uploader.Files.Items
    File.SaveToDisk Server.MapPath("images/sante/")




Set myrs = CreateObject("ADODB.Recordset")

  'mySQL = "SELECT * FROM tbl_receipe_sante WHERE t_rec_num =" & iReceipeId & ";"
  'myrs.Source = mySQL
  'Set myrs.ActiveConnection = cnnrecettes
  'myrs.CursorLocation = adUseClient
  'myrs.LockType = adLockPessimistic
  'myrs.Open
  
  LeFichier = File.FileName
  
    if request.QueryString("laphoto") = "2" then
      'myrs("t_img_path2") = File.FileName
      mySQL = "UPDATE tbl_receipe_sante Set t_img_path2 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
      cnnrecettes.Execute mySQL
  elseif request.QueryString("laphoto") = "3" then
      'myrs("t_img_path3") = File.FileName
      mySQL = "UPDATE tbl_receipe_sante Set t_img_path3 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
      cnnrecettes.Execute mySQL 
  elseif request.QueryString("laphoto") = "4" then
      'myrs("t_img_path4") = File.FileName
      mySQL = "UPDATE tbl_receipe_sante Set t_img_path4 = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
      cnnrecettes.Execute mySQL 
  else
      'myrs("t_img_path") = File.FileName
      mySQL = "UPDATE tbl_receipe_sante Set t_img_path = '" & LeFichier & "' WHERE t_rec_num =" & iReceipeId & " " 
      cnnrecettes.Execute mySQL 
  end if
     ' myrs.Update
    'myrs.Close
    cnnrecettes.Close
  Next
End If



%>
<p>La photo pour la recette <b><%= iReceipe %></b> est modifi&eacute;e.</p>
<A HREF="./admin_display_receipe.asp?resto=<%= resto %>"><FONT SIZE="-1" COLOR="#0000FF"><I>Retour à la liste</I></FONT></A><BR><BR>
<%
End Select
%>
<!--#include file="bas.asp"-->