mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
679 lines
23 KiB
PHP
679 lines
23 KiB
PHP
<?PHP
|
||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||
*
|
||
* 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.php");
|
||
require("../propal.class.php");
|
||
require("../facture.class.php");
|
||
|
||
$user->getrights('produit');
|
||
$user->getrights('propale');
|
||
$user->getrights('facture');
|
||
$mesg = '';
|
||
|
||
if (!$user->rights->produit->lire)
|
||
{
|
||
accessforbidden();
|
||
}
|
||
|
||
llxHeader("","","Fiche produit");
|
||
|
||
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->type = $HTTP_POST_VARS["type"];
|
||
$product->envente = $HTTP_POST_VARS["statut"];
|
||
$product->description = $HTTP_POST_VARS["desc"];
|
||
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
||
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
||
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
|
||
|
||
$id = $product->create($user);
|
||
$action = '';
|
||
}
|
||
|
||
if ($action == 'addinpropal')
|
||
{
|
||
$propal = New Propal($db);
|
||
|
||
$propal->fetch($HTTP_POST_VARS["propalid"]);
|
||
$result = $propal->insert_product($id, $HTTP_POST_VARS["qty"], $HTTP_POST_VARS["remise_percent"]);
|
||
if ( $result < 0)
|
||
{
|
||
$mesg = "erreur $result";
|
||
}
|
||
else
|
||
{
|
||
$mesg = ucfirst($types[$type]) . ' ajout<75> <20> la proposition ';
|
||
$mesg .= '<a href="../comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
|
||
}
|
||
$action = '';
|
||
}
|
||
|
||
if ($HTTP_POST_VARS["action"] == 'addinfacture' &&
|
||
( $user->rights->facture->modifier || $user->rights->facture->creer))
|
||
{
|
||
$product = new Product($db);
|
||
$result = $product->fetch($id);
|
||
|
||
$facture = New Facture($db);
|
||
|
||
$facture->fetch($HTTP_POST_VARS["factureid"]);
|
||
$facture->addline($HTTP_POST_VARS["factureid"],
|
||
addslashes($product->libelle),
|
||
$product->price,
|
||
$HTTP_POST_VARS["qty"],
|
||
$product->tva_tx, $id);
|
||
|
||
$action = '';
|
||
$mesg = 'Produit ajout<75> <20> la facture ';
|
||
$mesg .= '<a href="../compta/facture.php?facid='.$facture->id.'">'.$facture->ref.'</a>';
|
||
}
|
||
|
||
if ($HTTP_POST_VARS["action"] == 'add_fourn' && $cancel <> 'Annuler')
|
||
{
|
||
$product = new Product($db);
|
||
if( $product->fetch($id) )
|
||
{
|
||
if ($product->add_fournisseur($user, $HTTP_POST_VARS["id_fourn"], $HTTP_POST_VARS["ref_fourn"]) > 0)
|
||
{
|
||
$action = '';
|
||
$mesg = 'Founisseur ajout<75>';
|
||
}
|
||
else
|
||
{
|
||
$action = '';
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
if ($HTTP_POST_VARS["action"] == 'update' &&
|
||
$cancel <> 'Annuler' &&
|
||
( $user->rights->produit->modifier || $user->rights->produit->creer))
|
||
{
|
||
$product = new Product($db);
|
||
if ($product->fetch($id))
|
||
{
|
||
|
||
$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"];
|
||
$product->seuil_stock_alerte = $HTTP_POST_VARS["seuil_stock_alerte"];
|
||
$product->duration_value = $HTTP_POST_VARS["duration_value"];
|
||
$product->duration_unit = $HTTP_POST_VARS["duration_unit"];
|
||
|
||
if ($product->check())
|
||
{
|
||
if ( $product->update($id, $user))
|
||
{
|
||
$action = '';
|
||
$mesg = 'Fiche mise <20> jour';
|
||
}
|
||
else
|
||
{
|
||
$action = 're-edit';
|
||
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$action = 're-edit';
|
||
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
|
||
}
|
||
}
|
||
}
|
||
|
||
if ($HTTP_POST_VARS["action"] == 'update_price' &&
|
||
$cancel <> 'Annuler' &&
|
||
( $user->rights->produit->modifier || $user->rights->produit->creer))
|
||
{
|
||
$product = new Product($db);
|
||
$result = $product->fetch($id);
|
||
$product->price = $HTTP_POST_VARS["price"];
|
||
|
||
if ( $product->update_price($id, $user) > 0 )
|
||
{
|
||
$action = '';
|
||
$mesg = 'Fiche mise <20> jour';
|
||
}
|
||
else
|
||
{
|
||
$action = 'edit_price';
|
||
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $product->mesg_error;
|
||
}
|
||
}
|
||
|
||
|
||
if ($cancel == 'Annuler')
|
||
{
|
||
$action = '';
|
||
}
|
||
/*
|
||
*
|
||
*
|
||
*/
|
||
if ($action == 'create')
|
||
{
|
||
print "<form action=\"$PHP_SELF?type=$type\" method=\"post\">\n";
|
||
print "<input type=\"hidden\" name=\"action\" value=\"add\">\n";
|
||
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
|
||
print '<div class="titre">Nouveau '.$types[$type].'</div><br>'."\n";
|
||
|
||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||
print '<tr>';
|
||
print '<td>R<>f<EFBFBD>rence</td><td><input name="ref" size="20" value=""></td></tr>';
|
||
print "<tr>".'<td>Libell<6C></td><td><input name="libelle" size="40" value=""></td></tr>';
|
||
print "<tr>".'<td>Prix de vente</td><TD><input name="price" size="10" value=""></td></tr>';
|
||
print "<tr>".'<td>Taux TVA</td><TD>';
|
||
$html = new Form($db);
|
||
print $html->select_tva("tva_tx");
|
||
print '</td></tr>';
|
||
print '<tr><td>Statut</td><td>';
|
||
print '<select name="statut">';
|
||
print '<option value="1">En vente</option>';
|
||
print '<option value="0" SELECTED>Hors Vente</option>';
|
||
print '</td></tr>';
|
||
|
||
if ($_GET["type"] == 0 && defined("MAIN_MODULE_STOCK"))
|
||
{
|
||
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||
print '<input name="seuil_stock_alerte" size="4" value="0">';
|
||
print '</td></tr>';
|
||
}
|
||
else
|
||
{
|
||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||
}
|
||
print '<tr><td valign="top">Description</td><td>';
|
||
print '<textarea name="desc" rows="8" cols="50">';
|
||
print "</textarea></td></tr>";
|
||
if ($_GET["type"] == 1)
|
||
{
|
||
print "<tr>".'<td>Dur<75>e</td><TD><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'">';
|
||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
|
||
print '</td></tr>';
|
||
}
|
||
|
||
print "<tr>".'<td> </td><td><input type="submit" value="Cr<43>er"></td></tr>';
|
||
print '</table>';
|
||
print '</form>';
|
||
}
|
||
else
|
||
{
|
||
if ($id)
|
||
{
|
||
if ($action <> 're-edit')
|
||
{
|
||
$product = new Product($db);
|
||
$result = $product->fetch($id);
|
||
}
|
||
|
||
if ( $result )
|
||
{
|
||
if ($action <> 'edit' && $action <> 're-edit')
|
||
{
|
||
print '<table border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||
print '<tr class="liste_titre">';
|
||
print '<td><form action="liste.php?type='.$product->type.'" method="post">';
|
||
print 'R<>f : <input class="flat" type="text" size="10" name="sref"> <input class="flat" type="submit" value="go">';
|
||
print '</form></td><td><form action="liste.php" method="post">';
|
||
print 'Libell<6C> : <input class="flat" type="text" size="20" name="snom"> <input class="flat" type="submit" value="go">';
|
||
print '</form></td><td> </td></tr></table>';
|
||
|
||
|
||
print_fiche_titre('Fiche '.$types[$product->type].' : '.$product->ref, $mesg);
|
||
|
||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||
print "<tr>";
|
||
print '<td width="20%">R<>f<EFBFBD>rence</td><td width="40%">'.$product->ref.'</td>';
|
||
print '<td width="40%">';
|
||
if ($product->envente)
|
||
{
|
||
print "En vente";
|
||
}
|
||
else
|
||
{
|
||
print "<b>Cet article n'est pas en vente</b>";
|
||
}
|
||
print '</td></tr>';
|
||
print "<tr><td>Libell<6C></td><td>$product->libelle</td>";
|
||
print '<td><a href="stats/fiche.php?id='.$id.'">Statistiques</a></td></tr>';
|
||
print '<tr><td>Prix de vente</td><td>'.price($product->price).'</td>';
|
||
print '<td valign="top" rowspan="4">';
|
||
print 'Fournisseurs [<a href="fiche.php?id='.$id.'&action=ajout_fourn">Ajouter</a>]';
|
||
|
||
$sql = "SELECT s.nom, s.idp";
|
||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||
$sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product =$id";
|
||
$sql .= " ORDER BY lower(s.nom)";
|
||
|
||
if ( $db->query($sql) )
|
||
{
|
||
$num = $db->num_rows();
|
||
$i = 0;
|
||
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||
$var=True;
|
||
while ($i < $num)
|
||
{
|
||
$objp = $db->fetch_object( $i);
|
||
$var=!$var;
|
||
print "<TR $bc[$var]>";
|
||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.$objp->nom.'</a></td></tr>';
|
||
$i++;
|
||
}
|
||
print '</table>';
|
||
$db->free();
|
||
}
|
||
|
||
print '</td></tr>';
|
||
|
||
print '<tr><td>Taux TVA</td><TD>'.$product->tva_tx.' %</td></tr>';
|
||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||
{
|
||
print '<tr><td><a href="stock/product.php?id='.$product->id.'">Stock</a></td>';
|
||
if ($product->no_stock)
|
||
{
|
||
print "<td>Pas de d<>finition de stock pour ce produit";
|
||
}
|
||
else
|
||
{
|
||
if ($product->stock_reel <= $product->seuil_stock_alerte)
|
||
{
|
||
print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte;
|
||
}
|
||
else
|
||
{
|
||
print "<td>".$product->stock_reel;
|
||
}
|
||
}
|
||
print '</td></tr>';
|
||
}
|
||
print "<tr><td valign=\"top\">Description</td><td>".nl2br($product->description)."</td></tr>";
|
||
|
||
if ($product->type == 1)
|
||
{
|
||
print "<tr>".'<td>Dur<75>e</td><TD>'.$product->duration_value.' ';
|
||
if ($product->duration_value > 1)
|
||
{
|
||
$plu = "s";
|
||
}
|
||
switch ($product->duration_unit)
|
||
{
|
||
case "d":
|
||
print "jour$plu ";
|
||
break;
|
||
case "w":
|
||
print "semaine$plu ";
|
||
break;
|
||
case "m":
|
||
print 'mois ';
|
||
break;
|
||
case "y":
|
||
print "an$plu ";
|
||
break;
|
||
}
|
||
print '</td></tr>';
|
||
}
|
||
print "</table>";
|
||
}
|
||
|
||
if ($action == 'edit_price' && $user->rights->produit->creer)
|
||
{
|
||
print '<hr><div class="titre">Nouveau prix</div><br>';
|
||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||
print '<input type="hidden" name="action" value="update_price">';
|
||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||
print '<tr><td width="20%">Prix de vente</td><td><input name="price" size="10" value="'.price($product->price).'"></td></tr>';
|
||
print '<tr><td colspan="3" align="center"><input type="submit" value="Enregistrer"> ';
|
||
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
|
||
print '</table>';
|
||
print '</form>';
|
||
}
|
||
/*
|
||
* Ajouter un fournisseur
|
||
*
|
||
*/
|
||
if ($action == 'ajout_fourn' && $user->rights->produit->creer)
|
||
{
|
||
print_titre ("Ajouter un founisseur");
|
||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||
print '<input type="hidden" name="action" value="add_fourn">';
|
||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4"><tr>';
|
||
print '<td>Fournisseurs</td><td><select name="id_fourn">';
|
||
|
||
$sql = "SELECT s.idp, s.nom, s.ville FROM ".MAIN_DB_PREFIX."societe as s WHERE s.fournisseur=1";
|
||
$sql .= " ORDER BY lower(s.nom)";
|
||
|
||
if ($db->query($sql))
|
||
{
|
||
$num = $db->num_rows();
|
||
$i = 0;
|
||
while ($i < $num)
|
||
{
|
||
$obj = $db->fetch_object( $i);
|
||
print '<option value="'.$obj->idp.'">'.$obj->nom . " (".$obj->ville.")";
|
||
$i++;
|
||
}
|
||
}
|
||
print '</select></td><td>R<>f<EFBFBD>rence</td><td><input name="ref_fourn" size="25" value=""></td></tr>';
|
||
print '<tr><td colspan="4" align="center"><input type="submit" value="Enregistrer"> ';
|
||
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
|
||
print '</table>';
|
||
print '</form>';
|
||
}
|
||
|
||
}
|
||
|
||
|
||
if (($action == 'edit' || $action == 're-edit') && $user->rights->produit->creer)
|
||
{
|
||
print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, $mesg);
|
||
|
||
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
|
||
print '<input type="hidden" name="action" value="update">';
|
||
|
||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||
print "<tr>".'<td width="20%">R<>f<EFBFBD>rence</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
||
print '<td>Libell<6C></td><td colspan="2"><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||
|
||
print "<tr>".'<td>Taux TVA</td><td colspan="2">';
|
||
$html = new Form($db);
|
||
print $html->select_tva("tva_tx", $product->tva_tx);
|
||
print '</td></tr>';
|
||
print "<tr>".'<td>Statut</td><td colspan="2">';
|
||
print '<select name="statut">';
|
||
if ($product->envente)
|
||
{
|
||
print '<option value="1" SELECTED>En vente</option>';
|
||
print '<option value="0">Hors Vente</option>';
|
||
}
|
||
else
|
||
{
|
||
print '<option value="1">En vente</option>';
|
||
print '<option value="0" SELECTED>Hors Vente</option>';
|
||
}
|
||
print '</td></tr>';
|
||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||
{
|
||
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
|
||
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||
print '</td></tr>';
|
||
}
|
||
else
|
||
{
|
||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||
}
|
||
print "<tr>".'<td valign="top">Description</td><td colspan="2">';
|
||
print '<textarea name="desc" rows="8" cols="50">';
|
||
print $product->description;
|
||
print "</textarea></td></tr>";
|
||
|
||
if ($product->type == 1)
|
||
{
|
||
print "<tr>".'<td>Dur<75>e</td><td colspan="2"><input name="duration_value" size="6" maxlength="5" value="'.$product->duration_value.'">';
|
||
switch ($product->duration_unit)
|
||
{
|
||
case "d":
|
||
print '<input name="duration_unit" type="radio" value="d" checked>jour ';
|
||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
|
||
break;
|
||
case "w":
|
||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||
print '<input name="duration_unit" type="radio" value="w" checked>semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
|
||
break;
|
||
case "m":
|
||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m" checked>mois ';
|
||
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
|
||
break;
|
||
case "y":
|
||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||
print '<input name="duration_unit" type="radio" value="y" checked>ann<6E>e';
|
||
break;
|
||
default:
|
||
print '<input name="duration_unit" type="radio" value="d">jour ';
|
||
print '<input name="duration_unit" type="radio" value="w">semaine ';
|
||
print '<input name="duration_unit" type="radio" value="m">mois ';
|
||
print '<input name="duration_unit" type="radio" value="y">ann<6E>e';
|
||
break;
|
||
}
|
||
print '</td></tr>';
|
||
}
|
||
|
||
print "<tr>".'<td colspan="3" align="center"><input type="submit" value="Enregistrer"> ';
|
||
print '<input type="submit" name="cancel" value="Annuler"></td></tr>';
|
||
print '</table>';
|
||
print '</form>';
|
||
}
|
||
}
|
||
else
|
||
{
|
||
print "Error";
|
||
}
|
||
}
|
||
|
||
/* ************************************************************************** */
|
||
/* */
|
||
/* Barre d'action */
|
||
/* */
|
||
/* ************************************************************************** */
|
||
|
||
print '<br><table id="actions" width="100%" cellspacing="0" cellpadding="3">';
|
||
if ($action == '')
|
||
{
|
||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||
{
|
||
print '<td width="20%" align="center"><a href="fiche.php?action=edit_price&id='.$id.'">Changer le prix</a></td>';
|
||
}
|
||
else
|
||
{
|
||
print '<td width="20%" align="center">-</td>';
|
||
}
|
||
}
|
||
else
|
||
{
|
||
print '<td width="20%" align="center">-</td>';
|
||
}
|
||
print '<td width="20%" align="center">-</td>';
|
||
|
||
if ($action == '')
|
||
{
|
||
if ($user->rights->produit->modifier || $user->rights->produit->creer)
|
||
{
|
||
print '<td width="20%" align="center"><a href="fiche.php?action=edit&id='.$id.'">Editer</a></td>';
|
||
}
|
||
else
|
||
{
|
||
print '<td width="20%" align="center">-</td>';
|
||
}
|
||
}
|
||
else
|
||
{
|
||
print '<td width="20%" align="center">-</td>';
|
||
}
|
||
print '<td width="20%" align="center">-</td>';
|
||
if ($product->type == 0 && defined("MAIN_MODULE_STOCK"))
|
||
{
|
||
print '<td width="20%" align="center"><a href="stock/product.php?id='.$id.'&action=correction">Correction stock</a></td>';
|
||
}
|
||
else
|
||
{
|
||
print '<td width="20%" align="center">-</td>';
|
||
}
|
||
|
||
print '</table><br>';
|
||
|
||
if ($id && $action == '' && $product->envente)
|
||
{
|
||
|
||
$htmls = new Form($db);
|
||
$propal = New Propal($db);
|
||
|
||
print '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
|
||
if($user->rights->propale->creer)
|
||
{
|
||
print "<tr>".'<td width="50%" valign="top">';
|
||
print_titre("Ajouter <20> ma proposition") . '</td>';
|
||
|
||
print '<td width="50%" valign="top">';
|
||
print_titre("Ajouter aux autres propositions") . '</td>';
|
||
|
||
print '</tr>';
|
||
print "<tr>".'<td width="50%" valign="top">';
|
||
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.ref,".$db->pdate("p.datep")." as dp";
|
||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."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 '<TABLE border="0" width="100%" cellspacing="0" cellpadding="4">';
|
||
$var=True;
|
||
while ($i < $num)
|
||
{
|
||
$objp = $db->fetch_object( $i);
|
||
$var=!$var;
|
||
print "<TR $bc[$var]>";
|
||
print "<td><a href=\"../comm/propal.php?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
|
||
print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
|
||
print "<td>". strftime("%d %B %Y",$objp->dp)."</td>\n";
|
||
print '<form method="POST" action="fiche.php?id='.$id.'">';
|
||
print '<input type="hidden" name="action" value="addinpropal">';
|
||
print '<td><input type="hidden" name="propalid" value="'.$objp->propalid.'">';
|
||
print '<input type="text" name="qty" size="3" value="1"> Rem.';
|
||
print '<input type="text" name="remise_percent" size="3" value="0"> %';
|
||
print " ".$product->stock_proposition;
|
||
print '</td><td>';
|
||
print '<input type="submit" value="Ajouter">';
|
||
print "</td>";
|
||
print '</form></tr>';
|
||
$i++;
|
||
}
|
||
print "</table>";
|
||
$db->free();
|
||
}
|
||
|
||
print '</td>';
|
||
|
||
if($user->rights->propale->creer)
|
||
{
|
||
print '<td width="50%" valign="top">';
|
||
|
||
$otherprop = $propal->liste_array(1, '<>'.$user->id);
|
||
if (sizeof($otherprop))
|
||
{
|
||
print '<form method="POST" action="fiche.php?id='.$id.'">';
|
||
print '<input type="hidden" name="action" value="addinpropal">';
|
||
print '<table class="border" width="100%" cellpadding="3" cellspacing="0">';
|
||
print "<tr>".'<td>Autres Propositions</td><td>';
|
||
$htmls->select_array("propalid", $otherprop);
|
||
print '</td><td>';
|
||
print '<input type="text" name="qty" size="3" value="1"> Rem.';
|
||
print '<input type="text" name="remise_percent" size="3" value="0"> %';
|
||
print '</td><td>';
|
||
print '<input type="submit" value="Ajouter">';
|
||
print '</td></tr>';
|
||
print '</table></form>';
|
||
}
|
||
print '</td>';
|
||
}
|
||
print '</tr>';
|
||
}
|
||
|
||
if($user->rights->facture->creer)
|
||
{
|
||
print "<tr>".'<td width="50%" valign="top">';
|
||
print_titre("Ajouter <EFBFBD> ma facture");
|
||
print '</td><td width="50%" valign="top">';
|
||
print_titre("Ajouter aux autres factures");
|
||
print '</td></tr>';
|
||
print "<tr>".'<td width="50%" valign="top">';
|
||
$sql = "SELECT s.nom, s.idp, f.rowid as factureid, f.facnumber,".$db->pdate("f.datef")." as df";
|
||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."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 '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||
$var=True;
|
||
while ($i < $num)
|
||
{
|
||
$objp = $db->fetch_object( $i);
|
||
|
||
$var=!$var;
|
||
print "<TR $bc[$var]>";
|
||
print "<td><a href=\"../compta/facture.php?facid=$objp->factureid\">$objp->facnumber</a></TD>\n";
|
||
print "<td><a href=\"../comm/fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
|
||
print "<td>". strftime("%d %B %Y",$objp->df)."</td>\n";
|
||
print '<form method="POST" action="fiche.php?id='.$id.'">';
|
||
print '<input type="hidden" name="action" value="addinfacture">';
|
||
print '<td><input type="hidden" name="factureid" value="'.$objp->factureid.'">';
|
||
print '<input type="text" name="qty" size="3" value="1"> Rem.';
|
||
print '<input type="text" name="remise_percent" size="3" value="0"> %';
|
||
print '</td><td>';
|
||
print '<input type="submit" value="Ajouter">';
|
||
print "</td>";
|
||
print '</form></tr>';
|
||
$i++;
|
||
}
|
||
print "</table>";
|
||
$db->free();
|
||
}
|
||
else
|
||
{
|
||
print $db->error() . "<br>" . $sql;
|
||
}
|
||
print '</td><td width="50%" valign="top">';
|
||
print '</td></tr></table>';
|
||
}
|
||
}
|
||
|
||
|
||
$db->close();
|
||
|
||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||
?>
|