File encoding must be iso

This commit is contained in:
Laurent Destailleur 2008-05-21 02:12:09 +00:00
parent 8bb152de80
commit 61ac018214
2 changed files with 256 additions and 256 deletions

View File

@ -1,4 +1,4 @@
#Fri May 16 20:28:51 CEST 2008 #Wed May 21 02:07:20 GMT 2008
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//dev/skeletons/modMyModule.class.php=ISO-8859-1 encoding//dev/skeletons/modMyModule.class.php=ISO-8859-1
encoding//htdocs/about.php=ISO-8859-1 encoding//htdocs/about.php=ISO-8859-1
@ -40,7 +40,7 @@ encoding//htdocs/expedition/stats/month.php=ISO-8859-1
encoding//htdocs/facture.class.php=ISO-8859-1 encoding//htdocs/facture.class.php=ISO-8859-1
encoding//htdocs/fichinter/fichinter.class.php=ISO-8859-1 encoding//htdocs/fichinter/fichinter.class.php=ISO-8859-1
encoding//htdocs/fourn/facture/fiche.php=ISO-8859-1 encoding//htdocs/fourn/facture/fiche.php=ISO-8859-1
encoding//htdocs/fourn/facture/paiement.php=UTF-8 encoding//htdocs/fourn/facture/paiement.php=ISO-8859-1
encoding//htdocs/fourn/facture/paiementfourn.class.php=ISO-8859-1 encoding//htdocs/fourn/facture/paiementfourn.class.php=ISO-8859-1
encoding//htdocs/fourn/liste.php=ISO-8859-1 encoding//htdocs/fourn/liste.php=ISO-8859-1
encoding//htdocs/html.form.class.php=ISO-8859-1 encoding//htdocs/html.form.class.php=ISO-8859-1

View File

