[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> 5 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * 21 * $Id: document.php,v 1.24 2005/10/02 19:32:46 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/propal/document.php,v $ 23 */ 24 25 /** 26 \file htdocs/comm/propal/document.php 27 \ingroup propale 28 \brief Page de gestion des documents attachées à une proposition commerciale 29 \version $Revision: 1.24 $ 30 */ 31 32 require ('./pre.inc.php'); 33 require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 34 35 $user->getrights('propale'); 36 37 if (!$user->rights->propale->lire) 38 accessforbidden(); 39 40 $langs->load('compta'); 41 42 llxHeader(); 43 44 $propalid=empty($_GET['propalid']) ? 0 : intVal($_GET['propalid']); 45 $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; 46 47 48 function do_upload ($upload_dir) 49 { 50 global $local_file, $error_msg, $langs; 51 52 if (! is_dir($upload_dir)) 53 { 54 create_exdir($upload_dir); 55 } 56 57 if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) 58 { 59 echo $langs->trans('FileUploaded'); 60 } 61 else 62 { 63 echo $langs->trans('FileNotUploaded'); 64 } 65 } 66 67 /******************************************************************************/ 68 /* Actions */ 69 /******************************************************************************/ 70 71 if ($propalid > 0) 72 { 73 $propal = new Propal($db); 74 75 if ($propal->fetch($propalid)) 76 { 77 $propref = sanitize_string($propal->ref); 78 $upload_dir = $conf->propal->dir_output.'/'.$propref; 79 80 if ( $error_msg ) 81 { 82 echo '<B>'.$error_msg.'</B><BR><BR>'; 83 } 84 85 /******************************************************************************/ 86 /* Actions */ 87 /******************************************************************************/ 88 if ($action=='delete') 89 { 90 $file = $upload_dir . '/' . urldecode($_GET['urlfile']); 91 dol_delete_file($file); 92 } 93 94 if ( $_POST['sendit'] ) 95 { 96 do_upload ($upload_dir); 97 } 98 99 $h=0; 100 101 $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; 102 $head[$h][1] = $langs->trans('CommercialCard'); 103 $h++; 104 105 $head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id; 106 $head[$h][1] = $langs->trans('AccountancyCard'); 107 $h++; 108 109 if ($conf->use_preview_tabs) 110 { 111 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id; 112 $head[$h][1] = $langs->trans("Preview"); 113 $h++; 114 } 115 116 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id; 117 $head[$h][1] = $langs->trans('Note'); 118 $h++; 119 120 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id; 121 $head[$h][1] = $langs->trans('Info'); 122 $h++; 123 124 $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id; 125 $head[$h][1] = $langs->trans('Documents'); 126 $hselected=$h; 127 $h++; 128 129 dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); 130 131 print_titre($langs->trans('AssociatedDocuments').' '.$propal->ref_url); 132 133 print '<table width="100%" class="noborder">'; 134 135 print '<form name="userfile" action="document.php?propalid='.$propal->id.'" enctype="multipart/form-data" method="POST">'; 136 print '<input type="hidden" name="max_file_size" value="2000000">'; 137 print '<input type="file" name="userfile" size="40" maxlength="80" class="flat"><br>'; 138 print '<input type="submit" value="'.$langs->trans('Upload').'" name="sendit" class="button"> '; 139 print '<input type="submit" value="'.$langs->trans('Cancel').'" name="cancelit" class="button"><br>'; 140 print '</form><br>'; 141 142 clearstatcache(); 143 144 if (is_dir($upload_dir)) 145 { 146 147 $handle=opendir($upload_dir); 148 if ($handle) 149 { 150 print '<tr class="liste_titre">'; 151 print '<td>'.$langs->trans('Document').'</td>'; 152 print '<td align="right">'.$langs->trans('Size').'</td>'; 153 print '<td align="center">'.$langs->trans('Date').'</td>'; 154 print '<td> </td>'; 155 print '</tr>'; 156 $var=true; 157 while (($file = readdir($handle))!==false) 158 { 159 if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') 160 { 161 $var=!$var; 162 print '<tr '.$bc[$var].'>'; 163 print '<td>'; 164 echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=propal&file='.$propref.'/'.urlencode($file).'">'.$file.'</a>'; 165 print "</td>\n"; 166 print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>'; 167 print '<td align="center">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>'; 168 print '<td align="center">'; 169 if ($file == $propref . '.pdf') 170 { 171 echo '-'; 172 } 173 else 174 { 175 echo '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>'; 176 } 177 print "</td></tr>\n"; 178 } 179 } 180 closedir($handle); 181 } 182 else 183 { 184 print '<div class="error">'.$langs->trans('ErrorCantOpenDir').'<b> '.$upload_dir.'</b></div>'; 185 } 186 187 } 188 print '</table>'; 189 190 print '</div>'; 191 } 192 else 193 { 194 dolibarr_print_error($db); 195 } 196 } 197 else 198 { 199 print $langs->trans("UnkownError"); 200 } 201 202 $db->close(); 203 204 llxFooter('$Date: 2005/10/02 19:32:46 $ - $Revision: 1.24 $'); 205 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |