[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/scripts/ -> file-dons.pl (source)

   1  #!/usr/bin/perl
   2  
   3  # Copyright (C) 2002 Rodolphe Quiedeville
   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  # Write a file with the 3 values
  20  # Remember to : export DBI_DSN="dbi:mysql:dbname=dolibarr"
  21  #
  22  # Usage : file-dons.pl PROJECTID FILE_TO_WRITE [DBI_DSN]
  23  #
  24  use DBI;
  25  
  26  my $dbh = DBI->connect($ARGV[2]) || die $DBI::errstr ;
  27  
  28  my $sql = 'SELECT sum(amount),fk_statut FROM llx_don';
  29  $sql .= ' WHERE fk_statut in (1,2,3) AND fk_don_projet = '.$ARGV[0];
  30  $sql .= ' GROUP BY fk_statut ASC ;';
  31  
  32  my $sth = $dbh->prepare("$sql") || die $dbh->errstr ;
  33  $sth->execute;
  34  
  35  open (FH, ">$ARGV[1]") || die "can't open $ARGV[1]: $!";    
  36  
  37  while (my @row = $sth->fetchrow_array ) 
  38  {    
  39      print FH int($row[0]) . "\n";
  40  }
  41  
  42  close (FH);
  43  
  44  $dbh->disconnect();
  45  


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics