Look: Uniformisation onglet facture fournisseur
This commit is contained in:
parent
95239fcd48
commit
a27d69264b
@ -23,10 +23,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/fourn/facture/fiche.php
|
||||
\ingroup facture
|
||||
\brief Page des la fiche facture fournisseur
|
||||
\version $Revision$
|
||||
\file htdocs/fourn/facture/fiche.php
|
||||
\ingroup facture
|
||||
\brief Page des la fiche facture fournisseur
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
@ -39,9 +39,7 @@ $langs->load("bills");
|
||||
$langs->load("suppliers");
|
||||
$langs->load("companies");
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
// Sécurité accés client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
@ -222,469 +220,471 @@ if ($_GET["action"] == 'add_ligne')
|
||||
if ($_GET["action"] == 'create' or $_GET["action"] == 'copy')
|
||||
{
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_titre($langs->trans("NewBill"));
|
||||
llxHeader();
|
||||
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
print_titre($langs->trans("NewBill"));
|
||||
|
||||
if ($_GET["action"] == 'copy')
|
||||
if ($mesg) { print "$mesg<br>"; }
|
||||
|
||||
if ($_GET["action"] == 'copy')
|
||||
{
|
||||
$fac_ori = new FactureFournisseur($db);
|
||||
$fac_ori->fetch($_GET["facid"]);
|
||||
}
|
||||
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||
|
||||
print '<td><select name="socidp">';
|
||||
|
||||
$sql = "SELECT s.nom, s.prefix_comm, s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.fournisseur = 1";
|
||||
if ($_GET["socid"] > 0 )
|
||||
{
|
||||
$sql .= " AND s.idp =".$_GET["socid"];
|
||||
$fac_ori = new FactureFournisseur($db);
|
||||
$fac_ori->fetch($_GET["facid"]);
|
||||
}
|
||||
|
||||
print '<form action="fiche.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||
|
||||
$sql .= " ORDER BY s.nom ASC";
|
||||
print '<td><select name="socidp">';
|
||||
|
||||
if ( $db->query($sql) )
|
||||
$sql = "SELECT s.nom, s.prefix_comm, s.idp";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.fournisseur = 1";
|
||||
if ($_GET["socid"] > 0 )
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
print '<option value="'.$obj->idp;
|
||||
|
||||
if ($_GET["socid"] == $obj->idp)
|
||||
{
|
||||
print '" selected>'.$obj->nom.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '">'.$obj->nom.'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= " AND s.idp =".$_GET["socid"];
|
||||
}
|
||||
print '</select></td>';
|
||||
print '<td>'.$langs->trans("Comments").'</td></tr>';
|
||||
$sql .= " ORDER BY s.nom ASC";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td><input name="facnumber" type="text"></td>';
|
||||
|
||||
print '<td rowspan="4" valign="top"><textarea name="note" wrap="soft" cols="30" rows="6"></textarea></td></tr>';
|
||||
if ($_GET["action"] == 'copy')
|
||||
if ( $db->query($sql) )
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="libelle" value="'.$fac_ori->libelle.'" type="text"></td></tr>';
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object();
|
||||
print '<option value="'.$obj->idp;
|
||||
|
||||
if ($_GET["socid"] == $obj->idp)
|
||||
{
|
||||
print '" selected>'.$obj->nom.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '">'.$obj->nom.'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
print '</select></td>';
|
||||
print '<td>'.$langs->trans("Comments").'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td><input name="facnumber" type="text"></td>';
|
||||
|
||||
print '<td rowspan="4" valign="top"><textarea name="note" wrap="soft" cols="30" rows="6"></textarea></td></tr>';
|
||||
if ($_GET["action"] == 'copy')
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="libelle" type="text"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="libelle" value="'.$fac_ori->libelle.'" type="text"></td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date();
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateEcheance").'</td><td>';
|
||||
$html->select_date('','ech');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUTTC").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
for ($i = 1 ; $i < 9 ; $i++)
|
||||
else
|
||||
{
|
||||
if ($_GET["action"] == 'copy')
|
||||
{
|
||||
$value_label = $fac_ori->lignes[$i-1][0];
|
||||
$value_pu = $fac_ori->lignes[$i-1][1];
|
||||
$value_qty = $fac_ori->lignes[$i-1][3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value_qty = "1";
|
||||
}
|
||||
print '<tr><td>'.$i.'</td>';
|
||||
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
|
||||
print '<td align="center"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
|
||||
print '<td align="center"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="center">';
|
||||
$html->select_tva("tauxtva".$i);
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input size="30" name="libelle" type="text"></td></tr>';
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date();
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("DateEcheance").'</td><td>';
|
||||
$html->select_date('','ech');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td> </td><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUTTC").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
for ($i = 1 ; $i < 9 ; $i++)
|
||||
{
|
||||
if ($_GET["action"] == 'copy')
|
||||
{
|
||||
$value_label = $fac_ori->lignes[$i-1][0];
|
||||
$value_pu = $fac_ori->lignes[$i-1][1];
|
||||
$value_qty = $fac_ori->lignes[$i-1][3];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value_qty = "1";
|
||||
}
|
||||
print '<tr><td>'.$i.'</td>';
|
||||
print '<td><input size="50" name="label'.$i.'" value="'.$value_label.'" type="text"></td>';
|
||||
print '<td align="center"><input type="text" size="8" name="amount'.$i.'" value="'.$value_pu.'"></td>';
|
||||
print '<td align="center"><input type="text" size="3" name="qty'.$i.'" value="'.$value_qty.'"></td>';
|
||||
print '<td align="center">';
|
||||
$html->select_tva("tauxtva".$i);
|
||||
print '</td>';
|
||||
print '<td align="center"><input type="text" size="8" name="amountttc'.$i.'" value=""></td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print '<p align="center"><input type="submit" value="'.$langs->trans("Save").'"></p>';
|
||||
print "</form>";
|
||||
|
||||
print "</table>";
|
||||
print '<p align="center"><input type="submit" value="'.$langs->trans("Save").'"></p>';
|
||||
print "</form>";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Fiche facture en mode visu ou edition
|
||||
*
|
||||
*/
|
||||
if ($_GET["facid"] > 0)
|
||||
/*
|
||||
* Fiche facture en mode visu ou edition
|
||||
*
|
||||
*/
|
||||
if ($_GET["facid"] > 0)
|
||||
{
|
||||
|
||||
$fac = new FactureFournisseur($db);
|
||||
$fac->fetch($_GET["facid"]);
|
||||
$fac = new FactureFournisseur($db);
|
||||
$fac->fetch($_GET["facid"]);
|
||||
|
||||
$societe = new Fournisseur($db);
|
||||
$societe = new Fournisseur($db);
|
||||
|
||||
if ( $societe->fetch($fac->socidp) )
|
||||
{
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$fac->socidp;
|
||||
$addons[0][1] = $societe->nom;
|
||||
}
|
||||
llxHeader('','', $addons);
|
||||
if ( $societe->fetch($fac->socidp) )
|
||||
{
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$fac->socidp;
|
||||
$addons[0][1] = $societe->nom;
|
||||
}
|
||||
llxHeader('','', $addons);
|
||||
|
||||
if ($mesg) { print "<br>$mesg<br>"; }
|
||||
if ($mesg) { print "<br>$mesg<br>"; }
|
||||
|
||||
if ($_GET["action"] == "edit")
|
||||
{
|
||||
if ($_GET["action"] == "edit")
|
||||
{
|
||||
|
||||
print_titre($langs->trans("Bill").': '.$fac->ref);
|
||||
|
||||
print '<form action="fiche.php?facid='.$fac->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
|
||||
|
||||
print '<td width="20%">'.stripslashes($fac->socnom).'</td>';
|
||||
print '<td width="60%" valign="top">'.$langs->trans("Comments").'</tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td valign="top">';
|
||||
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
|
||||
|
||||
print '<td rowspan="8" width="60%" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="10">';
|
||||
print stripslashes($fac->note);
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input size="30" name="libelle" type="text" value="'.stripslashes($fac->libelle).'"></td></tr>';
|
||||
print_titre($langs->trans("Bill").': '.$fac->ref);
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountHT").' / '.$langs->trans("AmountTTC").'</td>';
|
||||
print '<td>'.price($fac->total_ht).' / '.price($fac->total_ttc).'</td></tr>';
|
||||
print '<form action="fiche.php?facid='.$fac->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date($fac->datep);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date($fac->date_echeance,'ech');
|
||||
print "</td></tr>";
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Company").'</td>';
|
||||
|
||||
$authorfullname=" ";
|
||||
if ($fac->author)
|
||||
{
|
||||
$author = new User($db, $fac->author);
|
||||
$author->fetch('');
|
||||
$authorfullname=$author->fullname;
|
||||
}
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td>$authorfullname</td></tr>";
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$fac->LibStatut($fac->paye,$fac->statut)."</td></tr>";
|
||||
print "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$langs->trans("Save")."\"></td></tr>";
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print '<br>';
|
||||
|
||||
print "<form action=\"fiche.php?facid=$fac->id&action=add_ligne\" method=\"post\">";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUTTC").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("TotalHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td align="right">'.$langs->trans("TotalTTC").'</td><td> </td></tr>';
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
print "<tr $bc[1]>".'<td>'.$fac->lignes[$i][0]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1])."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100)))."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][3]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][4])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][2]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][5])."</td>";
|
||||
print '<td align="right">'.price($fac->lignes[$i][6])."</td>";
|
||||
print '<td align="center">';
|
||||
print '<a href="fiche.php?facid='.$fac->id.'&action=del_ligne&ligne_id='.$fac->lignes[$i][7].'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/* Nouvelle ligne */
|
||||
print "<tr $bc[1]>";
|
||||
print '<td>';
|
||||
print '<input size="30" name="label" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="8" name="amount" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="8" name="amountttc" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="2" name="qty" type="text" value="1">';
|
||||
print '</td>';
|
||||
print '<td align="center">-</td>';
|
||||
print '<td align="center">';
|
||||
$html->select_tva("tauxtva");
|
||||
print '</td><td align="center" colspan="2">';
|
||||
print ' ';
|
||||
print '</td><td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = "fiche.php?facid=".$fac->id;
|
||||
$head[$h][1] = $langs->trans("SupplierBill").': '.$fac->ref;
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected);
|
||||
print '<td width="20%">'.stripslashes($fac->socnom).'</td>';
|
||||
print '<td width="60%" valign="top">'.$langs->trans("Comments").'</tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Ref").'</td><td valign="top">';
|
||||
print '<input name="facnumber" type="text" value="'.$fac->ref.'"></td>';
|
||||
|
||||
print '<td rowspan="8" width="60%" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="60" rows="10">';
|
||||
print stripslashes($fac->note);
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input size="30" name="libelle" type="text" value="'.stripslashes($fac->libelle).'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountHT").' / '.$langs->trans("AmountTTC").'</td>';
|
||||
print '<td>'.price($fac->total_ht).' / '.price($fac->total_ttc).'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date($fac->datep);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date").'</td><td>';
|
||||
$html->select_date($fac->date_echeance,'ech');
|
||||
print "</td></tr>";
|
||||
|
||||
$authorfullname=" ";
|
||||
if ($fac->author)
|
||||
{
|
||||
$author = new User($db, $fac->author);
|
||||
$author->fetch('');
|
||||
$authorfullname=$author->fullname;
|
||||
}
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td>$authorfullname</td></tr>";
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$fac->LibStatut($fac->paye,$fac->statut)."</td></tr>";
|
||||
print "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$langs->trans("Save")."\"></td></tr>";
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print '<br>';
|
||||
|
||||
print "<form action=\"fiche.php?facid=$fac->id&action=add_ligne\" method=\"post\">";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUTTC").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("TotalHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td align="right">'.$langs->trans("TotalTTC").'</td><td> </td></tr>';
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
print "<tr $bc[1]>".'<td>'.$fac->lignes[$i][0]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1])."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1] * (1+($fac->lignes[$i][2]/100)))."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][3]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][4])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][2]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][5])."</td>";
|
||||
print '<td align="right">'.price($fac->lignes[$i][6])."</td>";
|
||||
print '<td align="center">';
|
||||
print '<a href="fiche.php?facid='.$fac->id.'&action=del_ligne&ligne_id='.$fac->lignes[$i][7].'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/* Nouvelle ligne */
|
||||
print "<tr $bc[1]>";
|
||||
print '<td>';
|
||||
print '<input size="30" name="label" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="8" name="amount" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="8" name="amountttc" type="text">';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<input size="2" name="qty" type="text" value="1">';
|
||||
print '</td>';
|
||||
print '<td align="center">-</td>';
|
||||
print '<td align="center">';
|
||||
$html->select_tva("tauxtva");
|
||||
print '</td><td align="center" colspan="2">';
|
||||
print ' ';
|
||||
print '</td><td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
print "</table>";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
*
|
||||
*/
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = "fiche.php?facid=".$fac->id;
|
||||
$head[$h][1] = $langs->trans("SupplierBill").': '.$fac->ref;
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
$html->form_confirm("fiche.php?facid=$fac->id",$langs->trans("ValidateBill"),$langs->trans("ConfirmValidateBill"),"confirm_valid");
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
print "<table border=\"0\" width=\"100%\">";
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
/*
|
||||
* Confirmation de la validation
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'valid')
|
||||
{
|
||||
$html->form_confirm("fiche.php?facid=$fac->id",$langs->trans("ValidateBill"),$langs->trans("ConfirmValidateBill"),"confirm_valid");
|
||||
print '<br />';
|
||||
}
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td colspan=\"2\"><b><a href=\"../fiche.php?socid=$fac->socidp\">$fac->socnom</a></b></td>";
|
||||
print "<td align=\"right\"><a href=\"index.php?socid=$fac->socidp\">".$langs->trans("OtherBills")."</a></td>\n";
|
||||
print "</tr>";
|
||||
print "<table border=\"0\" width=\"100%\">";
|
||||
print '<tr><td width="50%" valign="top">';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Date")."</td><td colspan=\"3\">";
|
||||
print dolibarr_print_date($fac->datep,"%A %e %B %Y")."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">';
|
||||
print $fac->libelle;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$authorfullname=" ";
|
||||
if ($fac->author)
|
||||
{
|
||||
$author = new User($db, $fac->author);
|
||||
$author->fetch('');
|
||||
$authorfullname=$author->fullname;
|
||||
}
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td colspan=\"3\">$authorfullname</td>";
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$fac->LibStatut($fac->paye,$fac->statut)."</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("TotalHT").'</td><td align="center"><b>'.price($fac->total_ht)."</b></td>";
|
||||
print '<td align="right">'.$langs->trans("VAT").'</td><td align="center">'.price($fac->total_tva)."</td></tr>";
|
||||
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="3" align="center">'.price($fac->total_ttc)."</td></tr>";
|
||||
if (strlen($fac->note))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Comments").'</td><td colspan="3">';
|
||||
print nl2br(stripslashes($fac->note));
|
||||
print '</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print "</td><td valign=\"top\">";
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Company")."</td><td colspan=\"2\"><b><a href=\"../fiche.php?socid=$fac->socidp\">$fac->socnom</a></b></td>";
|
||||
print "<td align=\"right\"><a href=\"index.php?socid=$fac->socidp\">".$langs->trans("OtherBills")."</a></td>\n";
|
||||
print "</tr>";
|
||||
|
||||
/*
|
||||
* Paiements
|
||||
*/
|
||||
print '<tr><td>'.$langs->trans("Date")."</td><td colspan=\"3\">";
|
||||
print dolibarr_print_date($fac->datep,"%A %d %B %Y")."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">';
|
||||
print $fac->libelle;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>';
|
||||
$authorfullname=" ";
|
||||
if ($fac->author)
|
||||
{
|
||||
$author = new User($db, $fac->author);
|
||||
$author->fetch('');
|
||||
$authorfullname=$author->fullname;
|
||||
}
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td colspan=\"3\">$authorfullname</td>";
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$fac->LibStatut($fac->paye,$fac->statut)."</td></tr>";
|
||||
|
||||
$sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||
$sql .= " WHERE p.fk_facture_fourn = ".$fac->id." AND p.fk_paiement = c.id";
|
||||
print '<tr><td>'.$langs->trans("TotalHT").'</td><td align="center"><b>'.price($fac->total_ht)."</b></td>";
|
||||
print '<td align="right">'.$langs->trans("VAT").'</td><td align="center">'.price($fac->total_tva)."</td></tr>";
|
||||
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td colspan="3" align="center">'.price($fac->total_ttc)."</td></tr>";
|
||||
if (strlen($fac->note))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Comments").'</td><td colspan="3">';
|
||||
print nl2br(stripslashes($fac->note));
|
||||
print '</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Payments").' :</td>';
|
||||
print '<td>'.$langs->trans("DateEcheance")." : ";
|
||||
print dolibarr_print_date($fac->date_echeance,"%A %e %B %Y")."</td></tr>\n";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
$tdsup=' colspan="2"';
|
||||
}
|
||||
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td><td$tdsup> </td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".img_object($langs->trans("Payment"),"payment").' '.dolibarr_print_date($objp->dp)."</td>\n";
|
||||
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
|
||||
print "<td align=\"right\">".price($objp->amount)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td>\n";
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<td align="center">';
|
||||
print '<a href="fiche.php?facid='.$fac->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
print "</tr>";
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
print "<tr class=\"liste_total\"><td colspan=\"2\" align=\"right\">".$langs->trans("Total")." :</td><td align=\"right\"><b>".price($total)."</b></td><td$tdsup>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
|
||||
|
||||
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
$resteapayer = abs($fac->total_ttc - $total);
|
||||
print "<tr class=\liste_total\"><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print '<td align="right"><b>'.price($resteapayer)."</b></td><td$tdsup>".$langs->trans("Currency".$conf->monnaie)."</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
print "</td><td valign=\"top\">";
|
||||
|
||||
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
/*
|
||||
* Liste des paiements
|
||||
*/
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("DateEcheance").'</td><td>';
|
||||
print dolibarr_print_date($fac->date_echeance,"%A %d %B %Y")."</td></tr>\n";
|
||||
|
||||
print '<tr><td colspan="2">'.$langs->trans("Payments").'</td></tr>';
|
||||
|
||||
$sql = "SELECT ".$db->pdate("datep")." as dp, p.amount, c.libelle as paiement_type, p.num_paiement, p.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||
$sql .= " WHERE p.fk_facture_fourn = ".$fac->id." AND p.fk_paiement = c.id";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
print '<tr><td colspan="2">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
$tdsup=' colspan="2"';
|
||||
}
|
||||
print "<td align=\"right\">".$langs->trans("AmountTTC")."</td><td$tdsup> </td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td nowrap>".img_object($langs->trans("Payment"),"payment").' '.dolibarr_print_date($objp->dp)."</td>\n";
|
||||
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
|
||||
print "<td align=\"right\">".price($objp->amount)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td>\n";
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<td align="center">';
|
||||
print '<a href="fiche.php?facid='.$fac->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
print "</tr>";
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
print "<tr class=\"liste_total\"><td colspan=\"2\" align=\"right\">".$langs->trans("Total")." :</td><td align=\"right\"><b>".price($total)."</b></td><td$tdsup>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
|
||||
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print '<p><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("TotalHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td align="right">'.$langs->trans("TotalTTC").'</td></tr>';
|
||||
$var=1;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>".'<td>'.$fac->lignes[$i][0]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][3]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][4])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][2]." %</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][5])."</td>";
|
||||
print '<td align="right">'.price($fac->lignes[$i][6])."</td>";
|
||||
if ($fac->statut > 0)
|
||||
{
|
||||
$resteapayer = abs($fac->total_ttc - $total);
|
||||
print "<tr class=\liste_total\"><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print '<td align="right"><b>'.price($resteapayer)."</b></td><td$tdsup>".$langs->trans("Currency".$conf->monnaie)."</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
print "</table>";
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
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
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=edit">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<a class="butAction" href="paiement.php?facid='.$fac->id.'&action=create">'.$langs->trans("DoPaiement").'</a>';
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && price($resteapayer) <= 0 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=payed\">".$langs->trans('ClassifyPayed')."</a>";
|
||||
}
|
||||
|
||||
if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider)
|
||||
{
|
||||
if ($_GET["action"] <> "edit")
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=valid\">".$langs->trans('Valid')."</a>";
|
||||
}
|
||||
else
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
*/
|
||||
print '<p><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
|
||||
print '<td align="center">'.$langs->trans("PriceUHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
print '<td align="center">'.$langs->trans("TotalHT").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td align="center">'.$langs->trans("VAT").'</td>';
|
||||
print '<td align="right">'.$langs->trans("TotalTTC").'</td></tr>';
|
||||
$var=1;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>".'<td>'.$fac->lignes[$i][0]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][1])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][3]."</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][4])."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i][2]." %</td>";
|
||||
print '<td align="center">'.price($fac->lignes[$i][5])."</td>";
|
||||
print '<td align="right">'.price($fac->lignes[$i][6])."</td>";
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
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
|
||||
{
|
||||
print '<a class="butAction" href="fiche.php?facid='.$fac->id.'&action=edit">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<a class="butAction" href="paiement.php?facid='.$fac->id.'&action=create">'.$langs->trans("DoPaiement").'</a>';
|
||||
}
|
||||
|
||||
if ($fac->statut == 1 && price($resteapayer) <= 0 && $fac->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=payed\">".$langs->trans('ClassifyPayed')."</a>";
|
||||
}
|
||||
|
||||
if ($fac->statut == 0 && $user->rights->fournisseur->facture->valider)
|
||||
{
|
||||
if ($_GET["action"] <> "edit")
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=valid\">".$langs->trans('Valid')."</a>";
|
||||
}
|
||||
else
|
||||
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=copy&socid=$fac->socidp\">".$langs->trans('Copy')."</a>";
|
||||
}
|
||||
|
||||
if ($_GET["action"] != "edit" && $fac->statut == 0 && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="index.php?facid='.$fac->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
if ($user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print "<a class=\"butAction\" href=\"fiche.php?facid=$fac->id&action=copy&socid=$fac->socidp\">".$langs->trans('Copy')."</a>";
|
||||
}
|
||||
|
||||
if ($_GET["action"] != "edit" && $fac->statut == 0 && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="index.php?facid='.$fac->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user