Correction bugs et amlioration gestion avoirs
This commit is contained in:
parent
08b11faa6f
commit
6b1a4b7c20
@ -1168,9 +1168,9 @@ if ($_GET['action'] == 'create')
|
||||
$text=$langs->transnoentities("InvoiceAvoirAsk").' ';
|
||||
// $text.='<input type="text" value="">';
|
||||
$text.='<select class="flat" name="fac_avoir"';
|
||||
if (! $options) $text.=' disabled="true"';
|
||||
if (! $optionsav) $text.=' disabled="true"';
|
||||
$text.='>';
|
||||
if ($options)
|
||||
if ($optionsav)
|
||||
{
|
||||
$text.='<option value="-1"> </option>';
|
||||
$text.=$optionsav;
|
||||
@ -1760,7 +1760,7 @@ else
|
||||
print '. ';
|
||||
if ($absolute_discount)
|
||||
{
|
||||
if ($fac->statut > 0)
|
||||
if ($fac->statut > 0 || $fac->type == 2)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
}
|
||||
@ -1793,40 +1793,50 @@ else
|
||||
$sql.= ' ORDER BY dp DESC';
|
||||
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Payments').'</td><td>'.$langs->trans('Type').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td><td> </td></tr>';
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
|
||||
if ($fac->type != 2)
|
||||
{
|
||||
$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 dolibarr_print_date($objp->dp).'</a></td>';
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
// Liste des paiements
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans('Payments').'</td><td>'.$langs->trans('Type').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Amount').'</td><td> </td></tr>';
|
||||
|
||||
$var=True;
|
||||
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 dolibarr_print_date($objp->dp).'</a></td>';
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
if ($fac->close_code == 'escompte')
|
||||
// Solde facture
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans('AlreadyPayed').' :</td><td align="right"><b>'.price($totalpaye).'</b></td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
if ($fac->close_code == 'escompte')
|
||||
{
|
||||
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 - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
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><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
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 - $totalpaye).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
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><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
|
||||
// Solde avoir
|
||||
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>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
$db->free($result);
|
||||
}
|
||||
@ -1840,8 +1850,16 @@ else
|
||||
// Date limite reglement
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateMaxPayment').'</td>';
|
||||
print '<td colspan="3">' . dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
|
||||
if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late'));
|
||||
print '<td colspan="3">';
|
||||
if ($fac->type != 2)
|
||||
{
|
||||
print dolibarr_print_date($fac->date_lim_reglement,'%A %d %B %Y');
|
||||
if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans('Late'));
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Conditions de réglement
|
||||
@ -1849,16 +1867,23 @@ else
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editconditions' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
if ($fac->type != 2 && $_GET['action'] != 'editconditions' && $fac->brouillon && $user->rights->facture->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&facid='.$fac->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'editconditions')
|
||||
if ($fac->type != 2)
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'cond_reglement_id');
|
||||
if ($_GET['action'] == 'editconditions')
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'cond_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none');
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ if ($socid > 0)
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td>'.$langs->trans("Status").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Debit").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Credit").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Balance").'</td>';
|
||||
@ -137,6 +137,7 @@ if ($socid > 0)
|
||||
print $fac->error."<br>";
|
||||
continue;
|
||||
}
|
||||
$totalpaye = $fac->getSommePaiement();
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
@ -144,7 +145,7 @@ if ($socid > 0)
|
||||
print "<td align=\"center\">".dolibarr_print_date($fac->date)."</td>\n";
|
||||
print "<td><a href=\"../compta/facture.php?facid=$fac->id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."</a></td>\n";
|
||||
|
||||
print '<td aling="left">'.$fac->getLibStatut(2).'</td>';
|
||||
print '<td aling="left">'.$fac->getLibStatut(2,$totalpaye).'</td>';
|
||||
print '<td align="right">'.price($fac->total_ttc)."</td>\n";
|
||||
$solde = $solde + $fac->total_ttc;
|
||||
|
||||
@ -207,6 +208,7 @@ if ($socid > 0)
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
print "</table>";
|
||||
print "<br>";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -382,14 +382,16 @@ class Facture extends CommonObject
|
||||
$sql.= ','.$this->db->pdate('f.datef').' as df, f.fk_projet';
|
||||
$sql.= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
|
||||
$sql.= ', f.note, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.model_pdf';
|
||||
$sql.= ', f.fk_mode_reglement, p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= ', f.fk_cond_reglement, c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
|
||||
$sql.= ', f.fk_facture_source';
|
||||
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement';
|
||||
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
|
||||
$sql.= ', cf.fk_commande';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c, '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as c ON f.fk_cond_reglement = c.rowid';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_fa as cf ON cf.fk_facture = f.rowid';
|
||||
$sql.= ' WHERE f.rowid='.$rowid.' AND c.rowid = f.fk_cond_reglement';
|
||||
$sql.= ' WHERE f.rowid='.$rowid;
|
||||
if ($societe_id > 0)
|
||||
{
|
||||
$sql.= ' AND f.fk_soc = '.$societe_id;
|
||||
|
||||
@ -884,17 +884,30 @@ class pdf_crabe extends ModelePDFFactures
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->trans("ReplaceInvoice", $objectreplaced->ref), '', 'R');
|
||||
}
|
||||
if ($object->type == 2)
|
||||
{
|
||||
$objectreplaced=new Facture($this->db);
|
||||
$objectreplaced->fetch($object->fk_facture_source);
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->trans("CorrectInvoice", $objectreplaced->ref), '', 'R');
|
||||
}
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->trans("DateInvoice")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', 'R');
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->trans("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"%d %b %Y"), '', 'R');
|
||||
|
||||
if ($object->type != 2)
|
||||
{
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100,$posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(100, 3, $outputlangs->trans("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"%d %b %Y"), '', 'R');
|
||||
}
|
||||
|
||||
if ($showadress)
|
||||
{
|
||||
// Emetteur
|
||||
|
||||
Loading…
Reference in New Issue
Block a user