@ -21,11 +21,11 @@
*/ */
/** /**
\file htdocs/fourn/facture/paiement.php * \file htdocs/fourn/facture/paiement.php
\ingroup fournisseur,facture * \ingroup fournisseur,facture
\brief Paiements des factures fournisseurs * \brief Payment page for suppliers invoices
\version $Id$ * \version $Id$
*/ */
require('./pre.inc.php'); require('./pre.inc.php');
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php'); require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
@ -41,12 +41,12 @@ $sortfield = isset($_GET['sortfield'])?$_GET['sortfield']:$_POST['sortfield'];
$sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder']; $sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder'];
$page=isset($_GET['page'])?$_GET['page']:$_POST['page']; $page=isset($_GET['page'])?$_GET['page']:$_POST['page'];
// Sécurité accés client // Security check
$socid=0; $socid=0;
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
@ -55,130 +55,130 @@ if ($user->societe_id > 0)
*/ */
if ($action == 'add_paiement') if ($action == 'add_paiement')
{ {
$error = 0; $error = 0;
$datepaye = dolibarr_mktime(12, 0 , 0, $datepaye = dolibarr_mktime(12, 0 , 0,
$_POST['remonth'], $_POST['remonth'],
$_POST['reday'], $_POST['reday'],
$_POST['reyear']); $_POST['reyear']);
$paiement_id = 0; $paiement_id = 0;
$total = 0; $total = 0;
// Génère tableau des montants amounts // Genere tableau des montants amounts
$amounts = array(); $amounts = array();
foreach ($_POST as $key => $value) foreach ($_POST as $key => $value)
{
if (substr($key,0,7) == 'amount_')
{ {
if (substr($key,0,7) == 'amount_')
{
$other_facid = substr($key,7); $other_facid = substr($key,7);
$amounts[$other_facid] = $_POST[$key]; $amounts[$other_facid] = $_POST[$key];
$total = $total + $amounts[$other_facid]; $total = $total + $amounts[$other_facid];
}
} }
}
// Effectue les vérifications des parametres // Effectue les verifications des parametres
if ($_POST['paiementid'] <= 0) if ($_POST['paiementid'] <= 0)
{
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>';
$error++;
}
if ($conf->banque->enabled)
{
// Si module bank actif, un compte est obligatoire lors de la saisie
// d'un paiement
if (! $_POST['accountid'])
{ {
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('PaymentMode')).'</div>';
$error++;
}
if ($conf->banque->enabled)
{
// Si module bank actif, un compte est obligatoire lors de la saisie
// d'un paiement
if (! $_POST['accountid'])
{
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>'; $mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')).'</div>';
$error++; $error++;
}
} }
}
/* /*
\TODO A activer qd gestion avoir active et que creation facture fournisseur negative interdit \TODO A activer qd gestion avoir active et que creation facture fournisseur negative interdit
if ($total <= 0) if ($total <= 0)
{ {
$mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'</div>'; $mesg = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'</div>';
$error++; $error++;
} }
*/ */
if (! $error) if (! $error)
{
$db->begin();
// Creation de la ligne paiement
$paiement = new PaiementFourn($db);
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array of amounts
$paiement->paiementid = $_POST['paiementid'];
$paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment'];
$paiement_id = $paiement->create($user);
if ($paiement_id > 0)
{ {
if ($conf->banque->enabled) $db->begin();
{
// Insertion dans llx_bank
$label = "(SupplierInvoicePayment)";
$acc = new Account($db, $_POST['accountid']);
//paiementid contient "CHQ ou VIR par exemple"
$bank_line_id = $acc->addline($paiement->datepaye,
$paiement->paiementid,
$label,
0.0 - $paiement->total,
$paiement->num_paiement,
'',
$user);
// Mise a jour fk_bank dans llx_paiement. // Creation de la ligne paiement
// On connait ainsi le paiement qui a généré l'écriture bancaire $paiement = new PaiementFourn($db);
if ($bank_line_id > 0) $paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array of amounts
$paiement->paiementid = $_POST['paiementid'];
$paiement->num_paiement = $_POST['num_paiement'];
$paiement->note = $_POST['comment'];
$paiement_id = $paiement->create($user);
if ($paiement_id > 0)
{ {
$paiement->update_fk_bank($bank_line_id); if ($conf->banque->enabled)
// Mise a jour liens (pour chaque facture concernées par le paiement) {
foreach ($paiement->amounts as $key => $value) // Insertion dans llx_bank
{ $label = "(SupplierInvoicePayment)";
$facid = $key; $acc = new Account($db, $_POST['accountid']);
$fac = new FactureFournisseur($db); //paiementid contient "CHQ ou VIR par exemple"
$fac->fetch($facid); $bank_line_id = $acc->addline($paiement->datepaye,
$fac->fetch_fournisseur(); $paiement->paiementid,
$acc->add_url_line($bank_line_id, $label,
0.0 - $paiement->total,
$paiement->num_paiement,
'',
$user);
// Mise a jour fk_bank dans llx_paiement.
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0)
{
$paiement->update_fk_bank($bank_line_id);
// Mise a jour liens (pour chaque facture concernees par le paiement)
foreach ($paiement->amounts as $key => $value)
{
$facid = $key;
$fac = new FactureFournisseur($db);
$fac->fetch($facid);
$fac->fetch_fournisseur();
$acc->add_url_line($bank_line_id,
$paiement_id, $paiement_id,
DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=', DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=',
'(paiement)', '(paiement)',
'payment_supplier'); 'payment_supplier');
$acc->add_url_line($bank_line_id, $acc->add_url_line($bank_line_id,
$fac->fournisseur->id, $fac->fournisseur->id,
DOL_URL_ROOT.'/fourn/fiche.php?socid=', DOL_URL_ROOT.'/fourn/fiche.php?socid=',
$fac->fournisseur->nom, $fac->fournisseur->nom,
'company'); 'company');
} }
}
else
{
$error++;
}
}
} }
else else
{ {
$error++;
}
}
}
else
{
$mesg = '<div class="error">'.$langs->trans($paiement->error).'</div>'; $mesg = '<div class="error">'.$langs->trans($paiement->error).'</div>';
$error++; $error++;
} }
if ($error == 0) if ($error == 0)
{ {
$loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id;
$db->commit(); $db->commit();
Header('Location: '.$loc); Header('Location: '.$loc);
exit; exit;
} }
else else
{ {
$db->rollback(); $db->rollback();
}
} }
}
} }
/* /*
@ -191,28 +191,28 @@ $html=new Form($db);
if ($mesg) if ($mesg)
{ {
print '<tr><td colspan="3" align="center">'.$mesg.'</td></tr>'; print '<tr><td colspan="3" align="center">'.$mesg.'</td></tr>';
} }
if ($action == 'create' || $action == 'add_paiement') if ($action == 'create' || $action == 'add_paiement')
{ {
$facture = new FactureFournisseur($db); $facture = new FactureFournisseur($db);
$facture->fetch($facid); $facture->fetch($facid);
$sql = 'SELECT s.nom, s.rowid as socid,'; $sql = 'SELECT s.nom, s.rowid as socid,';
$sql.= ' f.rowid as ref, f.facnumber, f.amount, f.total_ttc as total'; $sql.= ' f.rowid as ref, f.facnumber, f.amount, f.total_ttc as total';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= ' WHERE f.fk_soc = s.rowid'; $sql .= ' WHERE f.fk_soc = s.rowid';
$sql .= ' AND f.rowid = '.$facid; $sql .= ' AND f.rowid = '.$facid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{ {
$num = $db->num_rows($resql);
if ($num)
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$total = $obj->total; $total = $obj->total;
@ -230,9 +230,9 @@ if ($action == 'create' || $action == 'add_paiement')
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$obj->nom.'</td></tr>'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$obj->nom.'</td></tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td>'; print '<tr><td>'.$langs->trans('Date').'</td><td>';
if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear']))
$sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
else else
$sel_date=''; $sel_date='';
$html->select_date($sel_date,'','','','',"addpaiement"); $html->select_date($sel_date,'','','','',"addpaiement");
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>'; print '<td>'.$langs->trans('Comments').'</td></tr>';
@ -243,17 +243,17 @@ if ($action == 'create' || $action == 'add_paiement')
print '<textarea name="comment" wrap="soft" cols="40" rows="4">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>'; print '<textarea name="comment" wrap="soft" cols="40" rows="4">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
print '<tr><td>'.$langs->trans('Numero').'</td><td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"></td></tr>'; print '<tr><td>'.$langs->trans('Numero').'</td><td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"></td></tr>';
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
print '<tr><td>'.$langs->trans('Account').'</td><td>'; print '<tr><td>'.$langs->trans('Account').'</td><td>';
$html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1);
print '</td></tr>'; print '</td></tr>';
} }
else else
{ {
print '<tr><td colspan="2">&nbsp;</td></tr>'; print '<tr><td colspan="2">&nbsp;</td></tr>';
} }
/* /*
* Autres factures impayées * Autres factures impayees
*/ */
$sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df'; $sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df';
$sql .= ', sum(pf.amount) as am'; $sql .= ', sum(pf.amount) as am';
@ -261,79 +261,79 @@ if ($action == 'create' || $action == 'add_paiement')
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
$sql .= ' WHERE f.fk_soc = '.$facture->socid; $sql .= ' WHERE f.fk_soc = '.$facture->socid;
$sql .= ' AND f.paye = 0'; $sql .= ' AND f.paye = 0';
$sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee
$sql .= ' GROUP BY f.facnumber'; $sql .= ' GROUP BY f.facnumber';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0) if ($num > 0)
{ {
$i = 0; $i = 0;
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
print $langs->trans('Invoices').'<br>'; print $langs->trans('Invoices').'<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>'; print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('RefSupplier').'</td>'; print '<td>'.$langs->trans('RefSupplier').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>'; print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td align="right">'.$langs->trans('AmountTTC').'</td>'; print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
print '<td align="right">'.$langs->trans('AlreadyPayed').'</td>'; print '<td align="right">'.$langs->trans('AlreadyPayed').'</td>';
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>'; print '<td align="right">'.$langs->trans('RemainderToPay').'</td>';
print '<td align="center">'.$langs->trans('Amount').'</td>'; print '<td align="center">'.$langs->trans('Amount').'</td>';
print '</tr>'; print '</tr>';
$var=True; $var=True;
$total=0; $total=0;
$totalrecu=0; $totalrecu=0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td><a href="fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref; print '<td><a href="fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref;
print '</a></td>'; print '</a></td>';
print '<td>'.$objp->facnumber.'</td>'; print '<td>'.$objp->facnumber.'</td>';
if ($objp->df > 0 ) if ($objp->df > 0 )
{ {
print '<td align="center">'; print '<td align="center">';
print dolibarr_print_date($objp->df).'</td>'; print dolibarr_print_date($objp->df).'</td>';
} }
else else
{ {
print '<td align="center"><b>!!!</b></td>'; print '<td align="center"><b>!!!</b></td>';
} }
print '<td align="right">'.price($objp->total_ttc).'</td>'; print '<td align="right">'.price($objp->total_ttc).'</td>';
print '<td align="right">'.price($objp->am).'</td>'; print '<td align="right">'.price($objp->am).'</td>';
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>'; print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
print '<td align="center">'; print '<td align="center">';
$namef = 'amount_'.$objp->facid; $namef = 'amount_'.$objp->facid;
print '<input type="text" size="8" name="'.$namef.'">'; print '<input type="text" size="8" name="'.$namef.'">';
print "</td></tr>\n"; print "</td></tr>\n";
$total+=$objp->total; $total+=$objp->total;
$total_ttc+=$objp->total_ttc; $total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am; $totalrecu+=$objp->am;
$i++; $i++;
} }
if ($i > 1) if ($i > 1)
{ {
// Print total // Print total
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td colspan="3" align="left">'.$langs->trans('TotalTTC').':</td>'; print '<td colspan="3" align="left">'.$langs->trans('TotalTTC').':</td>';
print '<td align="right"><b>'.price($total_ttc).'</b></td>'; print '<td align="right"><b>'.price($total_ttc).'</b></td>';
print '<td align="right"><b>'.price($totalrecu).'</b></td>'; print '<td align="right"><b>'.price($totalrecu).'</b></td>';
print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>'; print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
print "</table></td></tr>\n"; print "</table></td></tr>\n";
} }
$db->free($resql); $db->free($resql);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
/* /*
* *
@ -341,8 +341,8 @@ if ($action == 'create' || $action == 'add_paiement')
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"></td></tr>'; print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
}
} }
}
} }
/* /*
@ -350,57 +350,57 @@ if ($action == 'create' || $action == 'add_paiement')
*/ */
if (! $_GET['action'] && ! $_POST['action']) if (! $_GET['action'] && ! $_POST['action'])
{ {
if ($page == -1) $page = 0 ; if ($page == -1) $page = 0 ;
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
if (! $sortorder) $sortorder='DESC'; if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='p.datep'; if (! $sortfield) $sortfield='p.datep';
$sql = 'SELECT p.rowid, p.rowid as pid, '.$db->pdate('p.datep').' as dp, p.amount as pamount,'; $sql = 'SELECT p.rowid, p.rowid as pid, '.$db->pdate('p.datep').' as dp, p.amount as pamount,';
$sql.= ' f.rowid as facid, f.rowid as ref, f.facnumber, f.amount,'; $sql.= ' f.rowid as facid, f.rowid as ref, f.facnumber, f.amount,';
$sql.= ' s.rowid as socid, s.nom,'; $sql.= ' s.rowid as socid, s.nom,';
$sql.= ' c.libelle as paiement_type, p.num_paiement,'; $sql.= ' c.libelle as paiement_type, p.num_paiement,';
$sql.= ' ba.rowid as bid, ba.label'; $sql.= ' ba.rowid as bid, ba.label';
if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user "; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn '; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn ';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
if (!$user->rights->societe->client->voir) $sql .= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir) $sql .= " WHERE s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) if ($socid)
{
$sql .= ' WHERE f.fk_soc = '.$socid;
}
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
$sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=True;
print_barre_liste($langs->trans('SupplierPayments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('RefPayment'),'paiement.php','rowid','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Invoice'),'paiement.php','facnumber','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('ThirdParty'),'paiement.php','s.nom','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Type'),'paiement.php','c.libelle','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Account'),'paiement.php','ba.label','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('AmountTTC'),'paiement.php','f.amount','','','align="right"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{ {
$sql .= ' WHERE f.fk_soc = '.$socid;
}
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
$sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=True;
print_barre_liste($langs->trans('SupplierPayments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('RefPayment'),'paiement.php','rowid','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Invoice'),'paiement.php','facnumber','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('ThirdParty'),'paiement.php','s.nom','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Type'),'paiement.php','c.libelle','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Account'),'paiement.php','ba.label','','','',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('AmountTTC'),'paiement.php','f.amount','','','align="right"',$sortfield,$sortorder);
print '<td>&nbsp;</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
@ -426,13 +426,13 @@ if (! $_GET['action'] && ! $_POST['action'])
print '<td align="right">'.price($objp->pamount).'</td><td>&nbsp;</td>'; print '<td align="right">'.price($objp->pamount).'</td><td>&nbsp;</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
}
print "</table>";
}
else
{
dolibarr_print_error($db);
} }
print "</table>";
}
else
{
dolibarr_print_error($db);
}
} }
$db->close(); $db->close();