2002-12-12 22:37:44 +01:00
< ? PHP
2003-02-03 12:56:05 +01:00
/* Copyright ( C ) 2002 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2002-12-12 22:37:44 +01:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
require ( " ./pre.inc.php3 " );
llxHeader ();
2003-07-05 23:49:43 +02:00
$upload_dir = SOCIETE_OUTPUTDIR . " / " . $socid ;
2003-06-24 17:21:05 +02:00
if ( ! is_dir ( $upload_dir ))
{
2003-07-05 23:49:43 +02:00
umask ( 0 );
mkdir ( $upload_dir , 0755 );
2003-06-24 17:21:05 +02:00
}
2002-12-12 22:37:44 +01:00
2003-06-17 16:36:36 +02:00
function do_upload ( $socid )
{
global $upload_dir ;
2002-12-12 22:37:44 +01:00
global $local_file , $error_msg ;
2003-09-06 18:28:28 +02:00
if ( doliMoveFileUpload ( $_FILES [ 'userfile' ][ 'tmp_name' ], $upload_dir . " / " . $_FILES [ 'userfile' ][ 'name' ]))
2002-12-12 22:37:44 +01:00
{
2003-06-17 16:36:36 +02:00
print " Le fichier est valide, et a été téléchargé
2003-06-18 15:25:08 +02:00
avec succ & egrave ; s . \n " ;
2003-06-17 16:36:36 +02:00
//print_r($_FILES);
}
else
{
echo " Le fichier n'a pas <20> t<EFBFBD> t<> l<EFBFBD> charg<72> " ;
// print_r($_FILES);
2003-02-03 12:56:05 +01:00
}
2002-12-12 22:37:44 +01:00
}
if ( $error_msg )
{
echo " <B> $error_msg </B><BR><BR> " ;
}
2003-06-17 16:36:36 +02:00
if ( $action == 'delete' )
{
2003-07-05 23:49:43 +02:00
$file = $upload_dir . " / " . urldecode ( $urlfile );
2003-06-17 16:36:36 +02:00
dol_delete_file ( $file );
}
2003-06-24 17:21:05 +02:00
if ( $sendit )
2002-12-12 22:37:44 +01:00
{
2003-02-03 12:56:05 +01:00
do_upload ( $socid );
2002-12-12 22:37:44 +01:00
}
/*
*
* Mode fiche
*
*
*/
2003-02-03 12:56:05 +01:00
if ( $socid > 0 )
{
2002-12-12 22:37:44 +01:00
$societe = new Societe ( $db , $socid );
2003-06-17 16:36:36 +02:00
$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 " ;
2002-12-12 22:37:44 +01:00
$sql .= " WHERE s.fk_stcomm=st.id AND s.fk_typent = t.id AND s.fk_effectif = e.id " ;
$result = $db -> query ( $sql );
2003-02-03 12:56:05 +01:00
if ( $result )
{
$objsoc = $db -> fetch_object ( 0 );
$dac = strftime ( " %Y-%m-%d %H:%M " , time ());
if ( $errmesg )
{
print " <b> $errmesg </b><br> " ;
}
/*
*
*/
print " <table width= \" 100% \" border= \" 0 \" cellspacing= \" 1 \" > \n " ;
2003-06-18 15:25:08 +02:00
print " <tr><td><div class= \" titre \" >Documents associ<63> s <20> l'entreprise : $objsoc->nom </div></td> " ;
2003-06-18 18:44:56 +02:00
print " <td align= \" center \" ><a href= \" fiche.php3?socid= $objsoc->idp\ " > Commercial </ a ></ td > " ;
print " <td align= \" center \" ><a href= \" ../compta/fiche.php3?socid= $objsoc->idp\ " > Compta </ a ></ td > " ;
2003-02-03 12:56:05 +01:00
print " <td><a href= \" socnote.php3?socid= $objsoc->idp\ " > Notes </ a ></ td > " ;
print " <td align= \" center \" >[<a href= \" ../soc.php3?socid= $objsoc->idp &action=edit \" >Editer</a>]</td> " ;
print " </tr></table> " ;
/*
*
*
*/
print " <table width= \" 100% \" border=0><tr> \n " ;
print " <td valign= \" top \" > " ;
print " <table cellspacing= \" 0 \" border= \" 1 \" width= \" 100% \" > " ;
print " <tr><td>Type</td><td> $objsoc->typent </td><td>Effectif</td><td> $objsoc->effectif </td></tr> " ;
print " <tr><td>Tel</td><td> $objsoc->tel </td><td>fax</td><td> $objsoc->fax </td></tr> " ;
print " <tr><td>Ville</td><td colspan= \" 3 \" > " . nl2br ( $objsoc -> address ) . " <br> $objsoc->cp $objsoc->ville </td></tr> " ;
print " <tr><td>siren</td><td><a href= \" http://www.societe.com/cgi-bin/recherche?rncs= $objsoc->siren\ " > $objsoc -> siren </ a >& nbsp ; </ td > " ;
print " <td>prefix</td><td> " ;
2003-06-17 16:36:36 +02:00
if ( $objsoc -> prefix_comm )
{
print $objsoc -> prefix_comm ;
2003-06-18 18:44:56 +02:00
}
else
{
2003-06-17 16:36:36 +02:00
print " [<a href= \" $PHP_SELF ?socid= $objsoc->idp &action=attribute_prefix \" >Attribuer</a>] " ;
}
2003-02-03 12:56:05 +01:00
print " </td></tr> " ;
print " </table> " ;
/*
*
*/
print " </td> \n " ;
print " </table> " ;
2003-06-24 17:21:05 +02:00
echo '<FORM NAME="userfile" ACTION="docsoc.php?socid=' . $socid . '" ENCTYPE="multipart/form-data" METHOD="POST">' ;
2003-06-17 16:36:36 +02:00
print '<input type="hidden" name="max_file_size" value="2000000">' ;
2003-02-03 12:56:05 +01:00
print '<input type="file" name="userfile" size="40" maxlength="80">' ;
2003-06-17 16:36:36 +02:00
print '<BR>' ;
print '<input type="submit" value="Upload File!" name="sendit">' ;
print '<input type="submit" value="Cancel" name="cancelit"><BR>' ;
2003-02-03 12:56:05 +01:00
print '</FORM>' ;
2003-06-17 16:36:36 +02:00
clearstatcache ();
$handle = opendir ( $upload_dir );
2003-06-18 18:41:04 +02:00
if ( $handle )
2003-06-17 16:36:36 +02:00
{
2002-12-12 22:37:44 +01:00
2003-06-18 18:41:04 +02:00
print '<table width="100%" border="1" cellpadding="3" cellspacing="0">' ;
2002-12-12 22:37:44 +01:00
2003-06-18 18:41:04 +02:00
while (( $file = readdir ( $handle )) !== false )
{
if ( ! is_dir ( $dir . $file ) && substr ( $file , 0 , 1 ) <> '.' && substr ( $file , 0 , 3 ) <> 'CVS' )
{
print '<tr><td>' ;
2003-06-18 18:44:56 +02:00
echo '<a href="' . DOL_URL_ROOT . '/document/societe/' . $socid . '/' . $file . '">' . $file . '</a>' ;
2003-06-18 18:41:04 +02:00
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 );
}
2003-06-18 18:42:27 +02:00
else
{
2003-06-18 18:44:56 +02:00
print " <p>Impossible d'ouvrir : <b> " . $upload_dir . " </b> " ;
2003-06-18 18:42:27 +02:00
}
2003-02-03 12:56:05 +01:00
}
else
{
print $db -> error () . " <br> " . $sql ;
}
}
else
{
2002-12-12 22:37:44 +01:00
print " Erreur " ;
}
$db -> close ();
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>