On Sat, 27 Jan 2007 15:41:33 +0100 (CET)
Régis Houssin <[EMAIL PROTECTED]> wrote:
> Bonjour Franky,
>
> j'ai inclu tes modifications dans le cvs
>
>
> merci
> Régis
un grand merci!
En attach tu trouve des modifs pour la partie fournisseurs. De nouveau
rien de special, mais justement j'ai change le code:
$value_label = $fac_ori->lignes[$i-1][0];
par
$value_label = $fac_ori->lignes[$i-1]->description;
(et la meme chose pour [1],[2],...)
Pour cela, j'ai remplace en fournisseur.facture.class.php le code
$obj = $this->db->fetch_object($resql_rows);
$this->lignes[$i][0] = $obj->description;
$this->lignes[$i][1] = $obj->pu_ht;
$this->lignes[$i][2] = $obj->tva_taux;
$this->lignes[$i][3] = $obj->qty;
$this->lignes[$i][4] = $obj->total_ht;
$this->lignes[$i][5] = $obj->tva;
$this->lignes[$i][6] = $obj->total_ttc;
$this->lignes[$i][7] = $obj->rowid;
$this->lignes[$i][8] = $obj->total_tva;
par
$this->lignes[$i] =
$this->db->fetch_object($resql_rows);
(peut-etre encore mieux est le style:
$this->lignes[$i]->description=$obj->description, comme dans
product.class.php, mais ca je laisse a toi pour en decider)
Aussi, dans le patch, j'utilise 2 functions nouveaux dans
product.class.php (c'est pas dans le patch):
function isproduct() {
if ($this->type != 1) {
return 1;
} else {
return 0;
}
}
function isservice() {
if ($this->type==1) {
return 1;
} else {
return 0;
}
}
(j'ai encore les functions isproduct_raw(), isproduct_assembly() et
isproduct_stockkit(), mais c'est pas pour maintenant)
au lieu du vieux code
if ($this->type == 0)
{
$this->isproduct = 1;
$this->isservice = 0;
}
else
{
$this->isproduct = 0;
$this->isservice = 1;
}
parce que ces variables ne sont pas utilise (sauf dans
fourn/product/photos.php et la c'est change dans mon patch), et appeler
une fontion est mieux dans le style ObjectOriented Programming.
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/facture/fiche.php dolibarr/htdocs/fourn/facture/fiche.php
--- dolibarr.orig/htdocs/fourn/facture/fiche.php 2007-01-26 19:46:49.000000000 +0100
+++ dolibarr/htdocs/fourn/facture/fiche.php 2007-01-24 10:26:26.000000000 +0100
@@ -366,10 +367,10 @@
{
if ($_GET['action'] == 'copy')
{
- $value_label = $fac_ori->lignes[$i-1][0];
- $value_pu = $fac_ori->lignes[$i-1][1];
- $value_tauxtva = $fac_ori->lignes[$i-1][2];
- $value_qty = $fac_ori->lignes[$i-1][3];
+ $value_label = $fac_ori->lignes[$i-1]->description;
+ $value_pu = $fac_ori->lignes[$i-1]->pu_ht;
+ $value_tauxtva = $fac_ori->lignes[$i-1]->tva_taux;
+ $value_qty = $fac_ori->lignes[$i-1]->qty;
}
else
{
@@ -491,17 +492,17 @@
{
$var=!$var;
// Ligne en modification
- if ($_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i][7])
+ if ($_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i]->rowid)
{
- print '<form action="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=1&ligne_id='.$fac->lignes[$i][7].'" method="post">';
- print '<input type="hidden" name="tauxtva" value="'.$fac->lignes[$i][2].'">';
- print '<tr '.$bc[$var].'><td><input size="30" name="label" type="text" value="'.$fac->lignes[$i][0].'"></td>';
- print '<td align="right" nowrap="nowrap"><input size="6" name="puht" type="text" value="'.price($fac->lignes[$i][1]).'"></td>';
+ print '<form action="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=1&ligne_id='.$fac->lignes[$i]->rowid.'" method="post">';
+ print '<input type="hidden" name="tauxtva" value="'.$fac->lignes[$i]->tva_taux.'">';
+ print '<tr '.$bc[$var].'><td><input size="30" name="label" type="text" value="'.$fac->lignes[$i]->description.'"></td>';
+ print '<td align="right" nowrap="nowrap"><input size="6" name="puht" type="text" value="'.price($fac->lignes[$i]->pu_ht).'"></td>';
print '<td align="right" nowrap="nowrap"> </td>';
- print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lignes[$i][3].'"></td>';
- print '<td align="right" nowrap="nowrap"><input size="6" name="totalht" type="text" value="'.price($fac->lignes[$i][4]).'"></td>';
+ print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lignes[$i]->qty.'"></td>';
+ print '<td align="right" nowrap="nowrap"><input size="6" name="totalht" type="text" value="'.price($fac->lignes[$i]->total_ht).'"></td>';
print '<td align="right">';
- $html->select_tva('tauxtva',$fac->lignes[$i][2],$societe,$mysoc);
+ $html->select_tva('tauxtva',$fac->lignes[$i]->tva_taux,$societe,$mysoc);
print '</td>';
print '<td align="right" nowrap="nowrap"></td>';
print '<td align="right" nowrap="nowrap"></td>';
@@ -512,22 +513,22 @@
}
else // Affichage simple de la ligne
{
- print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i][0].'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][1]).'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100))).'</td>';
- print '<td align="right">'.$fac->lignes[$i][3].'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][4]).'</td>';
- print '<td align="right">'.$fac->lignes[$i][2].'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][5]).'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][6]).'</td>';
- print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i][7].'">'.img_edit().'</a></td>';
+ print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i]->description.'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht).'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht * (1+($fac->lignes[$i]->tva_taux/100))).'</td>';
+ print '<td align="right">'.$fac->lignes[$i]->qty.'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht).'</td>';
+ print '<td align="right">'.$fac->lignes[$i]->tva_taux.'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->tva).'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc).'</td>';
+ print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
if ($conf->global->PRODUIT_CONFIRM_DELETE_LINE)
{
- print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=delete_product_line&ligne_id='.$fac->lignes[$i][7].'">'.img_delete().'</a></td>';
+ print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=delete_product_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
}
else
{
- print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=del_ligne&ligne_id='.$fac->lignes[$i][7].'">'.img_delete().'</a></td>';
+ print '<td align="right"><a href="fiche.php?facid='.$fac->id.'&action=del_ligne&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
}
print '</td></tr>';
}
@@ -750,16 +751,16 @@
print '<tr '.$bc[$var].'>';
print '<td>';
- //print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$objp->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' ';
- print $fac->lignes[$i][0];
- //print '</a>';
+ print '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$fac->lignes[$i]->fk_product.'">'.img_object($langs->trans("ShowProduct"),'product').' ';
+ print $fac->lignes[$i]->description;
+ print '</a>';
print '</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][1]).'</td>';
- print '<td align="right">'.$fac->lignes[$i][3].'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][4]).'</td>';
- print '<td align="right" nowrap="nowrap">'.$fac->lignes[$i][2].' %</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][5]).'</td>';
- print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i][6]).'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht).'</td>';
+ print '<td align="right" nowrap="nowrap">'.$fac->lignes[$i]->qty.'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht).'</td>';
+ print '<td align="right" nowrap="nowrap">'.$fac->lignes[$i]->tva_taux.' %</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->tva).'</td>';
+ print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc).'</td>';
print '</tr>';
}
print '</table>';
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/fournisseur.commande.class.php dolibarr/htdocs/fourn/fournisseur.commande.class.php
--- dolibarr.orig/htdocs/fourn/fournisseur.commande.class.php 2007-01-06 16:47:53.000000000 +0100
+++ dolibarr/htdocs/fourn/fournisseur.commande.class.php 2007-01-24 10:26:26.000000000 +0100
@@ -113,7 +113,8 @@
$this->lignes = array();
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
- $sql.= ' p.label, p.description as product_desc, p.ref, p.fk_product_type, p.rowid as prodid';
+ #$sql.= ' p.label, p.description as product_desc, p.ref, p.fk_product_type, p.rowid as prodid';
+ $sql.= ' p.label, p.description as product_desc, p.ref, p.rowid as prodid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
$sql.= ' WHERE l.fk_commande = '.$this->id;
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/fournisseur.facture.class.php dolibarr/htdocs/fourn/fournisseur.facture.class.php
--- dolibarr.orig/htdocs/fourn/fournisseur.facture.class.php 2006-10-14 19:05:07.000000000 +0200
+++ dolibarr/htdocs/fourn/fournisseur.facture.class.php 2007-01-24 16:39:41.000000000 +0100
@@ -122,10 +123,10 @@
{
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
$this->updateline($idligne,
- $this->lignes[$i][0],
- $this->lignes[$i][1],
- $this->lignes[$i][2],
- $this->lignes[$i][3]);
+ $this->lignes[$i]->description,
+ $this->lignes[$i]->pu_ht,
+ $this->lignes[$i]->tva_taux,
+ $this->lignes[$i]->qty);
}
}
// Mise à jour prix
@@ -206,7 +207,7 @@
/*
* Lignes
*/
- $sql = 'SELECT rowid, description, pu_ht, qty, tva_taux, tva, total_ht, total_ttc';
+ $sql = 'SELECT rowid, description, pu_ht, qty, tva_taux, tva, total_ht, total_ttc, fk_product';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det';
$sql .= ' WHERE fk_facture_fourn='.$this->id;
$resql_rows = $this->db->query($sql);
@@ -218,16 +219,7 @@
{
while ($i < $num_rows)
{
- $obj = $this->db->fetch_object($resql_rows);
- $this->lignes[$i][0] = $obj->description;
- $this->lignes[$i][1] = $obj->pu_ht;
- $this->lignes[$i][2] = $obj->tva_taux;
- $this->lignes[$i][3] = $obj->qty;
- $this->lignes[$i][4] = $obj->total_ht;
- $this->lignes[$i][5] = $obj->tva;
- $this->lignes[$i][6] = $obj->total_ttc;
- $this->lignes[$i][7] = $obj->rowid;
- $this->lignes[$i][8] = $obj->total_tva;
+ $this->lignes[$i] = $this->db->fetch_object($resql_rows);
$i++;
}
}
@@ -348,7 +340,7 @@
* \param tauxtva taux de tva
* \param qty quantité
*/
- function addline($desc, $pu, $tauxtva, $qty, $idproduct)
+ function addline($desc, $pu, $tauxtva, $qty, $idproduct=0)
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
$sql .= ' VALUES ('.$this->id.');';
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/product/categorie.php dolibarr/htdocs/fourn/product/categorie.php
--- dolibarr.orig/htdocs/fourn/product/categorie.php 2005-12-03 13:28:02.000000000 +0100
+++ dolibarr/htdocs/fourn/product/categorie.php 2007-01-24 10:26:26.000000000 +0100
@@ -28,9 +29,6 @@
if (!$user->rights->produit->lire) accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
/*
* Creation de l'objet produit correspondant à l'id
*/
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/product/fiche.php dolibarr/htdocs/fourn/product/fiche.php
--- dolibarr.orig/htdocs/fourn/product/fiche.php 2006-08-02 01:54:39.000000000 +0200
+++ dolibarr/htdocs/fourn/product/fiche.php 2007-01-24 10:26:26.000000000 +0100
@@ -40,9 +41,6 @@
if (!$user->rights->produit->lire) accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
/*
*
*/
@@ -221,7 +219,7 @@
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
print '<input type="hidden" name="catid" value="'.$_REQUEST["catid"].'">'."\n";
- if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); }
+ if ($_GET["type"]!=1) { $title=$langs->trans("NewProduct"); }
if ($_GET["type"]==1) { $title=$langs->trans("NewService"); }
print_fiche_titre($title);
@@ -251,7 +249,7 @@
print '</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
- if ($_GET["type"] == 0 && $conf->stock->enabled)
+ if ($_GET["type"] != 1 && $conf->stock->enabled)
{
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
print '<input name="seuil_stock_alerte" size="4" value="0">';
@@ -308,7 +306,7 @@
$hselected = $h;
$h++;
- if($product->type == 0)
+ if($product->isproduct())
{
if ($conf->stock->enabled)
{
@@ -368,8 +366,8 @@
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
$nblignefour=2;
- if ($product->type == 0 && $conf->stock->enabled) $nblignefour++;
- if ($product->type == 1) $nblignefour++;
+ if ($product->isproduct() && $conf->stock->enabled) $nblignefour++;
+ if ($product->isservice()) $nblignefour++;
print '<td valign="middle" align="center" rowspan="'.$nblignefour.'">';
$product->show_photos($conf->produit->dir_output,1,1,0);
@@ -379,7 +377,7 @@
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
// Stock
- if ($product->type == 0 && $conf->stock->enabled)
+ if ($product->isproduct() && $conf->stock->enabled)
{
print '<tr><td><a href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>';
if ($product->no_stock)
@@ -401,7 +399,7 @@
}
// Duration
- if ($product->type == 1)
+ if ($product->isservice())
{
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
@@ -512,7 +510,11 @@
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer)
{
- print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, "");
+ if ($product->isservice()) {
+ print_fiche_titre($langs->trans('Edit').' '.$langs->trans('Service').' : '.$product->ref, "");
+ } else {
+ print_fiche_titre($langs->trans('Edit').' '.$langs->trans('Product').' : '.$product->ref, "");
+ }
if ($mesg) {
print '<br><div class="error">'.$mesg.'</div><br>';
@@ -526,7 +528,7 @@
print '<td>'.$langs->trans("Label").'</td><td colspan="2"><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
- if ($product->type == 0 && $conf->stock->enabled)
+ if ($product->isproduct() && $conf->stock->enabled)
{
print "<tr>".'<td>Seuil stock</td><td colspan="2">';
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
@@ -541,7 +543,7 @@
print $product->description;
print "</textarea></td></tr>";
- if ($product->type == 1)
+ if ($product->isservice())
{
print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="2"><input name="duration_value" size="3" maxlength="5" value="'.$product->duration_value.'">';
print ' ';
@@ -580,14 +582,14 @@
print '<a class="tabAction" href="fiche.php?action=edit&id='.$product->id.'">'.$langs->trans("Edit").'</a>';
}
- if ($product->type == 0 && $conf->stock->enabled)
+ if ($product->isproduct() && $conf->stock->enabled)
{
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$product->id.'&action=correction">'.$langs->trans("CorrectStock").'</a>';
}
print '<a class="butAction" href="fiche.php?id='.$product->id.'&action=ajout_fourn">'.$langs->trans("AddSupplier").'</a>';
- if ($product->type == 0 && $user->rights->commande->creer)
+ if ($product->isproduct() && $user->rights->commande->creer)
{
$langs->load('orders');
print '<a class="tabAction" href="fiche.php?action=fastappro&id='.$product->id.'">';
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/product/index.php dolibarr/htdocs/fourn/product/index.php
--- dolibarr.orig/htdocs/fourn/product/index.php 2007-01-27 16:28:31.000000000 +0100
+++ dolibarr/htdocs/fourn/product/index.php 2007-01-24 10:26:26.000000000 +0100
@@ -96,11 +97,11 @@
/*
- * Derniers produits/services en vente
+ * Derniers produits en vente
*/
-$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type";
+$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.type";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p ";
-$sql .= " WHERE p.fk_product_type=0";
+$sql .= " WHERE p.fk_product_type <> 1";
$sql .= " ORDER BY p.datec DESC ";
$sql .= $db->plimit(15 ,0);
@@ -112,9 +113,6 @@
$i = 0;
- $typeprodser[0]=$langs->trans("Product");
- $typeprodser[1]=$langs->trans("Service");
-
if ($num > 0)
{
print '<table class="noborder" width="100%">';
@@ -132,8 +130,10 @@
else print img_object($langs->trans("ShowProduct"),"product");
print "</a> <a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></td>\n";
print "<td>$objp->label</td>";
- print "<td>".$typeprodser[$objp->fk_product_type]."</td>";
- print "</tr>\n";
+ print "<td>";
+ if ($objp->fk_product_type==1) print $langs->trans('ShowService');
+ else print $langs->trans('ShowProduct');
+ print "</td></tr>\n";
$i++;
}
$db->free($resql);
diff -ubwr --ignore-matching-lines='$Id:' --ignore-matching-lines='$Revision:' --ignore-matching-lines=Copyright dolibarr.orig/htdocs/fourn/product/photos.php dolibarr/htdocs/fourn/product/photos.php
--- dolibarr.orig/htdocs/fourn/product/photos.php 2006-09-02 22:53:20.000000000 +0200
+++ dolibarr/htdocs/fourn/product/photos.php 2007-01-24 10:26:26.000000000 +0100
@@ -35,9 +36,6 @@
if (!$user->rights->produit->lire) accessforbidden();
-$types[0] = $langs->trans("Product");
-$types[1] = $langs->trans("Service");
-
/*
*
*/
@@ -118,7 +116,7 @@
* Ajouter une photo
*
*/
- if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && $product->isproduct && $conf->upload)
+ if ($_GET["action"] == 'ajout_photo' && $user->rights->produit->creer && $product->isproduct() && $conf->upload)
{
print_titre($langs->trans("AddPhoto"));
@@ -202,7 +200,7 @@
if ($_GET["action"] == '')
{
- if ( $user->rights->produit->creer && $product->isproduct && $conf->upload)
+ if ( $user->rights->produit->creer && $product->isproduct() && $conf->upload)
{
print '<a class="tabAction" href="photos.php?action=ajout_photo&id='.$product->id.'">';
print $langs->trans("AddPhoto").'</a>';
_______________________________________________
Dolibarr-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/dolibarr-dev