Changes to support deposit invoices
This commit is contained in:
parent
d92ab8874b
commit
d4e5647b7e
@ -117,7 +117,7 @@ if ($_socid > 0)
|
||||
*/
|
||||
$head = societe_prepare_head($objsoc);
|
||||
|
||||
dol_fiche_head($head, 'absolutediscount', $objsoc->nom);
|
||||
dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"));
|
||||
|
||||
|
||||
print '<form method="POST" action="remx.php?id='.$objsoc->id.'">';
|
||||
@ -125,6 +125,12 @@ if ($_socid > 0)
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Name
|
||||
print '<tr><td width="38%">'.$langs->trans('Name').'</td>';
|
||||
print '<td>';
|
||||
print $form->showrefnav($objsoc,'id','',1,'rowid','nom');
|
||||
print '</td></tr>';
|
||||
|
||||
// Calcul avoirs en cours
|
||||
$remise_all=$remise_user=0;
|
||||
$sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
|
||||
@ -191,12 +197,14 @@ if ($_socid > 0)
|
||||
{
|
||||
print_titre($langs->trans("DiscountStillRemaining"));
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre"><td width="120">'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="110" align="left">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>';
|
||||
print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
|
||||
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
|
||||
print '<td align="center" width="100">'.$langs->trans("DiscountOfferedBy").'</td>';
|
||||
print '<td width="100" align="center">'.$langs->trans("DiscountOfferedBy").'</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -209,33 +217,38 @@ if ($_socid > 0)
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.dol_print_date($obj->dc,'dayhour').'</td>';
|
||||
print '<td>';
|
||||
if ($obj->description == '(CREDIT_NOTE)')
|
||||
{
|
||||
print '<td nowrap="nowrap">';
|
||||
$facturestatic->id=$obj->fk_facture_source;
|
||||
$facturestatic->ref=$obj->ref;
|
||||
$facturestatic->type=$obj->type;
|
||||
print $langs->trans("CreditNote").' '.$facturestatic->getNomURl(1);
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($obj->description == '(DEPOSIT)')
|
||||
{
|
||||
print '<td nowrap="nowrap">';
|
||||
$facturestatic->id=$obj->fk_facture_source;
|
||||
$facturestatic->ref=$obj->ref;
|
||||
$facturestatic->type=$obj->type;
|
||||
print $langs->trans("InvoiceDeposit").' '.$facturestatic->getNomURl(1);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
print $obj->description;
|
||||
print '</td>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($obj->amount_ht).'</td>';
|
||||
print '<td align="left" nowrap="nowrap">'.$langs->trans("NotConsumed").'</td>';
|
||||
print '<td align="right">'.price($obj->amount_ht).'</td>';
|
||||
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
|
||||
print '<td align="right">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
|
||||
print '</td>';
|
||||
if ($obj->user_id == $user->id) print '<td><a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&action=remove&remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</td>';
|
||||
if ($obj->user_id == $user->id) print '<td><a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&action=remove&remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a></td>';
|
||||
else print '<td> </td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
@ -251,8 +264,9 @@ if ($_socid > 0)
|
||||
print '<br>';
|
||||
|
||||
/*
|
||||
* Liste ristournes appliqu<EFBFBD>es (=liees a une ligne de facture ou facture)
|
||||
* Liste ristournes appliquees (=liees a une ligne de facture ou facture)
|
||||
*/
|
||||
|
||||
// Remises liees a lignes de factures
|
||||
$sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,";
|
||||
$sql.= $db->pdate("rc.datec")." as dc, rc.description, rc.fk_facture_line, rc.fk_facture,";
|
||||
@ -295,13 +309,14 @@ if ($_socid > 0)
|
||||
{
|
||||
print_titre($langs->trans("DiscountAlreadyCounted"));
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="120">'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
|
||||
print '<td align="left">'.$langs->trans("Invoice").'</td>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="110" align="left">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>';
|
||||
print '<td align="left" nowrap="nowrap">'.$langs->trans("ConsumedBy").'</td>';
|
||||
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
|
||||
print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td>';
|
||||
print '<td align="center" width="100">'.$langs->trans("Author").'</td>';
|
||||
print '<td width="100" align="center">'.$langs->trans("Author").'</td>';
|
||||
print '<td width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -335,32 +350,36 @@ if ($_socid > 0)
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.dol_print_date($obj->dc,'dayhour').'</td>';
|
||||
print '<td>';
|
||||
if ($obj->description == '(CREDIT_NOTE)')
|
||||
{
|
||||
print '<td nowrap="nowrap">';
|
||||
$facturestatic->id=$obj->fk_facture_source;
|
||||
$facturestatic->ref=$obj->ref;
|
||||
$facturestatic->type=$obj->type;
|
||||
print $langs->trans("CreditNote").' '.$facturestatic->getNomURl(1);
|
||||
print '</td>';
|
||||
}
|
||||
elseif ($obj->description == '(DEPOSIT)')
|
||||
{
|
||||
print '<td nowrap="nowrap">';
|
||||
$facturestatic->id=$obj->fk_facture_source;
|
||||
$facturestatic->ref=$obj->ref;
|
||||
$facturestatic->type=$obj->type;
|
||||
print $langs->trans("InvoiceDeposit").' '.$facturestatic->getNomURl(1);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
print $obj->description;
|
||||
print '</td>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="left"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
|
||||
print '<td align="left" nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
|
||||
print '<td align="right">'.price($obj->amount_ht).'</td>';
|
||||
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
|
||||
print '<td align="right">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login;
|
||||
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -2156,10 +2156,11 @@ else
|
||||
}
|
||||
if ($fac->type == 2)
|
||||
{
|
||||
$facreplaced=new Facture($db);
|
||||
$facreplaced->fetch($fac->fk_facture_source);
|
||||
print ' ('.$langs->transnoentities("CorrectInvoice",$facreplaced->getNomUrl(1)).')';
|
||||
$facusing=new Facture($db);
|
||||
$facusing->fetch($fac->fk_facture_source);
|
||||
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
|
||||
}
|
||||
|
||||
$facidavoir=$fac->getListIdAvoirFromInvoice();
|
||||
if (sizeof($facidavoir) > 0)
|
||||
{
|
||||
@ -2192,7 +2193,15 @@ else
|
||||
{
|
||||
if ($fac->statut > 0 || $fac->type == 2 || $fac->type == 3)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)).'. ';
|
||||
if ($fac->statut == 0)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)).'. ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
|
||||
print $html->textwithhelp($text,$langs->trans("AbsoluteDiscountUse"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2207,8 +2216,12 @@ else
|
||||
// If validated, we show link "add credit note to payment"
|
||||
if ($fac->statut != 1 || $fac->type == 2 || $fac->type == 3)
|
||||
{
|
||||
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie));
|
||||
print $html->textwithhelp($text,$langs->trans("CreditNoteDepositUse"));
|
||||
if ($fac->statut == 0 && $fac->type != 3)
|
||||
{
|
||||
$text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie));
|
||||
print $html->textwithhelp($text,$langs->trans("CreditNoteDepositUse"));
|
||||
}
|
||||
else print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->monnaie)).'.';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2254,9 +2267,89 @@ else
|
||||
|
||||
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// List of payments already done
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.($fac->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>';
|
||||
print '<td>'.$langs->trans('Type').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td>';
|
||||
print '<td width="18"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=true;
|
||||
|
||||
/*
|
||||
* List of payments
|
||||
*/
|
||||
|
||||
// Payments already done (from deposits)
|
||||
/*
|
||||
$depositamount=0;
|
||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||
$sql.= " WHERE fk_facture = ".$fac->id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$numdeposits = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$invoice=new Facture($db);
|
||||
// Loop on each deposit applied
|
||||
while ($i < $numdeposits)
|
||||
{
|
||||
$objinvoice = $db->fetch_object($resql);
|
||||
$invoice->fetch($objinvoice->fk_facture_source);
|
||||
if ($invoice->type != 3) continue; // only deposits
|
||||
|
||||
// For each deposits, get payments
|
||||
$sql = 'SELECT '.$db->pdate('datep').' as dp, pf.amount,';
|
||||
$sql.= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||
$sql.= ' WHERE pf.fk_facture = '.$invoice->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid';
|
||||
$sql.= ' ORDER BY dp, tms';
|
||||
|
||||
$resqlpayment = $db->query($sql);
|
||||
if ($resqlpayment)
|
||||
{
|
||||
$numpayments = $db->num_rows($resqlpayment);
|
||||
$j = 0;
|
||||
while ($j < $numpayments)
|
||||
{
|
||||
$objpayment = $db->fetch_object($resqlpayement);
|
||||
$var=!$var;
|
||||
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objpayment->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print dol_print_date($objpayment->dp,'day').'</a>';
|
||||
|
||||
print ' ('.$langs->trans("Deposit").' ';
|
||||
print $invoice->getNomUrl(0).')';
|
||||
|
||||
print '</td>';
|
||||
print '<td>'.$objpayment->paiement_type.' '.$objpayement->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objpayment->amount).'</td>';
|
||||
// Remove deposit invoice
|
||||
print '<td align="right">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=unlinkdiscount&discountid='.$objinvoice->rowid.'">'.img_delete().'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$j++;
|
||||
$depositamount += $obj->amount;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
*/
|
||||
|
||||
// Payments already done (from payment on this invoice)
|
||||
$sql = 'SELECT '.$db->pdate('datep').' as dp, pf.amount,';
|
||||
$sql.= ' c.libelle as paiement_type, p.num_paiement, p.rowid';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p, '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement_facture as pf';
|
||||
@ -2268,19 +2361,9 @@ else
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
// List of payments already done
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.($fac->type == 2 ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>';
|
||||
print '<td>'.$langs->trans('Type').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td>';
|
||||
print '<td width="18"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($fac->type != 2)
|
||||
{
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -2294,97 +2377,7 @@ else
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Already payed
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td> </td></tr>';
|
||||
|
||||
// Billed
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=$resteapayer;
|
||||
|
||||
$creditnoteamount=0;
|
||||
|
||||
// Loop on each credit note applied
|
||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||
$sql.= " WHERE fk_facture = ".$fac->id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$invoice=new Facture($db);
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$invoice->fetch($obj->fk_facture_source);
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
|
||||
if ($invoice->type == 3) print $langs->trans("Deposit").' ';
|
||||
print $invoice->getNomUrl(0);
|
||||
print ' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'</a>';
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
$creditnoteamount += $obj->amount_ttc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// Payé partiellement 'escompte'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'discount_vat')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'badcustomer'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'badcustomer')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $totalpaye).'</td><td> </td></tr>';
|
||||
//$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'product_returned'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'product_returned')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'abandon'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'abandon')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
$text=$langs->trans("HelpAbandonOther");
|
||||
if ($fac->close_note) $text.='<br><br><b>'.$langs->trans("Reason").'</b>:'.$fac->close_note;
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$text,-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
|
||||
else print $langs->trans('ExcessReceived');
|
||||
print ' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayeraffiche).'</b></td>';
|
||||
print '<td wrap="nowrap"> </td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sold credit note
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('TotalTTCToYourCredit').' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price(abs($fac->total_ttc)).'</b></td><td> </td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
}
|
||||
else
|
||||
@ -2392,6 +2385,107 @@ else
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if ($fac->type != 2)
|
||||
{
|
||||
// Total already payed
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
if ($fac->type != 3) print $langs->trans('AlreadyPayedNoCreditNotesNoDeposits');
|
||||
else print $langs->trans('AlreadyPayed');
|
||||
print ' :</td><td align="right">'.price($totalpaye).'</td><td> </td></tr>';
|
||||
|
||||
$resteapayeraffiche=$resteapayer;
|
||||
|
||||
// Loop on each credit note or deposit amount applied
|
||||
$creditnoteamount=0;
|
||||
$depositamount=0;
|
||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||
$sql.= " WHERE fk_facture = ".$fac->id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$invoice=new Facture($db);
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$invoice->fetch($obj->fk_facture_source);
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
if ($invoice->type == 2) print $langs->trans("CreditNote").' ';
|
||||
if ($invoice->type == 3) print $langs->trans("Deposit").' ';
|
||||
print $invoice->getNomUrl(0);
|
||||
print ' :</td>';
|
||||
print '<td align="right">'.price($obj->amount_ttc).'</td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().'</a>';
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
if ($invoice->type == 2) $creditnoteamount += $obj->amount_ttc;
|
||||
if ($invoice->type == 3) $depositamount += $obj->amount_ttc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// Payé partiellement 'escompte'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'discount_vat')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Escompte").':',$langs->trans("HelpEscompte"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'badcustomer'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'badcustomer')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$langs->trans("HelpAbandonBadCustomer"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
//$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'product_returned'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'product_returned')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
print $html->textwithhelp($langs->trans("ProductReturned").':',$langs->trans("HelpAbandonProductReturned"),-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
// Payé partiellement ou Abandon 'abandon'
|
||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'abandon')
|
||||
{
|
||||
print '<tr><td colspan="2" align="right" nowrap="1">';
|
||||
$text=$langs->trans("HelpAbandonOther");
|
||||
if ($fac->close_note) $text.='<br><br><b>'.$langs->trans("Reason").'</b>:'.$fac->close_note;
|
||||
print $html->textwithhelp($langs->trans("Abandoned").':',$text,-1);
|
||||
print '</td><td align="right">'.price($fac->total_ttc - $creditnoteamount - $depositamount - $totalpaye).'</td><td> </td></tr>';
|
||||
$resteapayeraffiche=0;
|
||||
}
|
||||
|
||||
// Billed
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td> </td></tr>';
|
||||
|
||||
// Remainder to pay
|
||||
print '<tr><td colspan="2" align="right">';
|
||||
if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay');
|
||||
else print $langs->trans('ExcessReceived');
|
||||
print ' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price($resteapayeraffiche).'</b></td>';
|
||||
print '<td nowrap="nowrap"> </td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Sold credit note
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('TotalTTCToYourCredit').' :</td>';
|
||||
print '<td align="right" style="border: 1px solid;" bgcolor="#f0f0f0"><b>'.price(abs($fac->total_ttc)).'</b></td><td> </td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Date payment term
|
||||
@ -2975,10 +3069,10 @@ else
|
||||
|
||||
// Validate
|
||||
if ($fac->statut == 0 && $num_lignes > 0 &&
|
||||
(
|
||||
(($fac->type == 0 || $fac->type == 1 || $fac->type == 3 || $fac->type == 4) && $fac->total_ttc >= 0)
|
||||
|| ($fac->type == 2 && $fac->total_ttc <= 0))
|
||||
)
|
||||
(
|
||||
(($fac->type == 0 || $fac->type == 1 || $fac->type == 3 || $fac->type == 4) && $fac->total_ttc >= 0)
|
||||
|| ($fac->type == 2 && $fac->total_ttc <= 0))
|
||||
)
|
||||
{
|
||||
if ($user->rights->facture->valider)
|
||||
{
|
||||
|
||||
@ -46,7 +46,7 @@ $mesg='';
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
|
||||
$paiement = new Paiement($db);
|
||||
$paiement->fetch($_GET['id']);
|
||||
$result = $paiement->delete();
|
||||
@ -72,7 +72,7 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
|
||||
if ($paiement->valide() > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
|
||||
// \TODO Boucler sur les facture liées à ce paiement et régénèrer le pdf
|
||||
$factures=array();
|
||||
foreach($factures as $id)
|
||||
@ -121,11 +121,11 @@ $h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
$h++;
|
||||
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice"));
|
||||
@ -180,15 +180,15 @@ print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2b
|
||||
// Bank account
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
if ($paiement->bank_account)
|
||||
if ($paiement->bank_account)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($paiement->bank_line);
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -201,15 +201,15 @@ print '</table>';
|
||||
* Liste des factures
|
||||
*/
|
||||
$allow_delete = 1 ;
|
||||
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
|
||||
$sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.total_ttc, f.paye, f.fk_statut, pf.amount, s.nom, s.rowid as socid';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql .= ' WHERE pf.fk_facture = f.rowid AND f.fk_soc = s.rowid';
|
||||
$sql .= ' AND pf.fk_paiement = '.$paiement->id;
|
||||
$resql=$db->query($sql);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
@ -219,11 +219,11 @@ if ($resql)
|
||||
print '<td>'.$langs->trans('Company').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
|
||||
$facturestatic=new Facture($db);
|
||||
|
||||
while ($i < $num)
|
||||
@ -231,9 +231,12 @@ if ($resql)
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' ';
|
||||
print $objp->facnumber;
|
||||
print "</a></td>\n";
|
||||
print '<td>';
|
||||
$facturestatic->id=$objp->facid;
|
||||
$facturestatic->ref=$objp->facnumber;
|
||||
$facturestatic->type=$objp->type;
|
||||
print $facturestatic->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$objp->socid.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
@ -244,16 +247,16 @@ if ($resql)
|
||||
}
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$var=!$var;
|
||||
|
||||
print "</table>\n";
|
||||
$db->free($resql);
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
@ -283,7 +286,7 @@ if ($user->societe_id == 0 && $allow_delete && $_GET['action'] == '')
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
@ -490,7 +490,7 @@ class Form
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste déroulante des remises fixes
|
||||
* \brief Return HTML combo list of absolute discounts
|
||||
* \param selected Id remise fixe pré-sélectionnée
|
||||
* \param htmlname Nom champ formulaire
|
||||
* \param filter Criteres optionnels de filtre
|
||||
@ -1750,10 +1750,10 @@ class Form
|
||||
print '<td align="left">';
|
||||
if ($nbqualifiedlines > 0)
|
||||
{
|
||||
print ' <input type="submit" class="button" value="';
|
||||
print ' <input type="submit" class="button" value="';
|
||||
if (! $filter || $filter=='fk_facture_source IS NULL') print $langs->trans("UseDiscount");
|
||||
else print $langs->trans("UseCreditNoteInInvoicePayment");
|
||||
print '">';
|
||||
else print $langs->trans("UseCredit");
|
||||
print '" title="'.$langs->trans("UseCreditNoteInInvoicePayment").'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr></table></form>';
|
||||
|
||||
@ -32,6 +32,9 @@ ReplacementByInvoice=Replaced by invoice
|
||||
CorrectInvoice=Correct invoice %s
|
||||
CorrectInvoice=Correct invoice %s
|
||||
CorrectionInvoice=Correction invoice
|
||||
UsedByInvoice=Used to pay invoice %s
|
||||
ConsumedBy=Consumed by
|
||||
NotConsumed=Not consumed
|
||||
NoReplacableInvoice=No replacable invoices
|
||||
NoInvoiceToCorrect=No invoice to correct
|
||||
InvoiceHasAvoir=Corrected by one or several invoices
|
||||
@ -171,6 +174,7 @@ ShowInvoiceDeposit=Show deposit invoice
|
||||
ShowPayment=Show payment
|
||||
File=File
|
||||
AlreadyPayed=Already payed
|
||||
AlreadyPayedNoCreditNotesNoDeposits=Alreday payed (without credit notes and deposits)
|
||||
Abandoned=Abandoned
|
||||
RemainderToPay=Remainder to pay
|
||||
RemainderToTake=Remainder to take
|
||||
@ -232,6 +236,8 @@ Deposit=Deposit
|
||||
Deposits=Deposits
|
||||
DiscountFromCreditNote=Discount from credit note %s
|
||||
DiscountFromDeposit=Payments from deposit invoice %s
|
||||
AbsoluteDiscountUse=This kind of credit can be used on invoice before its validation
|
||||
CreditNoteDepositUse=Invoice must be validated to use this king of credits
|
||||
NewGlobalDiscount=New discount
|
||||
NoteReason=Note/Reason
|
||||
ReasonDiscount=Reason
|
||||
@ -318,7 +324,8 @@ LawApplicationPart3=the seller until the complete cashing of
|
||||
LawApplicationPart4=their price.
|
||||
LimitedLiabilityCompanyCapital=SARL with Capital of
|
||||
UseDiscount=Use discount
|
||||
UseCreditNoteInInvoicePayment=Reduce payment with this credit
|
||||
UseCredit=Use credit
|
||||
UseCreditNoteInInvoicePayment=Reduce amount to pay with this credit
|
||||
MenuChequeDeposits=Cheques deposits
|
||||
MenuCheques=Cheques
|
||||
MenuChequesReceipts=Cheques receipts
|
||||
|
||||
@ -32,6 +32,9 @@ ReplacedByInvoice=Remplacée par la facture %s
|
||||
ReplacementByInvoice=Remplacée par facture
|
||||
CorrectInvoice=Correction facture %s
|
||||
CorrectionInvoice=Correction facture
|
||||
UsedByInvoice=Appliqué sur facture %s
|
||||
ConsumedBy=Consommé par
|
||||
NotConsumed=Non consommé
|
||||
NoReplacableInvoice=Pas de factures remplacables
|
||||
NoInvoiceToCorrect=Pas de factures à corriger
|
||||
InvoiceHasAvoir=Corrigée par un ou plusieurs avoirs
|
||||
@ -171,6 +174,7 @@ ShowInvoiceDeposit=Afficher facture d'accompte
|
||||
ShowPayment=Afficher réglement
|
||||
File=Fichier
|
||||
AlreadyPayed=Déjà réglé
|
||||
AlreadyPayedNoCreditNotesNoDeposits=Déjà réglé (hors avoirs et accomptes)
|
||||
Abandoned=Abandonné
|
||||
RemainderToPay=Reste à payer
|
||||
RemainderToTake=Reste à encaisser
|
||||
@ -231,6 +235,8 @@ Deposit=Accompte
|
||||
Deposits=Accomptes
|
||||
DiscountFromCreditNote=Remise issue de l'avoir %s
|
||||
DiscountFromDeposit=Paiements issue de l'accompte %s
|
||||
AbsoluteDiscountUse=Ce type de crédit ne peut s'utiliser que sur un facture avant sa validation
|
||||
CreditNoteDepositUse=La facture doit être validée pour pouvoir utiliser ce type de crédits
|
||||
NewGlobalDiscount=Nouvelle remise fixe
|
||||
NoteReason=Note/Motif
|
||||
ReasonDiscount=Motif
|
||||
@ -319,7 +325,8 @@ LawApplicationPart3=vendeur jusqu'à complet encaissement de
|
||||
LawApplicationPart4=leurs prix.
|
||||
LimitedLiabilityCompanyCapital=SARL au Capital de
|
||||
UseDiscount=Appliquer remise
|
||||
UseCreditNoteInInvoicePayment=Réduire paiement avec ce credit
|
||||
UseCredit=Utiliser crédit
|
||||
UseCreditNoteInInvoicePayment=Réduire le montant du reste à payé avec ce credit
|
||||
MenuChequeDeposits=Remises de chèques
|
||||
MenuCheques=Gestion chèques
|
||||
MenuChequesReceipts=Bordereaux
|
||||
|
||||
@ -130,7 +130,7 @@ CustomerAbsoluteDiscountShort=Remise fixe
|
||||
CompanyHasRelativeDiscount=Ce client a une remise par défaut de <b>%s%%</b>
|
||||
CompanyHasNoRelativeDiscount=Ce client n'a pas de remises relatives par défaut
|
||||
CompanyHasAbsoluteDiscount=Ce client a <b>%s %s</b> de remises fixes disponibles
|
||||
CompanyHasCreditNote=Ce client a <b>%s %s</b> d'avoirs ou accomptes disponibles
|
||||
CompanyHasCreditNote=Ce client a <b>%s %s</b> d'avoirs/accomptes disponibles
|
||||
CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remises fixes disponibles
|
||||
CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur)
|
||||
CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement)
|
||||
|
||||
@ -965,7 +965,7 @@ else
|
||||
print '<form name="formsoc" method="post">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
//
|
||||
// Name
|
||||
print '<tr><td width="20%">'.$langs->trans('Name').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($soc,'socid','',1,'rowid','nom');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user