New: Add bank account on payment list of invoice card.
This commit is contained in:
parent
aa9648288c
commit
dc09960143
@ -11,6 +11,8 @@ For users:
|
||||
- New: Monaco is like France for default vat calculation
|
||||
- New: Can list elements (invoices, orders or proposals on a particular
|
||||
user contact). This allow to view a "basket" of its elements.
|
||||
- New: Add bank account on payment list of invoice card.
|
||||
- New: Cloning project allow to clones task, notes, files, contacts.
|
||||
- New: Enhance default style.
|
||||
|
||||
For developers:
|
||||
|
||||
@ -1584,6 +1584,7 @@ llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES
|
||||
$form = new Form($db);
|
||||
$htmlother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
$bankaccountstatic=new Account($db);
|
||||
$now=dol_now();
|
||||
|
||||
|
||||
@ -2520,8 +2521,9 @@ else
|
||||
* List of payments
|
||||
*/
|
||||
|
||||
$nbrows=8;
|
||||
$nbrows=8; $nbcols=2;
|
||||
if ($conf->projet->enabled) $nbrows++;
|
||||
if ($conf->banque->enabled) $nbcols++;
|
||||
|
||||
//Local taxes
|
||||
if ($mysoc->pays_code=='ES')
|
||||
@ -2538,6 +2540,7 @@ else
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.($object->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>';
|
||||
print '<td>'.$langs->trans('Type').'</td>';
|
||||
if ($conf->banque->enabled) print '<td align="right">'.$langs->trans('BankAccount').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td>';
|
||||
print '<td width="18"> </td>';
|
||||
print '</tr>';
|
||||
@ -2545,12 +2548,15 @@ else
|
||||
$var=true;
|
||||
|
||||
// Payments already done (from payment on this invoice)
|
||||
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid,';
|
||||
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
|
||||
$sql.= ' c.code as payment_code, c.libelle as payment_label,';
|
||||
$sql.= ' pf.amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||
$sql.= ' pf.amount,';
|
||||
$sql.= ' ba.rowid as baid, ba.ref, ba.label';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
|
||||
$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.= ' WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
|
||||
$sql.= ' ORDER BY dp, tms';
|
||||
$sql.= ' ORDER BY p.datep, p.tms';
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -2560,19 +2566,35 @@ else
|
||||
|
||||
if ($object->type != 2)
|
||||
{
|
||||
while ($i < $num)
|
||||
if ($num > 0)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print dol_print_date($db->jdate($objp->dp),'day').'</a></td>';
|
||||
$label=($langs->trans("PaymentType".$objp->payment_code)!=("PaymentType".$objp->payment_code))?$langs->trans("PaymentType".$objp->payment_code):$objp->payment_label;
|
||||
print '<td>'.$label.' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print dol_print_date($db->jdate($objp->dp),'day').'</a></td>';
|
||||
$label=($langs->trans("PaymentType".$objp->payment_code)!=("PaymentType".$objp->payment_code))?$langs->trans("PaymentType".$objp->payment_code):$objp->payment_label;
|
||||
print '<td>'.$label.' '.$objp->num_paiement.'</td>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
$bankaccountstatic->id=$objp->baid;
|
||||
$bankaccountstatic->ref=$objp->ref;
|
||||
$bankaccountstatic->label=$objp->ref;
|
||||
print '<td align="right">';
|
||||
print $bankaccountstatic->getNomUrl(1,'transactions');
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr '.$bc[$var].'><td colspan="'.$nbcols.'">'.$langs->trans("None").'</td><td></td><td></td></tr>';
|
||||
}
|
||||
}
|
||||
$db->free($result);
|
||||
@ -2585,7 +2607,7 @@ else
|
||||
if ($object->type != 2)
|
||||
{
|
||||
// Total already paid
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">';
|
||||
if ($object->type != 3) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits');
|
||||
else print $langs->trans('AlreadyPaid');
|
||||
print ' :</td><td align="right">'.price($totalpaye).'</td><td> </td></tr>';
|
||||
@ -2609,7 +2631,7 @@ else
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$invoice->fetch($obj->fk_facture_source);
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">';
|
||||
if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
|
||||
if ($invoice->type == 3) print $langs->trans("Deposit").' ';
|
||||
print $invoice->getNomUrl(0);
|
||||
@ -2631,7 +2653,7 @@ else
|
||||
// Paye partiellement 'escompte'
|
||||
if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'discount_vat')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right" nowrap="1">';
|
||||
print $form->textwithpicto($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
|
||||
print '</td><td align="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
@ -2639,7 +2661,7 @@ else
|
||||
// Paye partiellement ou Abandon 'badcustomer'
|
||||
if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'badcustomer')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right" nowrap="1">';
|
||||
print $form->textwithpicto($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
|
||||
print '</td><td align="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
//$resteapayeraffiche=0;
|
||||
@ -2647,7 +2669,7 @@ else
|
||||
// Paye partiellement ou Abandon 'product_returned'
|
||||
if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'product_returned')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right" nowrap="1">';
|
||||
print $form->textwithpicto($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
|
||||
print '</td><td align="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
@ -2655,7 +2677,7 @@ else
|
||||
// Paye partiellement ou Abandon 'abandon'
|
||||
if (($object->statut == 2 || $object->statut == 3) && $object->close_code == 'abandon')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right" nowrap="1">';
|
||||
$text=$langs->trans("HelpAbandonOther");
|
||||
if ($object->close_note) $text.='<br><br><b>'.$langs->trans("Reason").'</b>:'.$object->close_note;
|
||||
print $form->textwithpicto($langs->trans("Abandoned").':',$text,-1);
|
||||
@ -2664,10 +2686,10 @@ else
|
||||
}
|
||||
|
||||
// Billed
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($object->total_ttc).'</td><td> </td></tr>';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($object->total_ttc).'</td><td> </td></tr>';
|
||||
|
||||
// Remainder to pay
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">';
|
||||
if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
|
||||
else print $langs->trans('ExcessReceived');
|
||||
print ' :</td>';
|
||||
@ -2677,7 +2699,7 @@ else
|
||||
else
|
||||
{
|
||||
// Sold credit note
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('TotalTTC').' :</td>';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans('TotalTTC').' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price(abs($object->total_ttc)).'</b></td><td> </td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ class PaiementFourn extends Paiement
|
||||
if ($this->total <> 0) // On accepte les montants negatifs
|
||||
{
|
||||
$now=dol_now();
|
||||
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
|
||||
$sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
|
||||
$sql.= ' VALUES ('.$this->db->idate($now).',';
|
||||
@ -257,7 +257,7 @@ class PaiementFourn extends Paiement
|
||||
{
|
||||
if (count($billsarray))
|
||||
{
|
||||
$this->error='Impossible de supprimer un paiement portant sur au moins une facture a l\'etat paye';
|
||||
$this->error='Can\'t delete a payment shared by at least one invoice with status payed';
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -285,11 +285,13 @@ class PaiementFourn extends Paiement
|
||||
// Efface la ligne de paiement (dans paiement_facture et paiement)
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
|
||||
$sql.= ' WHERE fk_paiementfourn = '.$this->id;
|
||||
dol_syslog("sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn';
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
dol_syslog("sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
|
||||
@ -198,14 +198,15 @@ elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
|
||||
}
|
||||
|
||||
// Delete payment
|
||||
elseif($action == 'deletepaiement')
|
||||
elseif ($action == 'deletepaiement')
|
||||
{
|
||||
$object->fetch($id);
|
||||
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
$paiementfourn = new PaiementFourn($db);
|
||||
$paiementfourn->fetch($_GET['paiement_id']);
|
||||
$paiementfourn->delete();
|
||||
$paiementfourn->fetch(GETPOST('paiement_id'));
|
||||
$result=$paiementfourn->delete();
|
||||
if ($result < 0) $mesg='<div class="error">'.$paiementfourn->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -899,6 +900,7 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$bankaccountstatic=new Account($db);
|
||||
|
||||
llxHeader('','','');
|
||||
|
||||
@ -1258,9 +1260,7 @@ else
|
||||
if ($ret == 'html') print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression de la facture fournisseur
|
||||
*/
|
||||
// Confirmation de la suppression de la facture fournisseur
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBill'), $langs->trans('ConfirmDeleteBill'), 'confirm_delete', '', 0, 1);
|
||||
@ -1268,9 +1268,9 @@ else
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Facture
|
||||
*/
|
||||
/**
|
||||
* Invoice
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
@ -1334,9 +1334,10 @@ else
|
||||
|
||||
/*
|
||||
* List of payments
|
||||
*/
|
||||
$nbrows=7;
|
||||
*/
|
||||
$nbrows=7; $nbcols=2;
|
||||
if ($conf->projet->enabled) $nbrows++;
|
||||
if ($conf->banque->enabled) $nbcols++;
|
||||
|
||||
// Local taxes
|
||||
if ($mysoc->country_code=='ES')
|
||||
@ -1347,14 +1348,17 @@ else
|
||||
|
||||
print '<td rowspan="'.$nbrows.'" valign="top">';
|
||||
|
||||
// TODO move to DAO class
|
||||
$sql = 'SELECT datep as dp, pf.amount,';
|
||||
$sql .= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
|
||||
$sql .= ' WHERE pf.fk_facturefourn = '.$object->id;
|
||||
$sql .= ' ORDER BY dp DESC';
|
||||
$sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,';
|
||||
$sql.= ' c.libelle as paiement_type,';
|
||||
$sql.= ' pf.amount,';
|
||||
$sql.= ' ba.rowid as baid, ba.ref, ba.label';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p';
|
||||
$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.'c_paiement as c ON p.fk_paiement = c.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
|
||||
$sql.= ' WHERE pf.fk_facturefourn = '.$object->id;
|
||||
$sql.= ' ORDER BY p.datep, p.tms';
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -1365,41 +1369,58 @@ else
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Payments').'</td>';
|
||||
print '<td>'.$langs->trans('Type').'</td>';
|
||||
if ($conf->banque->enabled) print '<td align="right">'.$langs->trans('BankAccount').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td>';
|
||||
print '<td width="18"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
$var=true;
|
||||
if ($num > 0)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td nowrap><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."</a></td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td align="center">';
|
||||
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
|
||||
while ($i < $num)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').' '.dol_print_date($db->jdate($objp->dp),'day')."</a></td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
$bankaccountstatic->id=$objp->baid;
|
||||
$bankaccountstatic->ref=$objp->ref;
|
||||
$bankaccountstatic->label=$objp->ref;
|
||||
print '<td align="right">';
|
||||
print $bankaccountstatic->getNomUrl(1,'transactions');
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td align="center">';
|
||||
if ($object->statut == 1 && $object->paye == 0 && $user->societe_id == 0)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deletepaiement&paiement_id='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$totalpaye += $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$totalpaye += $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr '.$bc[$var].'><td colspan="'.$nbcols.'">'.$langs->trans("None").'</td><td></td><td></td></tr>';
|
||||
}
|
||||
|
||||
if ($object->paye == 0)
|
||||
{
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPaid').' :</td><td align="right"><b>'.price($totalpaye).'</b></td></tr>';
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($object->total_ttc).'</td></tr>';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans('AlreadyPaid').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td></td></tr>';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($object->total_ttc).'</td><td></td></tr>';
|
||||
|
||||
$resteapayer = $object->total_ttc - $totalpaye;
|
||||
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('RemainderToPay').' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td></tr>';
|
||||
print '<tr><td colspan="'.$nbcols.'" align="right">'.$langs->trans('RemainderToPay').' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayer).'</b></td><td></td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
@ -1420,7 +1441,7 @@ else
|
||||
// Due date
|
||||
print '<tr><td>'.$form->editfieldkey("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker').'</td><td colspan="3">';
|
||||
print $form->editfieldval("DateMaxPayment",'date_lim_reglement',$object->date_echeance,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer && $object->getSommePaiement() <= 0),'datepicker');
|
||||
if ((empty($action) || $action == 'view') && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
|
||||
if ($action != 'editdate_li_reglement' && $object->statut < 2 && $object->date_echeance && $object->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)) print img_warning($langs->trans('Late'));
|
||||
print '</td>';
|
||||
|
||||
// Status
|
||||
|
||||
Loading…
Reference in New Issue
Block a user