| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: fiche.php,v 1.30.2.1 2006/01/14 13:46:25 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/dons/fiche.php,v $ 21 */ 22 23 /** 24 \file htdocs/compta/dons/fiche.php 25 \ingroup don 26 \brief Page de fiche de don 27 \version $Revision: 1.30.2.1 $ 28 */ 29 30 require_once ("./pre.inc.php"); 31 require_once(DOL_DOCUMENT_ROOT."/don.class.php"); 32 require_once(DOL_DOCUMENT_ROOT."/paiement.class.php"); 33 34 $langs->load("donations"); 35 $langs->load("bills"); 36 37 $mesg=""; 38 39 40 /* 41 * Actions 42 */ 43 44 if ($_POST["action"] == 'update') 45 { 46 47 if ($_POST["amount"] > 0) 48 { 49 50 $don = new Don($db); 51 $don->id = $_POST["rowid"]; 52 $don->fetch($_POST["rowid"]); 53 54 $don->prenom = $_POST["prenom"]; 55 $don->nom = $_POST["nom"]; 56 $don->societe = $_POST["societe"]; 57 $don->adresse = $_POST["adresse"]; 58 $don->amount = $_POST["amount"]; 59 $don->cp = $_POST["cp"]; 60 $don->ville = $_POST["ville"]; 61 $don->email = $_POST["email"]; 62 $don->date = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 63 $don->note = $_POST["note"]; 64 $don->pays = $_POST["pays"]; 65 $don->public = $_POST["public"]; 66 $don->projetid = $_POST["projetid"]; 67 $don->commentaire = $_POST["comment"]; 68 $don->modepaiementid = $_POST["modepaiement"]; 69 70 if ($don->update($user) > 0) 71 { 72 Header("Location: fiche.php?rowid=".$don->id); 73 exit; 74 } 75 } 76 else 77 { 78 $mesg="Montant non défini"; 79 } 80 } 81 82 if ($_POST["action"] == 'add') 83 { 84 85 if ($_POST["amount"] > 0) 86 { 87 $don = new Don($db); 88 89 $don->prenom = $_POST["prenom"]; 90 $don->nom = $_POST["nom"]; 91 $don->societe = $_POST["societe"]; 92 $don->adresse = $_POST["adresse"]; 93 $don->amount = $_POST["amount"]; 94 $don->cp = $_POST["cp"]; 95 $don->ville = $_POST["ville"]; 96 $don->email = $_POST["email"]; 97 $don->date = mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); 98 $don->note = $_POST["note"]; 99 $don->pays = $_POST["pays"]; 100 $don->public = $_POST["public"]; 101 $don->projetid = $_POST["projetid"]; 102 $don->commentaire = $_POST["comment"]; 103 $don->modepaiementid = $_POST["modepaiement"]; 104 105 if ($don->create($user) > 0) 106 { 107 Header("Location: index.php"); 108 exit; 109 } 110 } 111 else 112 { 113 $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); 114 $_GET["action"] = "create"; 115 } 116 } 117 118 if ($_GET["action"] == 'delete') 119 { 120 $don = new Don($db); 121 $don->delete($_GET["rowid"]); 122 Header("Location: liste.php"); 123 exit; 124 } 125 if ($_POST["action"] == 'commentaire') 126 { 127 $don = new Don($db); 128 $don->set_commentaire($_POST["rowid"],$_POST["commentaire"]); 129 $_GET["rowid"] = $_POST["rowid"]; 130 } 131 if ($_GET["action"] == 'valid_promesse') 132 { 133 $don = new Don($db); 134 if ($don->valid_promesse($_GET["rowid"], $user->id)) 135 { 136 Header("Location: fiche.php?rowid=".$_GET["rowid"]); 137 exit; 138 } 139 } 140 if ($_GET["action"] == 'set_payed') 141 { 142 $don = new Don($db); 143 if ($don->set_paye($_GET["rowid"], $modepaiement)) 144 { 145 Header("Location: fiche.php?rowid=".$_GET["rowid"]); 146 exit; 147 } 148 } 149 if ($_GET["action"] == 'set_encaisse') 150 { 151 $don = new Don($db); 152 if ($don->set_encaisse($_GET["rowid"])) 153 { 154 Header("Location: liste.php"); 155 exit; 156 } 157 } 158 159 /* 160 * Générer ou regénérer le document 161 */ 162 if ($_GET['action'] == 'build') 163 { 164 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/dons/modules_don.php"); 165 don_create($db, $_GET['rowid']); 166 } 167 168 169 170 llxHeader(); 171 172 $html=new Form($db); 173 174 175 /* ************************************************************************** */ 176 /* */ 177 /* Création d'une fiche don */ 178 /* */ 179 /* ************************************************************************** */ 180 181 if ($_GET["action"] == 'create') 182 { 183 print_titre($langs->trans("AddDonation")); 184 185 print '<form action="fiche.php" method="post">'; 186 print '<table class="border" width="100%">'; 187 188 print '<input type="hidden" name="action" value="add">'; 189 190 print '<tr><td>'.$langs->trans("Date").'</td><td>'; 191 $html->select_date(); 192 print '</td>'; 193 194 $nbrows=11; 195 if ($conf->projet->enabled) $nbrows++; 196 197 print '<td rowspan="'.$nbrows.'" valign="top">'.$langs->trans("Comments").' :<br>'; 198 print "<textarea name=\"comment\" wrap=\"soft\" cols=\"40\" rows=\"15\"></textarea></td></tr>"; 199 print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n"; 200 201 $paiement = new Paiement($db); 202 203 $paiement->select("modepaiement","CRDT"); 204 205 print "</td></tr>\n"; 206 207 if ($conf->projet->enabled) 208 { 209 // Si module projet actif 210 print "<tr><td>".$langs->trans("Project")."</td><td>"; 211 $html->select_projects('','','',"projetid"); 212 print "</td></tr>\n"; 213 } 214 215 print "<tr><td>".$langs->trans("PublicDonation")."</td><td>"; 216 $html=new Form($db); 217 $html->selectyesno("public",1,1); 218 print "</td></tr>\n"; 219 220 $langs->load("companies"); 221 print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40"></td></tr>'; 222 print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40"></td></tr>'; 223 print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="nom" size="40"></td></tr>'; 224 print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'; 225 print '<textarea name="adresse" wrap="soft" cols="40" rows="3"></textarea></td></tr>'; 226 print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td><input type="text" name="cp" size="8"> <input type="text" name="ville" size="40"></td></tr>'; 227 print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="pays" size="40"></td></tr>'; 228 print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" size="40"></td></tr>'; 229 print "<tr>".'<td>'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 230 print "<tr>".'<td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr>'; 231 print "</table>\n"; 232 print "</form>\n"; 233 } 234 235 236 /* ************************************************************ */ 237 /* */ 238 /* Fiche don en mode edition */ 239 /* */ 240 /* ************************************************************ */ 241 242 if ($_GET["rowid"] && $_GET["action"] == 'edit') 243 { 244 $don = new Don($db); 245 $don->id = $_GET["rowid"]; 246 $don->fetch($_GET["rowid"]); 247 248 $h=0; 249 $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; 250 $head[$h][1] = $langs->trans("Donation"); 251 $hselected=$h; 252 $h++; 253 254 dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").": ".$_GET["rowid"]); 255 256 print '<form action="fiche.php" method="post">'; 257 print '<table class="border" width="100%">'; 258 259 print '<input type="hidden" name="action" value="update">'; 260 print '<input type="hidden" name="rowid" value="'.$don->id.'">'; 261 262 print "<tr>".'<td>'.$langs->trans("Date").'</td><td>'; 263 $html->select_date($don->date); 264 print '</td>'; 265 266 $nbrows=12; 267 if ($conf->projet->enabled) $nbrows++; 268 269 print '<td rowspan="'.$nbrows.'" valign="top">'.$langs->trans("Comments").' :<br>'; 270 print "<textarea name=\"comment\" wrap=\"soft\" cols=\"40\" rows=\"15\">$don->commentaire</textarea></td></tr>"; 271 272 if ($conf->projet->enabled) 273 { 274 print "<tr><td>".$langs->trans("Project")."</td><td><select name=\"projetid\">\n"; 275 $sql = "SELECT rowid, libelle FROM ".MAIN_DB_PREFIX."don_projet"; 276 $sql.= " ORDER BY rowid"; 277 if ($db->query($sql)) 278 { 279 $num = $db->num_rows(); 280 $i = 0; 281 while ($i < $num) 282 { 283 $objopt = $db->fetch_object(); 284 print "<option value=\"$objopt->rowid\">$objopt->libelle</option>\n"; 285 $i++; 286 } 287 } 288 else 289 { 290 dolibarr_print_error($db); 291 } 292 print "</select><br>"; 293 print "</td></tr>\n"; 294 } 295 296 print "<tr><td>".$langs->trans("PublicDonation")."</td><td>"; 297 $html=new Form($db); 298 $html->selectyesno("public",1,1); 299 print "</td>"; 300 print "</tr>\n"; 301 302 $langs->load("companies"); 303 print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.$don->societe.'"></td></tr>'; 304 print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.$don->prenom.'"></td></tr>'; 305 print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="nom" size="40" value="'.$don->nom.'"></td></tr>'; 306 print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'; 307 print '<textarea name="adresse" wrap="soft" cols="40" rows="'.ROWS_3.'">'.$don->adresse.'</textarea></td></tr>'; 308 print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td><input type="text" name="cp" size="8" value="'.$don->cp.'"> <input type="text" name="ville" size="40" value="'.$don->ville.'"></td></tr>'; 309 print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="pays" size="40" value="'.$don->pays.'"></td></tr>'; 310 print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" size="40" value="'.$don->email.'"></td></tr>'; 311 print "<tr>".'<td>'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.$don->amount.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 312 313 print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n"; 314 $paiement = new Paiement($db); 315 $paiement->select("modepaiement","CRDT"); 316 print "</td></tr>\n"; 317 318 print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut().'</td></tr>'; 319 320 print "<tr>".'<td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>'; 321 322 print "</table>\n"; 323 print "</form>\n"; 324 325 print "</div>\n"; 326 } 327 328 329 330 /* ************************************************************ */ 331 /* */ 332 /* Fiche don en mode visu */ 333 /* */ 334 /* ************************************************************ */ 335 if ($_GET["rowid"] && $_GET["action"] != 'edit') 336 { 337 $don = new Don($db); 338 $don->id = $_GET["rowid"]; 339 $don->fetch($_GET["rowid"]); 340 341 342 $h=0; 343 $head[$h][0] = DOL_URL_ROOT."/compta/dons/fiche.php?rowid=".$_GET["rowid"]; 344 $head[$h][1] = $langs->trans("Donation"); 345 $hselected=$h; 346 $h++; 347 348 dolibarr_fiche_head($head, $hselected, $langs->trans("Ref").": ".$_GET["rowid"]); 349 350 print "<form action=\"fiche.php\" method=\"post\">"; 351 print '<table class="border" width="100%">'; 352 353 print "<tr><td>".$langs->trans("Date")."</td><td>"; 354 print dolibarr_print_date($don->date,"%d %B %Y"); 355 print "</td>"; 356 357 $nbrows=12; 358 if ($conf->projet->enabled) $nbrows++; 359 360 print '<td rowspan="'.$nbrows.'" valign="top" width="50%">'.$langs->trans("Comments").' :<br>'; 361 print nl2br($don->commentaire).'</td></tr>'; 362 363 if ($conf->projet->enabled) 364 { 365 print "<tr>".'<td>'.$langs->trans("Project").'</td><td>'.$don->projet.'</td></tr>'; 366 } 367 368 print "<tr><td>".$langs->trans("PublicDonation")."</td><td>"; 369 print $yn[$don->public]; 370 print "</td></tr>\n"; 371 372 print "<tr>".'<td>'.$langs->trans("Company").'</td><td>'.$don->societe.'</td></tr>'; 373 print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td>'.$don->prenom.'</td></tr>'; 374 print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td>'.$don->nom.'</td></tr>'; 375 print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'.nl2br($don->adresse).'</td></tr>'; 376 print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'.$don->cp.' '.$don->ville.'</td></tr>'; 377 print "<tr>".'<td>'.$langs->trans("Country").'</td><td>'.$don->pays.'</td></tr>'; 378 print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.$don->email.'</td></tr>'; 379 print "<tr>".'<td>'.$langs->trans("Amount").'</td><td>'.price($don->amount).' '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 380 print "<tr><td>".$langs->trans("PaymentMode")."</td><td>"; 381 print $don->modepaiement; 382 print "</td></tr>\n"; 383 384 print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut().'</td></tr>'; 385 386 print "</table>\n"; 387 print "</form>\n"; 388 389 print "</div>"; 390 391 392 /** 393 * Barre d'actions 394 */ 395 print '<div class="tabsAction">'; 396 397 print '<a class="butAction" href="fiche.php?action=edit&rowid='.$don->id.'">'.$langs->trans('Edit').'</a>'; 398 399 if ($don->statut == 0) 400 { 401 print '<a class="butAction" href="fiche.php?rowid='.$don->id.'&action=valid_promesse">'.$langs->trans("ValidPromess").'</a>'; 402 } 403 404 // \todo Gérer action émettre paiement 405 if ($don->statut == 1 && $resteapayer > 0) 406 { 407 print "<a class=\"butAction\" href=\"paiement.php?facid=$facid&action=create\">".$langs->trans("DoPayment")."</a>"; 408 } 409 410 if ($don->statut == 1 && abs($resteapayer) == 0 && $don->paye == 0) 411 { 412 print "<a class=\"butAction\" href=\"fiche.php?rowid=$don->id&action=set_payed\">".$langs->trans("ClassifyPayed")."</a>"; 413 } 414 415 if ($don->statut == 2 || $don->statut == 3) 416 { 417 print ' <a class="butAction" href="fiche.php?rowid='.$don->id.'&action=build">'.$langs->trans('BuildDonationReceipt').'</a>'; 418 } 419 420 if ($don->statut == 0) 421 { 422 print "<a class=\"butActionDelete\" href=\"fiche.php?rowid=$don->id&action=delete\">".$langs->trans("Delete")."</a>"; 423 } 424 425 print "</div>"; 426 427 428 print '<table width="100%"><tr><td width="50%" valign="top">'; 429 430 /* 431 * Documents générés 432 */ 433 $filename=sanitize_string($don->id); 434 $filedir=$conf->don->dir_output . '/' . get_exdir($filename); 435 $urlsource=$_SERVER['PHP_SELF'].'?rowid='.$don->id; 436 // $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer); 437 // $delallowed=$user->rights->facture->supprimer; 438 $genallowed=0; 439 $delallowed=0; 440 441 $var=true; 442 443 print '<br>'; 444 $html->show_documents('don',$filename,$filedir,$urlsource,$genallowed,$delallowed); 445 446 print '</td><td> </td>'; 447 448 print '</tr></table>'; 449 450 } 451 452 453 454 $db->close(); 455 456 llxFooter('$Date: 2006/01/14 13:46:25 $ - $Revision: 1.30.2.1 $'); 457 458 ?>
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 |
|