* * 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("../propal.class.php3"); require("../facture.class.php3"); llxHeader(); $db = new Db(); $mesg = ''; if ($action == 'add') { $product = new Product($db); $product->ref = $HTTP_POST_VARS["ref"]; $product->libelle = $HTTP_POST_VARS["libelle"]; $product->price = $HTTP_POST_VARS["price"]; $product->tva_tx = $HTTP_POST_VARS["tva_tx"]; $product->description = $HTTP_POST_VARS["desc"]; $id = $product->create($user); $action = ''; } if ($action == 'addinpropal') { $propal = New Propal($db); $propal->fetch($HTTP_POST_VARS["propalid"]); $propal->insert_product($id, $HTTP_POST_VARS["qty"]); $action = ''; $mesg = 'Produit ajouté à la proposition '; $mesg .= ''.$propal->ref.''; } if ($action == 'addinfacture') { $product = new Product($db); $result = $product->fetch($id); $facture = New Facture($db); $facture->fetch($HTTP_POST_VARS["factureid"]); $facture->addline($HTTP_POST_VARS["factureid"], $product->description, $product->price, $HTTP_POST_VARS["qty"], $product->tva_tx, $id); $action = ''; $mesg = 'Produit ajouté à la facture '; $mesg .= ''.$facture->ref.''; } if ($action == 'update' && $cancel <> 'Annuler') { $product = new Product($db); $product->ref = $HTTP_POST_VARS["ref"]; $product->libelle = $HTTP_POST_VARS["libelle"]; $product->price = $HTTP_POST_VARS["price"]; $product->tva_tx = $HTTP_POST_VARS["tva_tx"]; $product->description = $HTTP_POST_VARS["desc"]; $product->envente = $HTTP_POST_VARS["statut"]; if ( $product->update($id, $user)) { $action = ''; $mesg = 'Fiche mise à jour'; } else { $action = 'edit'; $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; } } /* * * */ if ($action == 'create') { print "
\n"; print ""; print '
Nouveau produit

'; print ''; print ""; print ''; print ''; print ''; print ''; print ""; print ''; print '
Référence
Libellé
Prix de vente
Taux TVA'; $html = new Form($db); print $html->select_tva("tva_tx"); print ' %
Description"; print '
 
'; print '
'; } else { if ($id) { $product = new Product($db); $result = $product->fetch($id); if ( $result ) { print ''; print ''; print ''; print ''; print ''; print ''; print '
Réf :  
Libellé :   
'; print_fiche_titre('Fiche produit : '.$product->ref, $mesg); print ''; print ""; print ''; print ''; print ""; print ''; print ''; print ''; print ''; print ""; print "
Référence'.$product->ref.''; if ($product->envente) { print "En vente"; } else { print "Cet article n'est pas en vente"; } print '
Libellé$product->labelStatistiques
Prix de vente'.price($product->price).''; print "Propositions commerciales : ".$product->count_propale(); print "
Proposé à ".$product->count_propale_client()." clients"; print "
Factures : ".$product->count_facture(); print '
Taux TVA'.$product->tva_tx.' %
Description".nl2br($product->description)."
"; } if ($action == 'edit') { print '
Edition de la fiche produit : '.$product->ref.'

'; print "
\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ""; print ''; print '
Référence
Libellé
Prix de vente
Taux TVA'; $html = new Form($db); print $html->select_tva("tva_tx", $product->tva_tx); print '
Statut'; print '
Description"; print '
  '; print '
'; print '
'; } } else { print "Error"; } } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print '
'; print ''; print ''; print ''; if ($action == 'create') { print ''; } else { print ''; } print ''; print '
----[Editer]-

'; if ($id && $action == '' && $product->envente) { $htmls = new Form($db); $propal = New Propal($db); print ''; print ''; print ''; print ''; print '
'; print_titre("Ajouter ma proposition"); print ''; print_titre("Ajouter aux autres propositions"); print '
'; $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price - p.remise as price, p.ref,".$db->pdate("p.datep")." as dp"; $sql .= " FROM llx_societe as s, llx_propal as p"; $sql .=" WHERE p.fk_soc = s.idp AND p.fk_statut = 0 AND p.fk_user_author = ".$user->id; $sql .= " ORDER BY p.datec DESC, tms DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print ''; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; print ''; print ''; print '"; print ''; $i++; } print "
propalid\">$objp->refidp\">$objp->nom". strftime("%d %B %Y",$objp->dp)."
'; print ''; print ''; print ''; print "
"; $db->free(); } print '
'; $otherprop = $propal->liste_array(1, '<>'.$user->id); if (sizeof($otherprop)) { print '
'; print ''; print ''; print ""; print '
Autres Propositions"; $htmls->select_array("propalid", $otherprop); print ''; print ''; print ''; print ''; print "
'; } print '
'; print_titre("Ajouter ma facture"); print ''; print_titre("Ajouter aux autres factures"); print '
'; $sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df"; $sql .= " FROM llx_societe as s, llx_facture as f"; $sql .=" WHERE f.fk_soc = s.idp AND f.fk_statut = 0 AND f.fk_user_author = ".$user->id; $sql .= " ORDER BY f.datec DESC, f.rowid DESC"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; print ''; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; print ''; print ''; print '"; print ''; $i++; } print "
factureid\">$objp->facnumberidp\">$objp->nom". strftime("%d %B %Y",$objp->df)."
'; print ''; print ''; print ''; print "
"; $db->free(); } else { print $db->error() . "
" . $sql; } print '
'; print '
'; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>