Fix: Debuggage page cration facture fournisseur.
This commit is contained in:
parent
07d6aa6411
commit
add87c4733
@ -438,7 +438,7 @@ class Facture extends CommonObject
|
||||
$this->paye = $obj->paye;
|
||||
$this->close_code = $obj->close_code;
|
||||
$this->close_note = $obj->close_note;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->date_lim_reglement = $obj->dlr;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
@ -505,7 +505,7 @@ class Facture extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
\brief Recupére les lignes de factures
|
||||
\brief Recupére les lignes de factures dans this->lignes
|
||||
\return int 1 si ok, < 0 si erreur
|
||||
*/
|
||||
function fetch_lines()
|
||||
@ -530,7 +530,7 @@ class Facture extends CommonObject
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$faclig = new FactureLigne($this->db);
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->desc = $objp->description; // Description ligne
|
||||
$faclig->libelle = $objp->label; // Label produit
|
||||
$faclig->product_desc = $objp->product_desc; // Description produit
|
||||
@ -1339,93 +1339,92 @@ class Facture extends CommonObject
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='', $price_base_type='HT', $pu_ttc=0)
|
||||
{
|
||||
global $conf;
|
||||
dolibarr_syslog("Facture::Addline $facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='', $price_base_type='HT', $pu_ttc=0)
|
||||
{
|
||||
dolibarr_syslog("Facture::Addline $facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
if ($this->brouillon)
|
||||
{
|
||||
$this->db->begin();
|
||||
if ($this->brouillon)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
// Nettoyage paramètres
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
if (! $ventil) $ventil=0;
|
||||
if (! $info_bits) $info_bits=0;
|
||||
$pu = price2num($pu);
|
||||
$txtva=price2num($txtva);
|
||||
// Nettoyage paramètres
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
if (! $ventil) $ventil=0;
|
||||
if (! $info_bits) $info_bits=0;
|
||||
$pu = price2num($pu);
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $pu_ttc);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, $price_base_type, $pu_ttc);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
$remise = 0;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100),2);
|
||||
$price = ($pu - $remise);
|
||||
}
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$price = $pu;
|
||||
$remise = 0;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100),2);
|
||||
$price = ($pu - $remise);
|
||||
}
|
||||
|
||||
// Insertion ligne
|
||||
$ligne=new FactureLigne($this->db);
|
||||
// Insertion ligne
|
||||
$ligne=new FactureLigne($this->db);
|
||||
|
||||
$ligne->fk_facture=$facid;
|
||||
$ligne->desc=$desc;
|
||||
$ligne->qty=$qty;
|
||||
$ligne->txtva=$txtva;
|
||||
$ligne->fk_product=$fk_product;
|
||||
$ligne->remise_percent=$remise_percent;
|
||||
$ligne->subprice=$pu;
|
||||
$ligne->date_start=$date_start;
|
||||
$ligne->date_end=$date_end;
|
||||
$ligne->ventil=$ventil;
|
||||
$ligne->rang=-1;
|
||||
$ligne->info_bits=$info_bits;
|
||||
$ligne->fk_remise_except=$fk_remise_except;
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
$ligne->fk_facture=$facid;
|
||||
$ligne->desc=$desc;
|
||||
$ligne->qty=$qty;
|
||||
$ligne->txtva=$txtva;
|
||||
$ligne->fk_product=$fk_product;
|
||||
$ligne->remise_percent=$remise_percent;
|
||||
$ligne->subprice=$pu;
|
||||
$ligne->date_start=$date_start;
|
||||
$ligne->date_end=$date_end;
|
||||
$ligne->ventil=$ventil;
|
||||
$ligne->rang=-1;
|
||||
$ligne->info_bits=$info_bits;
|
||||
$ligne->fk_remise_except=$fk_remise_except;
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
|
||||
// A ne plus utiliser
|
||||
$ligne->price=$price;
|
||||
$ligne->remise=$remise;
|
||||
// A ne plus utiliser
|
||||
$ligne->price=$price;
|
||||
$ligne->remise=$remise;
|
||||
|
||||
$result=$ligne->insert();
|
||||
if ($result > 0)
|
||||
{
|
||||
// Mise a jour informations denormalisees au niveau de la facture meme
|
||||
$result=$this->update_price($facid);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$ligne->error;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
$result=$ligne->insert();
|
||||
if ($result > 0)
|
||||
{
|
||||
// Mise a jour informations denormalisees au niveau de la facture meme
|
||||
$result=$this->update_price($facid);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$ligne->error;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mets à jour une ligne de facture
|
||||
@ -2073,47 +2072,47 @@ class Facture extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge les informations de l'onglet info dans l'objet facture
|
||||
* \param id Id de la facture a charger
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, '.$this->db->pdate('datec').' as datec,';
|
||||
$sql.= ' '.$this->db->pdate('date_valid').' as datev,';
|
||||
$sql.= ' fk_user_author, fk_user_valid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c';
|
||||
$sql.= ' WHERE c.rowid = '.$id;
|
||||
/**
|
||||
* \brief Charge les informations de l'onglet info dans l'objet facture
|
||||
* \param id Id de la facture a charger
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, '.$this->db->pdate('datec').' as datec,';
|
||||
$sql.= ' '.$this->db->pdate('date_valid').' as datev,';
|
||||
$sql.= ' fk_user_author, fk_user_valid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c';
|
||||
$sql.= ' WHERE c.rowid = '.$id;
|
||||
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
$cuser = new User($this->db, $obj->fk_user_author);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
$vuser = new User($this->db, $obj->fk_user_valid);
|
||||
$vuser->fetch();
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_validation = $obj->datev;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
$result=$this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
$cuser = new User($this->db, $obj->fk_user_author);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
$vuser = new User($this->db, $obj->fk_user_valid);
|
||||
$vuser->fetch();
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_validation = $obj->datev;
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Change les conditions de réglement de la facture
|
||||
|
||||
@ -30,8 +30,9 @@
|
||||
*/
|
||||
|
||||
require_once('./pre.inc.php');
|
||||
require_once('./paiementfourn.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/product.class.php');
|
||||
|
||||
|
||||
if (!$user->rights->fournisseur->facture->lire)
|
||||
@ -74,14 +75,14 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
$facturefourn = new FactureFournisseur($db);
|
||||
$facturefourn->fetch($_GET['facid']);
|
||||
$facturefourn->deleteline($_GET['ligne_id']);
|
||||
$_GET['action'] = 'edit';
|
||||
$_GET['action'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +112,7 @@ if ($_POST['action'] == 'modif_libelle')
|
||||
}
|
||||
|
||||
|
||||
if ($_POST['action'] == 'update')
|
||||
if ($_POST['action'] == 'update' && ! $_POST['cancel'])
|
||||
{
|
||||
$datefacture = $db->idate(mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']));
|
||||
$date_echeance = $db->idate(mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']));
|
||||
@ -204,12 +205,12 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('Ref')).'</div>';
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'</div>';
|
||||
$_GET['action']='create';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['action'] == 'del_ligne' && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||
if ($_GET['action'] == 'del_ligne')
|
||||
{
|
||||
$facfou = new FactureFournisseur($db,'',$_GET['facid']);
|
||||
$facfou->deleteline($_GET['ligne_id']);
|
||||
@ -217,15 +218,14 @@ if ($_GET['action'] == 'del_ligne' && !$conf->global->PRODUIT_CONFIRM_DELETE_LIN
|
||||
}
|
||||
|
||||
// Modification d'une ligne
|
||||
if ($_GET['action'] == 'mod_ligne')
|
||||
if ($_REQUEST['action'] == 'mod_ligne')
|
||||
{
|
||||
if ($_GET['etat'] == '1' && !$_GET['cancel']) // si on valide la modification
|
||||
if ($_REQUEST['etat'] == '1' && ! $_REQUEST['cancel']) // si on valide la modification
|
||||
{
|
||||
$facfou = new FactureFournisseur($db,'',$_GET['facid']);
|
||||
|
||||
$facfou->updateline($_GET['ligne_id'], $_POST['label'], $_POST['puht'], $_POST['tauxtva'], $_POST['qty']);
|
||||
}
|
||||
$_GET['action'] = 'edit';
|
||||
}
|
||||
|
||||
if ($_GET['action'] == 'add_ligne')
|
||||
@ -241,10 +241,18 @@ if ($_GET['action'] == 'add_ligne')
|
||||
// $label = '['.$nv_prod->ref.'] - '. $nv_prod->libelle;
|
||||
$label = $nv_prod->libelle;
|
||||
|
||||
$result=$nv_prod->get_buyprice($_POST['fourn_id'], $_POST['qty']);
|
||||
$result=$nv_prod->get_buyprice($_POST['socid'], $_POST['qty']);
|
||||
if ($result > 0)
|
||||
{
|
||||
$facfou->addline($label, $nv_prod->fourn_pu, $nv_prod->tva_tx, $_POST['qty'], $_POST['idprod']);
|
||||
$societe='';
|
||||
if ($_POST['socid'])
|
||||
{
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($_POST['socid']);
|
||||
}
|
||||
|
||||
$tvatx=get_default_tva($societe,$mysoc,$nv_prod->tva_tx);
|
||||
$facfou->addline($label, $nv_prod->fourn_pu, $tvatx, $_POST['qty'], $_POST['idprod']);
|
||||
}
|
||||
if ($result == -1)
|
||||
{
|
||||
@ -257,7 +265,7 @@ if ($_GET['action'] == 'add_ligne')
|
||||
$tauxtva = price2num($_POST['tauxtva']);
|
||||
if (! $_POST['label'])
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Label")).'</div>';
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -274,21 +282,21 @@ if ($_GET['action'] == 'add_ligne')
|
||||
}
|
||||
}
|
||||
}
|
||||
$_GET['action'] = 'edit';
|
||||
$_GET['action'] = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Mode creation
|
||||
*
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Affichage page
|
||||
*/
|
||||
$addons='';
|
||||
llxHeader('','', $addons);
|
||||
|
||||
|
||||
// Mode creation
|
||||
if ($_GET['action'] == 'create' or $_GET['action'] == 'copy')
|
||||
{
|
||||
llxHeader();
|
||||
|
||||
print_titre($langs->trans('NewBill'));
|
||||
|
||||
if ($mesg) { print $mesg.'<br>'; }
|
||||
@ -402,34 +410,18 @@ else
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
$productstatic = new Product($db);
|
||||
|
||||
$fac = new FactureFournisseur($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
|
||||
$societe = new Fournisseur($db);
|
||||
if ($societe->fetch($fac->socid))
|
||||
{
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$fac->socid;
|
||||
$addons[0][1] = $societe->nom;
|
||||
}
|
||||
$societe->fetch($fac->socid);
|
||||
|
||||
llxHeader('','', $addons);
|
||||
|
||||
if ($mesg) { print $mesg.'<br>'; }
|
||||
|
||||
|
||||
if ($_GET['action'] == 'edit' || $_GET['action'] == 'delete_product_line')
|
||||
if ($_GET['action'] == 'edit')
|
||||
{
|
||||
print_titre($langs->trans('SupplierInvoice'));
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression d'une ligne produit
|
||||
*/
|
||||
if ($_GET['action'] == 'delete_product_line' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||
{
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=edit&ligne_id='.$_GET["ligne_id"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
print '<form name="update" action="fiche.php?facid='.$fac->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
@ -437,14 +429,15 @@ else
|
||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||
|
||||
print '<td>'.$societe->getNomUrl(1).'</td>';
|
||||
print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</tr>';
|
||||
print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
|
||||
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
|
||||
|
||||
$rownb=9;
|
||||
$rownb=8;
|
||||
print '<td rowspan="'.$rownb.'" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="'.ROWS_5.'">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="'.ROWS_8.'">';
|
||||
print $fac->note;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
@ -467,7 +460,12 @@ else
|
||||
print '<td nowrap="nowrap">'.price($fac->total_ttc).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Status').'</td><td>'.$fac->getLibStatut(4).'</td></tr>';
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"></td></tr>';
|
||||
print '<tr><td colspan="2" align="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
@ -486,97 +484,25 @@ else
|
||||
print '<td align="right">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right" colspan="2">'.$langs->trans('TotalTTC').'</td><td> </td></tr>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td colspan="2"> </td></tr>';
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
// Ligne en modification
|
||||
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]->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]->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]->tva_taux,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
}
|
||||
else // Affichage simple de la ligne
|
||||
{
|
||||
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]->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]->rowid.'">'.img_delete().'</a></td>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
// Affichage simple de la ligne
|
||||
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="center"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
/* Nouvelle ligne */
|
||||
$var=!$var;
|
||||
print '<form action="fiche.php?facid='.$fac->id.'&action=add_ligne" method="post">';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
print '<input size="30" name="label" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="6" name="amount" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="6" name="amountttc" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="1" name="qty" type="text" value="1">';
|
||||
print '</td>';
|
||||
print '<td align="center">-</td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva','',$societe,$mysoc);
|
||||
print '</td><td align="center" colspan="2">';
|
||||
print ' ';
|
||||
print '</td><td align="center" valign="middle" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services prédéfinis
|
||||
if ($conf->produit->enabled)
|
||||
{
|
||||
print '<form name="addligne_predef" action="fiche.php?facid='.$fac->id.'&action=add_ligne" method="post">';
|
||||
print '<input type="hidden" name="fourn_id" value="'. $fac->socid .'">';
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="3">';
|
||||
$html->select_produits_fournisseurs($fac->socid,'','idprod',$filtre);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" valign="middle" rowspan="2" colspan="5"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
else
|
||||
@ -588,7 +514,16 @@ else
|
||||
$titre=$langs->trans('SupplierInvoice');
|
||||
dolibarr_fiche_head($head, 'card', $titre);
|
||||
|
||||
if ($mesg) { print $mesg.'<br>'; }
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression d'une ligne produit
|
||||
*/
|
||||
if ($_GET['action'] == 'confirm_delete_line')
|
||||
{
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?facid='.$fac->id.'&ligne_id='.$_GET["ligne_id"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline');
|
||||
print '<br>';
|
||||
}
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
@ -737,32 +672,124 @@ else
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Label').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PriceUTTC').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VATRate').'</td>';
|
||||
print '<td align="right">'.$langs->trans('VAT').'</td>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td></tr>';
|
||||
print '<td align="right">'.$langs->trans('TotalTTC').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$var=1;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
print '<td>';
|
||||
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]->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>';
|
||||
// Ligne en modification
|
||||
if ($_GET['action'] == 'mod_ligne' && $_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]->rowid.'" method="post">';
|
||||
print '<input type="hidden" name="tauxtva" value="'.$fac->lignes[$i]->tva_taux.'">';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<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]->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]->tva_taux,$societe,$mysoc);
|
||||
print '</td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="right" nowrap="nowrap"></td>';
|
||||
print '<td align="center" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Save').'">';
|
||||
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
}
|
||||
else // Affichage simple de la ligne
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
if ($fac->lignes[$i]->fk_product)
|
||||
{
|
||||
$productstatic->id=$fac->lignes[$i]->fk_product;
|
||||
$productstatic->type=1;
|
||||
$productstatic->ref=$fac->lignes[$i]->libelle;
|
||||
print $productstatic->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $fac->lignes[$i]->description;
|
||||
}
|
||||
print '</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="center"><a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a></td>';
|
||||
print '<td align="center"><a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($_GET['action'] != 'mod_ligne')
|
||||
{
|
||||
/* Nouvelle ligne */
|
||||
$var=!$var;
|
||||
print '<form action="fiche.php?facid='.$fac->id.'&action=add_ligne" method="post">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$societe->id.'">';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
print '<input size="30" name="label" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="6" name="amount" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="6" name="amountttc" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print '<input size="1" name="qty" type="text" value="1">';
|
||||
print '</td>';
|
||||
print '<td align="center">-</td>';
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva','',$societe,$mysoc);
|
||||
print '</td><td align="center" colspan="2">';
|
||||
print ' ';
|
||||
print '</td><td align="center" valign="middle" colspan="2"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services prédéfinis
|
||||
if ($conf->produit->enabled)
|
||||
{
|
||||
print '<form name="addligne_predef" action="fiche.php?facid='.$fac->id.'&action=add_ligne" method="post">';
|
||||
print '<input type="hidden" name="socid" value="'. $fac->socid .'">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$fac->socid.'">';
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="3">';
|
||||
$html->select_produits_fournisseurs($fac->socid,'','idprod',$filtre);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" valign="middle" rowspan="2" colspan="5"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
@ -775,11 +802,7 @@ else
|
||||
|
||||
if ($fac->statut == 0 && $user->societe_id == 0)
|
||||
{
|
||||
if ($_GET['action'] == 'edit')
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'">'.$langs->trans('Cancel').'</a>';
|
||||
}
|
||||
else
|
||||
if ($_GET['action'] != 'edit')
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=edit">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
|
||||
@ -171,13 +171,15 @@ class FactureFournisseur extends Facture
|
||||
$sql.= ' s.nom as socnom, s.idp as socid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql.= ' WHERE f.rowid='.$rowid.' AND f.fk_soc = s.idp';
|
||||
|
||||
dolibarr_syslog("FactureFourn::Fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num=$this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $rowid;
|
||||
$this->datep = $obj->df;
|
||||
@ -206,28 +208,36 @@ class FactureFournisseur extends Facture
|
||||
/*
|
||||
* Lignes
|
||||
*/
|
||||
$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;
|
||||
$sql = 'SELECT f.rowid, f.description, f.pu_ht, f.qty, f.tva_taux, f.tva,';
|
||||
$sql.= ' f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product,';
|
||||
$sql.= ' p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
|
||||
$sql.= ' WHERE fk_facture_fourn='.$this->id;
|
||||
|
||||
dolibarr_syslog("FactureFourn::Fetch search lines sql=".$sql, LOG_DEBUG);
|
||||
$resql_rows = $this->db->query($sql);
|
||||
if ($resql_rows)
|
||||
{
|
||||
$num_rows = $this->db->num_rows($resql_rows);
|
||||
$i = 0;
|
||||
if ($num_rows)
|
||||
{
|
||||
$i = 0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql_rows);
|
||||
$this->lignes[$i]->rowid = $obj->rowid;
|
||||
$this->lignes[$i]->description = $obj->description;
|
||||
$this->lignes[$i]->libelle = $obj->label; // Label produit
|
||||
$this->lignes[$i]->product_desc = $obj->product_desc; // Description produit
|
||||
$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_ht = $obj->total_ht;
|
||||
$this->lignes[$i]->total_tva = $obj->total_tva;
|
||||
$this->lignes[$i]->total_ttc = $obj->total_ttc;
|
||||
$this->lignes[$i]->fk_product = $obj->fk_product;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -235,7 +245,7 @@ class FactureFournisseur extends Facture
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('Erreur FactureFournisseur::Fetch rowid='.$rowid.', Erreur dans fetch des lignes');
|
||||
dolibarr_syslog('FactureFournisseur::Fetch rowid='.$rowid.', Erreur dans fetch des lignes');
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_print_error($this->db);
|
||||
return -3;
|
||||
@ -243,7 +253,7 @@ class FactureFournisseur extends Facture
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('Erreur FactureFournisseur::Fetch rowid='.$rowid.' numrows=0 sql='.$sql);
|
||||
dolibarr_syslog('FactureFournisseur::Fetch rowid='.$rowid.' numrows=0 sql='.$sql);
|
||||
$this->error='Bill with id '.$rowid.' not found sql='.$sql;
|
||||
dolibarr_print_error($this->db);
|
||||
return -2;
|
||||
@ -252,7 +262,7 @@ class FactureFournisseur extends Facture
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('Erreur FactureFournisseur::Fetch rowid='.$rowid.' Erreur dans fetch de la facture fournisseur');
|
||||
dolibarr_syslog('FactureFournisseur::Fetch rowid='.$rowid.' Erreur dans fetch de la facture fournisseur');
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
@ -342,32 +352,69 @@ class FactureFournisseur extends Facture
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajoute une ligne de facture (associé à aucun produit/service prédéfini)
|
||||
* \param desc description de la ligne
|
||||
* \param pu prix unitaire
|
||||
* \param tauxtva taux de tva
|
||||
* \param qty quantité
|
||||
* \param idproduct id produit
|
||||
*/
|
||||
function addline($desc, $pu, $tauxtva, $qty, $idproduct=0)
|
||||
* \brief Ajoute une ligne de facture (associé à aucun produit/service prédéfini)
|
||||
* \param desc Description de la ligne
|
||||
* \param pu Prix unitaire
|
||||
* \param txtva Taux de tva forcé, sinon -1
|
||||
* \param qty Quantité
|
||||
* \param fk_product Id du produit/service predéfini
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param date_start Date de debut de validité du service
|
||||
* \param date_end Date de fin de validité du service
|
||||
* \param ventil Code de ventilation comptable
|
||||
* \param info_bits Bits de type de lignes
|
||||
* \remarks Les parametres sont deja censé etre juste et avec valeurs finales a l'appel
|
||||
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete défini
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $fk_remise_except='', $price_base_type='HT', $pu_ttc=0)
|
||||
{
|
||||
dolibarr_syslog("FactureFourn::Addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Nettoyage paramètres
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
$tabprice = calcul_price_total($qty, $pu, 0, $txtva, 0, 'HT', 0);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)';
|
||||
$sql .= ' VALUES ('.$this->id.');';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
|
||||
$this->updateline($idligne, $desc, $pu, $tauxtva, $qty, $idproduct);
|
||||
$this->updateline($idligne, $desc, $pu, $txtva, $qty, $fk_product);
|
||||
|
||||
// Mise a jour prix facture
|
||||
$this->update_price($this->id);
|
||||
|
||||
return 1;
|
||||
$result=$this->update_price($this->id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Error sql=$sql, error=".$this->error);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
$this->error=$ligne->error;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -979,17 +979,17 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
|
||||
{
|
||||
$langs->load("propal");
|
||||
|
||||
print '<tr class="liste_titre"><td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToMyProposals")) . '</td>';
|
||||
print '<tr class="liste_titre"><td width="50%" valign="top" class="liste_titre">';
|
||||
print $langs->trans("AddToMyProposals") . '</td>';
|
||||
|
||||
if ($user->rights->commercial->client->voir)
|
||||
{
|
||||
print '<td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToOtherProposals")) . '</td>';
|
||||
print '<td width="50%" valign="top" class="liste_titre">';
|
||||
print $langs->trans("AddToOtherProposals").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="50%" valign="top"> </td>';
|
||||
print '<td width="50%" valign="top" class="liste_titre"> </td>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
@ -1093,17 +1093,17 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
|
||||
{
|
||||
$langs->load("orders");
|
||||
|
||||
print '<tr class="liste_titre"><td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToMyOrders")) . '</td>';
|
||||
print '<tr class="liste_titre"><td width="50%" valign="top" class="liste_titre">';
|
||||
print $langs->trans("AddToMyOrders").'</td>';
|
||||
|
||||
if ($user->rights->commercial->client->voir)
|
||||
{
|
||||
print '<td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToOtherOrders")) . '</td>';
|
||||
print '<td width="50%" valign="top" class="liste_titre">';
|
||||
print $langs->trans("AddToOtherOrders").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="50%" valign="top"></td>';
|
||||
print '<td width="50%" valign="top" class="liste_titre"> </td>';
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
@ -1203,19 +1203,19 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
|
||||
|
||||
|
||||
print '<tr class="liste_titre"><td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToMyBills"));
|
||||
print $langs->trans("AddToMyBills").'</td>';
|
||||
|
||||
if ($user->rights->commercial->client->voir)
|
||||
{
|
||||
print '</td><td width="50%" valign="top">';
|
||||
print_titre($langs->trans("AddToOtherBills"));
|
||||
print '<td width="50%" valign="top" class="liste_titre">';
|
||||
print $langs->trans("AddToOtherBills").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td width="50%" valign="top"></td>';
|
||||
print '<td width="50%" valign="top" class="liste_titre"> </td>';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Liste de Mes factures
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
@ -1298,7 +1298,7 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
|
||||
print '<form method="POST" action="fiche.php?id='.$product->id.'">';
|
||||
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><a href=\"../comm/fiche.php?socid=$objp->idp\">".dolibarr_trunc($objp->nom,24)."</a></td>\n";
|
||||
print "<td colspan=\"2\">".$langs->trans("Qty");
|
||||
print '<input type="hidden" name="action" value="addinfacture">';
|
||||
print "</td>";
|
||||
|
||||
@ -102,7 +102,7 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Ref")).'</div>';
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")).'</div>';
|
||||
}
|
||||
|
||||
if ($_POST["qty"])
|
||||
@ -123,13 +123,13 @@ if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Canc
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Price")).'</div>';
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")).'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Qty")).'</div>';
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")).'</div>';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -152,211 +152,212 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
|
||||
|
||||
|
||||
/*
|
||||
* Fiche produit
|
||||
* Affichage fiche
|
||||
*/
|
||||
|
||||
if ($_GET["id"] || $_GET["ref"])
|
||||
{
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
$product = new Product($db);
|
||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
$head=product_prepare_head($product, $user);
|
||||
$titre=$langs->trans("CardProduct".$product->type);
|
||||
dolibarr_fiche_head($head, 'suppliers', $titre);
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference
|
||||
print '<tr>';
|
||||
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
$product->load_previous_next_ref();
|
||||
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
|
||||
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
|
||||
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
|
||||
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Libelle
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
print $product->getLibStatut(2);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($mesg) print($mesg);
|
||||
|
||||
|
||||
// Formulaire ajout prix
|
||||
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print_fiche_titre($langs->trans("ChangeSupplierPrice"));
|
||||
} else {
|
||||
print_fiche_titre($langs->trans("AddSupplierPrice"));
|
||||
}
|
||||
print '<table class="border" width="100%">';
|
||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateprice">';
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
|
||||
$product->fetch_fourn_data($_GET["id_fourn"]);
|
||||
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
|
||||
} else {
|
||||
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
|
||||
$html=new Form($db);
|
||||
$html->select_societes('','id_fourn','fournisseur=1');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print '<input class="flat" name="ref_fourn" size="25" value="">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("Qty").'</td>';
|
||||
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
|
||||
print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>';
|
||||
print '<td>'.$langs->trans("Price").'</td>';
|
||||
print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</form>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] != 'add_price') {
|
||||
|
||||
if ($user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
||||
print $langs->trans("AddSupplier").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
print '<br>';
|
||||
|
||||
|
||||
if ($user->rights->fournisseur->lire) {
|
||||
// Titre liste des fournisseurs
|
||||
print '<table class="noborder" width="100%">';
|
||||
if ($product->isproduct()) $nblignefour=4;
|
||||
else $nblignefour=4;
|
||||
print '<tr class="liste_titre"><td valign="top">';
|
||||
print $langs->trans("Suppliers").'</td>';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("BuyingPrice").'</td>';
|
||||
print '<td align="right">'.$langs->trans("UnitPrice").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Liste des fournisseurs
|
||||
$sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
||||
$sql.= " WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql.= " ORDER BY lower(s.nom), pfp.quantity";
|
||||
|
||||
$resql="";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$objp->nom.'</a></td>';
|
||||
|
||||
// Fournisseur
|
||||
print '<td align="left">'.$objp->ref_fourn.'</td>';
|
||||
|
||||
// Quantité
|
||||
print '<td align="center">';
|
||||
print $objp->quantity;
|
||||
print '</td>';
|
||||
|
||||
// Prix quantité
|
||||
print '<td align="right">';
|
||||
print $objp->price?price($objp->price):"";
|
||||
print '</td>';
|
||||
|
||||
// Prix unitaire
|
||||
print '<td align="right">';
|
||||
print $objp->quantity?price($objp->price / $objp->quantity):" ";
|
||||
print '</td>';
|
||||
|
||||
// Modifier-Supprimer
|
||||
print '<td align="center">';
|
||||
if ($user->rights->produit->creer) {
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'&price='.$objp->price.'">'.img_edit()."</a>";
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">';
|
||||
print img_disable($langs->trans("Remove")).'</a>';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
$product = new Product($db);
|
||||
if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
|
||||
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
|
||||
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
/*
|
||||
* En mode visu
|
||||
*/
|
||||
|
||||
$head=product_prepare_head($product, $user);
|
||||
$titre=$langs->trans("CardProduct".$product->type);
|
||||
dolibarr_fiche_head($head, 'suppliers', $titre);
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Reference
|
||||
print '<tr>';
|
||||
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
$product->load_previous_next_ref();
|
||||
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
|
||||
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
|
||||
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
|
||||
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Libelle
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
|
||||
|
||||
// Prix
|
||||
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
print $product->getLibStatut(2);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
if ($mesg) print($mesg);
|
||||
|
||||
|
||||
// Formulaire ajout prix
|
||||
if ($_GET["action"] == 'add_price' && $user->rights->produit->creer)
|
||||
{
|
||||
$langs->load("suppliers");
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print_fiche_titre($langs->trans("ChangeSupplierPrice"));
|
||||
} else {
|
||||
print_fiche_titre($langs->trans("AddSupplierPrice"));
|
||||
}
|
||||
print '<table class="border" width="100%">';
|
||||
print '<form action="fournisseurs.php?id='.$product->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateprice">';
|
||||
|
||||
if ($_GET["id_fourn"]) {
|
||||
print '<input type="hidden" name="id_fourn" value="'.$_GET["id_fourn"].'">';
|
||||
$product->fetch_fourn_data($_GET["id_fourn"]);
|
||||
print '<input type="hidden" name="ref_fourn" value="'.$product->ref_fourn.'">';
|
||||
} else {
|
||||
print '<tr><td>'.$langs->trans("Supplier").'</td><td colspan="3">';
|
||||
$html=new Form($db);
|
||||
$html->select_societes('','id_fourn','fournisseur=1');
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print '<input class="flat" name="ref_fourn" size="25" value="">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("Qty").'</td>';
|
||||
$quantity = $_GET["qty"] ? $_GET["qty"] : "1";
|
||||
print '<td><input class="flat" name="qty" size="5" value="'.$quantity.'"></td>';
|
||||
print '<td>'.$langs->trans("Price").'</td>';
|
||||
print '<td><input class="flat" name="price" size="8" value="'.price($_GET["price"]).'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="4" align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</form>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($_GET["action"] != 'add_price') {
|
||||
|
||||
if ($user->rights->produit->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$product->id.'&action=add_price">';
|
||||
print $langs->trans("AddSupplier").'</a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "\n</div>\n";
|
||||
print '<br>';
|
||||
|
||||
|
||||
if ($user->rights->fournisseur->lire) {
|
||||
// Titre liste des fournisseurs
|
||||
print '<table class="noborder" width="100%">';
|
||||
if ($product->isproduct()) $nblignefour=4;
|
||||
else $nblignefour=4;
|
||||
print '<tr class="liste_titre"><td valign="top">';
|
||||
print $langs->trans("Suppliers").'</td>';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="right">'.$langs->trans("BuyingPrice").'</td>';
|
||||
print '<td align="right">'.$langs->trans("UnitPrice").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Liste des fournisseurs
|
||||
$sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
|
||||
$sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product";
|
||||
$sql.= " WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id;
|
||||
$sql.= " ORDER BY lower(s.nom), pfp.quantity";
|
||||
|
||||
$resql="";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="../fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$objp->nom.'</a></td>';
|
||||
|
||||
// Fournisseur
|
||||
print '<td align="left">'.$objp->ref_fourn.'</td>';
|
||||
|
||||
// Quantité
|
||||
print '<td align="center">';
|
||||
print $objp->quantity;
|
||||
print '</td>';
|
||||
|
||||
// Prix quantité
|
||||
print '<td align="right">';
|
||||
print $objp->price?price($objp->price):"";
|
||||
print '</td>';
|
||||
|
||||
// Prix unitaire
|
||||
print '<td align="right">';
|
||||
print $objp->quantity?price($objp->price / $objp->quantity):" ";
|
||||
print '</td>';
|
||||
|
||||
// Modifier-Supprimer
|
||||
print '<td align="center">';
|
||||
if ($user->rights->produit->creer) {
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=add_price&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'&price='.$objp->price.'">'.img_edit()."</a>";
|
||||
print '<a href="fournisseurs.php?id='.$product->id.'&action=remove_fourn&id_fourn='.$objp->idp.'&qty='.$objp->quantity.'">';
|
||||
print img_disable($langs->trans("Remove")).'</a>';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
else {
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorUnknown");
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user