Gestion des fichiers
This commit is contained in:
parent
f768dcaf73
commit
2e26eeea1e
@ -24,37 +24,30 @@ llxHeader();
|
|||||||
|
|
||||||
$db = new Db();
|
$db = new Db();
|
||||||
|
|
||||||
|
$upload_dir = SOCIETE_DOCUMENT_DIR . "/" . $socid . "/";
|
||||||
|
|
||||||
function do_upload ($socid) {
|
function do_upload ($socid)
|
||||||
global $uploadfile, $uploadfile_size;
|
{
|
||||||
|
global $upload_dir;
|
||||||
global $local_file, $error_msg;
|
global $local_file, $error_msg;
|
||||||
|
|
||||||
if ( $uploadfile == "none" )
|
if (! is_dir($upload_dir))
|
||||||
{
|
{
|
||||||
$error_msg = "You did not specify a file for uploading.";
|
mkdir($upload_dir, 0755);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( $uploadfile_size > 2000000 )
|
|
||||||
{
|
|
||||||
$error_msg = "Sorry, your file is too large.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$soc_dir = SOCIETE_DOCUMENT_DIR . "/" . $socid;
|
|
||||||
|
|
||||||
if (! is_dir($soc_dir))
|
|
||||||
{
|
|
||||||
mkdir($soc_dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$upload_dir = "/tmp";
|
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . $_FILES['userfile']['name']))
|
||||||
|
{
|
||||||
$local_file = SOCIETE_DOCUMENT_DIR . "/" . $socid . "/";
|
print "Le fichier est valide, et a été téléchargé
|
||||||
|
avec succès. Voici plus d'informations :\n";
|
||||||
move_uploaded_file ( $userfile, $local_file );
|
//print_r($_FILES);
|
||||||
|
}
|
||||||
print $HTTP_POST_FILES['uploadfile']['name'];
|
else
|
||||||
|
{
|
||||||
|
echo "Le fichier n'a pas été téléchargé";
|
||||||
|
// print_r($_FILES);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +55,12 @@ if ( $error_msg )
|
|||||||
{
|
{
|
||||||
echo "<B>$error_msg</B><BR><BR>";
|
echo "<B>$error_msg</B><BR><BR>";
|
||||||
}
|
}
|
||||||
|
if ($action=='delete')
|
||||||
|
{
|
||||||
|
$file = $upload_dir . urldecode($urlfile);
|
||||||
|
dol_delete_file($file);
|
||||||
|
}
|
||||||
|
|
||||||
if ( $sendit )
|
if ( $sendit )
|
||||||
{
|
{
|
||||||
do_upload ($socid);
|
do_upload ($socid);
|
||||||
@ -78,7 +77,7 @@ if ($socid > 0)
|
|||||||
{
|
{
|
||||||
$societe = new Societe($db, $socid);
|
$societe = new Societe($db, $socid);
|
||||||
|
|
||||||
$sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM societe as s, c_stcomm as st, c_typent as t, c_effectif as e ";
|
$sql = "SELECT s.idp, s.nom, ".$db->pdate("s.datec")." as dc, s.tel, s.fax, st.libelle as stcomm, s.fk_stcomm, s.url,s.address,s.cp,s.ville, s.note, t.libelle as typent, e.libelle as effectif, s.siren, s.prefix_comm, s.services,s.parent, s.description FROM llx_societe as s, c_stcomm as st, c_typent as t, c_effectif as e ";
|
||||||
$sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id";
|
$sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id";
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +99,6 @@ if ($socid > 0)
|
|||||||
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\">\n";
|
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\">\n";
|
||||||
|
|
||||||
print "<tr><td><div class=\"titre\">Fiche client : $objsoc->nom</div></td>";
|
print "<tr><td><div class=\"titre\">Fiche client : $objsoc->nom</div></td>";
|
||||||
print "<td align=\"center\"><a href=\"index.php3?socidp=$objsoc->idp&action=add_bookmark\">[Bookmark]</a></td>";
|
|
||||||
print "<td align=\"center\"><a href=\"projet/fiche.php3?socidp=$objsoc->idp&action=create\">[Projet]</a></td>";
|
print "<td align=\"center\"><a href=\"projet/fiche.php3?socidp=$objsoc->idp&action=create\">[Projet]</a></td>";
|
||||||
print "<td align=\"center\"><a href=\"addpropal.php3?socidp=$objsoc->idp&action=create\">[Propal]</a></td>";
|
print "<td align=\"center\"><a href=\"addpropal.php3?socidp=$objsoc->idp&action=create\">[Propal]</a></td>";
|
||||||
print "<td><a href=\"socnote.php3?socid=$objsoc->idp\">Notes</a></td>";
|
print "<td><a href=\"socnote.php3?socid=$objsoc->idp\">Notes</a></td>";
|
||||||
@ -122,16 +120,15 @@ if ($socid > 0)
|
|||||||
|
|
||||||
print "<tr><td>siren</td><td><a href=\"http://www.societe.com/cgi-bin/recherche?rncs=$objsoc->siren\">$objsoc->siren</a> </td>";
|
print "<tr><td>siren</td><td><a href=\"http://www.societe.com/cgi-bin/recherche?rncs=$objsoc->siren\">$objsoc->siren</a> </td>";
|
||||||
print "<td>prefix</td><td>";
|
print "<td>prefix</td><td>";
|
||||||
if ($objsoc->prefix_comm) {
|
if ($objsoc->prefix_comm)
|
||||||
print $objsoc->prefix_comm;
|
{
|
||||||
} else {
|
print $objsoc->prefix_comm;
|
||||||
print "[<a href=\"$PHP_SELF?socid=$objsoc->idp&action=attribute_prefix\">Attribuer</a>]";
|
} else {
|
||||||
}
|
print "[<a href=\"$PHP_SELF?socid=$objsoc->idp&action=attribute_prefix\">Attribuer</a>]";
|
||||||
|
}
|
||||||
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Site</td><td colspan=\"3\"><a href=\"http://$objsoc->url\">$objsoc->url</a> </td></tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -143,15 +140,39 @@ if ($socid > 0)
|
|||||||
|
|
||||||
echo '<FORM NAME="userfile" ACTION="docsoc.php?socid='.$socid.'" ENCTYPE="multipart/form-data" METHOD="POST">';
|
echo '<FORM NAME="userfile" ACTION="docsoc.php?socid='.$socid.'" ENCTYPE="multipart/form-data" METHOD="POST">';
|
||||||
|
|
||||||
print '<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="2000000">';
|
print '<input type="hidden" name="max_file_size" value="2000000">';
|
||||||
print '<input type="file" name="userfile" size="40" maxlength="80">';
|
print '<input type="file" name="userfile" size="40" maxlength="80">';
|
||||||
print '<BR><BR>';
|
print '<BR>';
|
||||||
print '<INPUT TYPE="SUBMIT" VALUE="Upload File!" NAME="sendit">';
|
print '<input type="submit" value="Upload File!" name="sendit">';
|
||||||
print '<INPUT TYPE="SUBMIT" VALUE="Cancel" NAME="cancelit"><BR>';
|
print '<input type="submit" value="Cancel" name="cancelit"><BR>';
|
||||||
print '</FORM>';
|
print '</FORM>';
|
||||||
|
|
||||||
|
clearstatcache();
|
||||||
|
|
||||||
|
$handle=opendir($upload_dir);
|
||||||
|
|
||||||
|
print '<table width="100%" border="1" cellpadding="3" cellspacing="0">';
|
||||||
|
|
||||||
|
while (($file = readdir($handle))!==false)
|
||||||
|
{
|
||||||
|
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||||
|
{
|
||||||
|
print '<tr><td>';
|
||||||
|
echo '<a href="/document/societe/'.$socid.'/'.$file.'">'.$file.'</a>';
|
||||||
|
print "</td>\n";
|
||||||
|
|
||||||
|
print '<td align="right">'.filesize($upload_dir."/".$file). ' bytes</td>';
|
||||||
|
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($upload_dir."/".$file)).'</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
echo '<a href="'.$PHP_SELF.'?socid='.$socid.'&action=delete&urlfile='.urlencode($file).'">Delete</a>';
|
||||||
|
print "</td></tr>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
closedir($handle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user