* * 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"); require("../facture.class.php3"); llxHeader(); $db = new Db(); $yn[1] = "oui"; $yn[0] = "non"; if ($action == 'valid') { $fac = new Facture($db); $result = $fac->set_valid($facid, $user->id); } if ($action == 'payed') { $fac = new Facture($db); $result = $fac->set_payed($facid); } if ($action == 'delete') { $fac = new Facture($db); $fac->delete($facid); $facid = 0 ; } if ($action == 'add') { $datefacture = $db->idate(mktime(12, 0 , 0, $pmonth, $pday, $pyear)); if (! $propalid) { $facture = new Facture($db, $socid); $facture->number = $facnumber; $facture->date = $datefacture; $facture->note = $note; $facture->amount = $amount; $facture->remise = $remise; $facture->create($user->id, $statut, $note); } else { $facture = new Facture($db, $socid); $facture->number = $facnumber; $facture->date = $datefacture; $facture->note = $note; $facture->amount = $amount; $facture->remise = $remise; $facture->propalid = $propalid; if ($facture->create($user->id) ) { /* * * Génération du PDF * */ // print "
"; // $command = "export DBI_DSN=\"".$GLOBALS["DBI"]."\" "; // $command .= " ; ../../scripts/facture-tex.pl --facture=$facid --pdf --ps" ; // $output = system($command); // print "
command : $command
";
}
else
{
print "
Erreur : la facture n'a pas été créée, vérifier le numéro !"; print "
Retour à la propal"; print $db->error(); } } $facid = $facid; $action = ''; } /* * * Mode creation * * * */ if ($action == 'create') { print_titre("Emettre une facture"); if ($propalid) { $sql = "SELECT s.nom, s.prefix_comm, s.idp, p.price, p.remise, p.tva, p.total, p.ref, ".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst"; $sql .= " FROM societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; $sql .= " AND p.rowid = $propalid"; } else { $sql = "SELECT s.nom, s.prefix_comm, s.idp "; $sql .= "FROM societe as s "; $sql .= "WHERE s.idp = $socidp"; } if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { $obj = $db->fetch_object(0); $numfa = "F-" . $obj->prefix_comm . "-" . strftime("%y%m%d", time()); print "