forked from Wavyzz/dolibarr
Ajout patch qui transforme les proprits par indice de tableau en proprits de classe d'objets
Correction du taux de tva par dfaut lors de creation d'un facture fournisseur
This commit is contained in:
@@ -366,10 +366,10 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
{
|
||||
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 +491,17 @@ else
|
||||
{
|
||||
$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 +512,22 @@ else
|
||||
}
|
||||
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 +750,16 @@ else
|
||||
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>';
|
||||
|
||||
@@ -113,7 +113,7 @@ class CommandeFournisseur extends Commande
|
||||
|
||||
$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.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;
|
||||
|
||||
@@ -122,10 +122,10 @@ class FactureFournisseur extends Facture
|
||||
{
|
||||
$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 <20> jour prix
|
||||
@@ -206,7 +206,7 @@ class FactureFournisseur extends Facture
|
||||
/*
|
||||
* 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);
|
||||
@@ -219,15 +219,15 @@ class FactureFournisseur extends Facture
|
||||
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]->description = $obj->description;
|
||||
$this->lignes[$i]->pu_ht = $obj->pu_ht;
|
||||
$this->lignes[$i]->tva_taux = $obj->tva_taux;
|
||||
$this->lignes[$i]->qty = $obj->qty;
|
||||
$this->lignes[$i]->total_ht = $obj->total_ht;
|
||||
$this->lignes[$i]->tva = $obj->tva;
|
||||
$this->lignes[$i]->total_ttc = $obj->total_ttc;
|
||||
$this->lignes[$i]->rowid = $obj->rowid;
|
||||
$this->lignes[$i]->total_tva = $obj->total_tva;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -347,8 +347,9 @@ class FactureFournisseur extends Facture
|
||||
* \param pu prix unitaire
|
||||
* \param tauxtva taux de tva
|
||||
* \param qty quantit<69>
|
||||
* \param idproduct id produit
|
||||
*/
|
||||
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.');';
|
||||
|
||||
@@ -28,9 +28,6 @@ $mesg = '';
|
||||
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
/*
|
||||
* Creation de l'objet produit correspondant <20> l'id
|
||||
*/
|
||||
|
||||
@@ -40,9 +40,6 @@ $mesg = '';
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@@ -221,7 +218,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
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 +248,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
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 +305,7 @@ else
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
if($product->type == 0)
|
||||
if($product->isproduct())
|
||||
{
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
@@ -368,8 +365,8 @@ else
|
||||
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 +376,7 @@ else
|
||||
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 +398,7 @@ else
|
||||
}
|
||||
|
||||
// Duration
|
||||
if ($product->type == 1)
|
||||
if ($product->isservice())
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$product->duration_value.' ';
|
||||
|
||||
@@ -512,7 +509,11 @@ else
|
||||
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 +527,7 @@ else
|
||||
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 +542,7 @@ else
|
||||
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 +581,14 @@ else
|
||||
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.'">';
|
||||
|
||||
@@ -96,11 +96,11 @@ print '</td><td valign="top" width="70%">';
|
||||
|
||||
|
||||
/*
|
||||
* 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 +112,6 @@ if ($resql)
|
||||
|
||||
$i = 0;
|
||||
|
||||
$typeprodser[0]=$langs->trans("Product");
|
||||
$typeprodser[1]=$langs->trans("Service");
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
@@ -132,8 +129,10 @@ if ($resql)
|
||||
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);
|
||||
|
||||
@@ -35,9 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
if (!$user->rights->produit->lire) accessforbidden();
|
||||
|
||||
|
||||
$types[0] = $langs->trans("Product");
|
||||
$types[1] = $langs->trans("Service");
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@@ -118,7 +115,7 @@ if ($_GET["id"])
|
||||
* 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 +199,7 @@ if ($_GET["id"])
|
||||
|
||||
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>';
|
||||
|
||||
@@ -2014,81 +2014,81 @@ class Form
|
||||
* Sinon la TVA propos<6F>e par d<>faut=0. Fin de r<>gle.
|
||||
*/
|
||||
function select_tva($name='tauxtva', $defaulttx='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='')
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
{
|
||||
global $langs,$conf,$mysoc;
|
||||
|
||||
//print $societe_vendeuse."-".$societe_acheteuse;
|
||||
if (is_object($societe_vendeuse) && ! $societe_vendeuse->pays_code)
|
||||
{
|
||||
if ($societe_vendeuse->id == $mysoc->id)
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_object($societe_vendeuse->pays_code))
|
||||
{
|
||||
$code_pays=$societe_vendeuse->pays_code;
|
||||
//print $societe_vendeuse."-".$societe_acheteuse;
|
||||
if (is_object($societe_vendeuse) && ! $societe_vendeuse->pays_code)
|
||||
{
|
||||
if ($societe_vendeuse->id == $mysoc->id)
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_object($societe_vendeuse))
|
||||
{
|
||||
$code_pays=$societe_vendeuse->pays_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code_pays=$mysoc->pays_code; // Pour compatibilite ascendente
|
||||
}
|
||||
|
||||
// Recherche liste des codes TVA du pays vendeur
|
||||
$sql = "SELECT t.taux,t.recuperableonly";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
|
||||
$sql .= " AND t.active = 1";
|
||||
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$txtva[ $i ] = $obj->taux;
|
||||
$libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':'');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry").'</div>';
|
||||
}
|
||||
|
||||
// D<>finition du taux <20> pr<70>s<EFBFBD>lectionner
|
||||
if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
|
||||
// Si taux par defaut n'a pu etre trouv<75>, on prend dernier.
|
||||
// Comme ils sont tri<72>s par ordre croissant, dernier = plus <20>lev<65> = taux courant
|
||||
if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1];
|
||||
|
||||
$nbdetaux = sizeof($txtva);
|
||||
|
||||
print '<select class="flat" name="'.$name.'">';
|
||||
if ($default) print '<option value="0">'.$langs->trans("Default").'</option>';
|
||||
|
||||
for ($i = 0 ; $i < $nbdetaux ; $i++)
|
||||
{
|
||||
print '<option value="'.$txtva[$i].'"';
|
||||
if ($txtva[$i] == $defaulttx)
|
||||
{
|
||||
print ' selected="true"';
|
||||
}
|
||||
print '>'.$libtva[$i].'</option>';
|
||||
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$code_pays=$mysoc->pays_code; // Pour compatibilite ascendente
|
||||
}
|
||||
|
||||
// Recherche liste des codes TVA du pays vendeur
|
||||
$sql = "SELECT t.taux,t.recuperableonly";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
|
||||
$sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_pays."'";
|
||||
$sql .= " AND t.active = 1";
|
||||
$sql .= " ORDER BY t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$txtva[ $i ] = $obj->taux;
|
||||
$libtva[ $i ] = $obj->taux.'%'.($obj->recuperableonly ? ' *':'');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry").'</div>';
|
||||
}
|
||||
|
||||
// D<>finition du taux <20> pr<70>s<EFBFBD>lectionner
|
||||
if ($defaulttx == '') $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit);
|
||||
// Si taux par defaut n'a pu etre trouv<75>, on prend dernier.
|
||||
// Comme ils sont tri<72>s par ordre croissant, dernier = plus <20>lev<65> = taux courant
|
||||
if ($defaulttx == '') $defaulttx = $txtva[sizeof($txtva)-1];
|
||||
|
||||
$nbdetaux = sizeof($txtva);
|
||||
|
||||
print '<select class="flat" name="'.$name.'">';
|
||||
if ($default) print '<option value="0">'.$langs->trans("Default").'</option>';
|
||||
|
||||
for ($i = 0 ; $i < $nbdetaux ; $i++)
|
||||
{
|
||||
print '<option value="'.$txtva[$i].'"';
|
||||
if ($txtva[$i] == $defaulttx)
|
||||
{
|
||||
print ' selected="true"';
|
||||
}
|
||||
print '>'.$libtva[$i].'</option>';
|
||||
|
||||
$this->tva_taux_value[$i] = $txtva[$i];
|
||||
$this->tva_taux_libelle[$i] = $libtva[$i];
|
||||
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user