* * 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("../lib/CMailFile.class.php3"); /* * Modules optionnels */ require("../project.class.php3"); require("../propal.class.php3"); require("../actioncomm.class.php3"); /* * */ llxHeader(); $db = new Db(); if ($action == 'setstatut') { /* * Cloture de la propale */ $propal = new Propal($db); $propal->id = $propalid; $propal->cloture($user->id, $statut, $note); } elseif ( $action == 'delete' ) { $sql = "DELETE FROM llx_propal WHERE rowid = $propalid;"; if ( $db->query($sql) ) { $sql = "DELETE FROM llx_propaldet WHERE fk_propal = $propalid ;"; if ( $db->query($sql) ) { print "Propal supprimée"; } else { print $db->error(); print "

$sql"; } } else { print $db->error(); print "

$sql"; } $propalid = 0; $brouillon = 1; } /* * * Mode fiche * * */ if ($propalid) { $propal = new Propal($db); $propal->fetch($propalid); if ($valid == 1) { $propal->valid($user->id); } /* * */ print ""; print ""; print "
Proposition commerciale : $propal->ref
"; /* * */ $sql = "SELECT s.nom, s.idp, p.price, p.fk_projet,p.remise, p.tva, p.total, p.ref,".$db->pdate("p.datep")." as dp, c.id as statut, c.label as lst, p.note, x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture"; $sql .= " FROM societe as s, llx_propal as p, c_propalst as c, socpeople as x"; $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = $propalid"; $result = $db->query($sql); if ( $result ) { $obj = $db->fetch_object( 0 ); if ($db->num_rows()) { $color1 = "#e0e0e0"; print ""; print ''; print ""; // print ''; if ($obj->fk_projet) { $projet = new Project($db); $projet->fetch($obj->fk_projet); print ''; } print ""; /* * */ print ""; /* * */ print ""; /* * */ $totalht = $propal->price - $propal->remise ; print ""; /* * */ print ''; /* * */ print ""; $file = $conf->propal->outputdir. "/$obj->ref/$obj->ref.pdf"; if (file_exists($file)) { print ''; } print ''; /* * */ print ""; print ''; print "
'.translate("Company").''.$obj->nom.'Note :
". nl2br($obj->note)."
'.translate("Date").''.strftime("%A %d %B %Y",$obj->dp).'
Projet'; print ''; print $projet->title.'
Destinataire$obj->firstname $obj->name <$obj->email>
Montant HT".price($obj->price)." euros
Remise".price($obj->remise)." euros
Total HT".price($totalht)." euros
Auteur'; $author = new User($db, $obj->fk_user_author); $author->fetch(''); print $author->fullname.'
PDF'.$obj->ref.'.pdf
Statut :$obj->lst
"; if ($action == 'statut') { print "

"; print ""; print "'; print '

'; print "
"; } print ""; /* * */ print "
"; /* * Factures associees */ $sql = "SELECT f.facnumber, f.amount,".$db->pdate("f.datef")." as df, f.rowid as facid, f.author, f.paye"; $sql .= " FROM llx_facture as f, llx_fa_pr as fp WHERE fp.fk_facture = f.rowid AND fp.fk_propal = $propalid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; $total = 0; print "
Facture(s) associée(s)"; print ""; print ""; print ""; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; print ''; print ""; $total = $total + $objp->amount; $i++; } print "\n"; print "
NumDateAuteurPrix
facid\">$objp->facnumber"; if ($objp->paye) { print " (payée)"; } print "".strftime("%d %B %Y",$objp->df)."$objp->author'.price($objp->amount).'
Total : $total Euros HT
"; $db->free(); } print "
"; /* * Actions */ print "

"; if ($obj->statut == 2) { print '"; } else { print ''; } print ""; if ($obj->statut == 2) { print ""; } else { print ""; } print "
'; print "Emettre une facture--[Facturée]-
"; /* * */ } else { print "Num rows = " . $db->num_rows(); print "

$sql"; } /* * Voir le suivi des actions * * * */ if ($suivi) { $validor = new User($db, $obj->fk_user_valid); $validor->fetch(''); $cloturor = new User($db, $obj->fk_user_cloture); $cloturor->fetch(''); print '

Cacher le suivi des actions '; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
 NomDate
Création'.$author->fullname.''.$obj->datec.'
Validation'.$validor->fullname.' '.$obj->date_valid.' 
Cloture'.$cloturor->fullname.' '.$obj->date_cloture.' 
'; } else { print '

Voir le suivi des actions '; } } else { print $db->error(); print "

$sql"; } /* * * * */ } else { /* * * * Mode Liste des propales * * */ if ($sortfield == "") { $sortfield="lower(p.label)"; } if ($sortorder == "") { $sortorder="ASC"; } $yn["t"] = "oui"; $yn["f"] = "non"; if ($page == -1) { $page = 0 ; } $limit = 26; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; print ""; print ""; print "
Propositions commerciales
"; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; $sql .= " FROM societe as s, llx_propal as p, c_propalst as c "; $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut in(2,4)"; if ($socidp) { $sql .= " AND s.idp = $socidp"; } if ($viewstatut <> '') { $sql .= " AND c.id = $viewstatut"; } if ($month > 0) { $sql .= " AND date_format(p.datep, '%Y-%m') = '$year-$month'"; } if ($year > 0) { $sql .= " AND date_format(p.datep, '%Y') = $year"; } $sql .= " ORDER BY p.fk_statut, datep DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print ""; $oldstatut = -1; $subtotal = 0; while ($i < $num) { $objp = $db->fetch_object( $i); if ($objp->statut <> $oldstatut ) { $oldstatut = $objp->statut; if ($i > 0) { print "\n"; print "\n"; } $subtotal = 0; print ''; print ""; print ""; print ""; print ""; print "'; print "\n"; $var=True; } $var=!$var; print ""; print "\n"; print "\n"; $now = time(); $lim = 3600 * 24 * 15 ; if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) { print ""; } else { print ""; } print "\n"; print "\n"; print "\n"; print "\n"; $total = $total + $objp->price; $subtotal = $subtotal + $objp->price; $i++; } print "\n"; print "\n"; print ""; print ""; print ""; print "
Total : ".price($subtotal)."Euros HT
RéfSociétéDatePrixStatut statutid\">"; print '
propalid\">$objp->refidp\">$objp->nom > 15 jours "; $y = strftime("%Y",$objp->dp); $m = strftime("%m",$objp->dp); print strftime("%d",$objp->dp)."\n"; print " "; print strftime("%B",$objp->dp)."\n"; print " "; print strftime("%Y",$objp->dp)."".price($objp->price)."$objp->statut
Total : ".price($subtotal)."Euros HT
$i propalesTotal : ".price($total)."Euros HT
"; $db->free(); } else { print $db->error(); } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>