Amélioration de la gestion des paiements clients en ajoutant page de confirmation et warning si paiement saisi supérieur au reste à payer.

This commit is contained in:
Laurent Destailleur 2006-11-10 00:28:39 +00:00
parent c586df3d02
commit 496e780434
9 changed files with 424 additions and 300 deletions

View File

@ -1107,7 +1107,7 @@ if ($_GET['action'] == 'create')
print '</td></tr>'; print '</td></tr>';
} }
// Societe // Tiers
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">';
print $soc->getNomUrl(1); print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">'; print '<input type="hidden" name="socid" value="'.$soc->id.'">';
@ -1121,7 +1121,7 @@ if ($_GET['action'] == 'create')
{ {
$options.='<option value="'.$key.'">'.$value.'</option>'; $options.='<option value="'.$key.'">'.$value.'</option>';
} }
$facids=$facturestatic->list_avoir_invoices($soc->id); $facids=$facturestatic->list_qualified_avoir_invoices($soc->id);
$optionsav=""; $optionsav="";
foreach ($facids as $key => $value) foreach ($facids as $key => $value)
{ {
@ -1726,7 +1726,7 @@ else
print '</tr>'; print '</tr>';
} }
// Société // Tiers Société
print '<tr><td>'.$langs->trans('Company').'</td>'; print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>'; print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>';
print '</tr>'; print '</tr>';
@ -2449,7 +2449,7 @@ else
// Récurrente // Récurrente
if (! $conf->global->FACTURE_DISABLE_RECUR) if (! $conf->global->FACTURE_DISABLE_RECUR)
{ {
print ' <a class="butAction" href="facture/fiche-rec.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans("ChangeIntoRepeatableInvoice").'</a>'; print '<a class="butAction" href="facture/fiche-rec.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans("ChangeIntoRepeatableInvoice").'</a>';
} }
// Valider // Valider
@ -2457,7 +2457,7 @@ else
{ {
if ($user->rights->facture->valider) if ($user->rights->facture->valider)
{ {
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=valid">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=valid">'.$langs->trans('Validate').'</a>';
} }
} }
else else
@ -2467,11 +2467,11 @@ else
{ {
if ($fac->paye == 0) if ($fac->paye == 0)
{ {
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=builddoc">'.$langs->trans('BuildPDF').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=builddoc">'.$langs->trans('BuildPDF').'</a>';
} }
else else
{ {
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=builddoc">'.$langs->trans('RebuildPDF').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&amp;action=builddoc">'.$langs->trans('RebuildPDF').'</a>';
} }
} }
} }
@ -2479,26 +2479,47 @@ else
// Envoyer // Envoyer
if ($fac->statut == 1 && $user->rights->facture->envoyer) if ($fac->statut == 1 && $user->rights->facture->envoyer)
{ {
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=presend">'.$langs->trans('SendByMail').'</a>'; if ($facidnext)
{
print '<span class="butActionRefused" alt="'.$langs->trans("DisabledBecauseReplacedInvoie").'">'.$langs->trans('SendByMail').'</span>';
}
else
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=presend">'.$langs->trans('SendByMail').'</a>';
}
} }
// Envoyer une relance // Envoyer une relance
if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer) if ($fac->statut == 1 && $resteapayer > 0 && $user->rights->facture->envoyer)
{ {
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=prerelance">'.$langs->trans('SendRemindByMail').'</a>'; if ($facidnext)
{
print '<span class="butActionRefused" alt="'.$langs->trans("DisabledBecauseReplacedInvoie").'">'.$langs->trans('SendRemindByMail').'</span>';
}
else
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=prerelance">'.$langs->trans('SendRemindByMail').'</a>';
}
} }
// Emettre paiement // Emettre paiement
if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement)
{ {
print ' <a class="butAction" href="paiement.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans('DoPaiement').'</a>'; if ($facidnext)
{
print '<span class="butActionRefused" alt="'.$langs->trans("DisabledBecauseReplacedInvoie").'">'.$langs->trans('DoPaiement').'</span>';
}
else
{
print '<a class="butAction" href="paiement.php?facid='.$fac->id.'&amp;action=create">'.$langs->trans('DoPaiement').'</a>';
}
} }
// Classer 'payé' // Classer 'payé'
if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement
&& $resteapayer <= 0) && $resteapayer <= 0)
{ {
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=payed">'.$langs->trans('ClassifyPayed').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=payed">'.$langs->trans('ClassifyPayed').'</a>';
} }
// Classer 'fermée' (possible si validée et pas encore classée payée) // Classer 'fermée' (possible si validée et pas encore classée payée)
@ -2507,11 +2528,11 @@ else
{ {
if ($totalpaye > 0) if ($totalpaye > 0)
{ {
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=payed">'.$langs->trans('ClassifyPayedPartially').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=payed">'.$langs->trans('ClassifyPayedPartially').'</a>';
} }
else else
{ {
print ' <a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=canceled">'.$langs->trans('ClassifyCanceled').'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&amp;action=canceled">'.$langs->trans('ClassifyCanceled').'</a>';
// \todo // \todo
// Ajouter bouton "Annuler et Créer facture remplacement" // Ajouter bouton "Annuler et Créer facture remplacement"

View File

@ -45,10 +45,15 @@ $sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder'];
$page=isset($_GET['page'])?$_GET['page']:$_POST['page']; $page=isset($_GET['page'])?$_GET['page']:$_POST['page'];
$amounts=array();
$amountsresttopay=array();
$addwarning=0;
/* /*
* Actions * Action add_paiement et confirm_paiement
*/ */
if ($_POST['action'] == 'add_paiement') if ($_POST['action'] == 'add_paiement' || $_POST['action'] == 'confirm_paiement')
{ {
$error = 0; $error = 0;
@ -57,16 +62,26 @@ if ($_POST['action'] == 'add_paiement')
$_POST['reday'], $_POST['reday'],
$_POST['reyear'])); $_POST['reyear']));
$paiement_id = 0; $paiement_id = 0;
$total = 0;
// Génère tableau des montants amounts // Verifie si des paiements sont supérieurs au montant facture
$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); $cursorfacid = substr($key,7);
$amounts[$other_facid] = $_POST[$key]; $amounts[$cursorfacid] = $_POST[$key];
$total = $total + $amounts[$other_facid]; $totalpaiement = $totalpaiement + price2num($amounts[$cursorfacid]);
$tmpfacture=new Facture($db);
$tmpfacture->fetch($cursorfacid);
$amountsresttopay[$cursorfacid]=($tmpfacture->total_ttc-$tmpfacture->getSommePaiement());
if ($amounts[$cursorfacid] && $amounts[$cursorfacid] > $amountsresttopay[$cursorfacid])
{
$addwarning=1;
$formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' Attention, le montant de paiement pour une ou plusieurs facture est supérieur au reste à payer.';
$formquestion['text'].='<br>Corriger votre saisie, sinon confirmer. Dolibarr pourra créer un avoir du trop perçu lors de la fermeture de chacune de facture.';
}
$formquestion[$i++]=array('type' => 'hidden','name' => $key, 'value' => $_POST[$key]);
} }
} }
@ -88,12 +103,31 @@ if ($_POST['action'] == 'add_paiement')
} }
} }
if ($total <= 0) if ($totalpaiement <= 0)
{ {
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('Amount')).'</div>'; $fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('Amount')).'</div>';
$error++; $error++;
} }
}
/*
* Action add_paiement
*/
if ($_POST['action'] == 'add_paiement')
{
if ($error)
{
$_POST['action']='';
$_GET['action'] = 'create';
}
// Le reste propre a cette action s'affiche en bas de page.
}
/*
* Action confirm_paiement
*/
if ($_POST['action'] == 'confirm_paiement' && $_POST['confirm'] == 'yes')
{
if (! $error) if (! $error)
{ {
$db->begin(); $db->begin();
@ -110,13 +144,6 @@ if ($_POST['action'] == 'add_paiement')
if ($paiement_id > 0) if ($paiement_id > 0)
{ {
// On determine le montant total du paiement
$total=0;
foreach ($paiement->amounts as $value)
{
$total += $value;
}
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
// Insertion dans llx_bank // Insertion dans llx_bank
@ -126,7 +153,7 @@ if ($_POST['action'] == 'add_paiement')
$bank_line_id = $acc->addline($paiement->datepaye, $bank_line_id = $acc->addline($paiement->datepaye,
$paiement->paiementid, $paiement->paiementid,
$label, $label,
$total, $totalpaiement,
$paiement->num_paiement, $paiement->num_paiement,
'', '',
$user); $user);
@ -198,180 +225,220 @@ llxHeader();
$html=new Form($db); $html=new Form($db);
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
if ($fiche_erreur_message)
{
print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
}
if ($_GET['action'] == 'create' || $_POST['action'] == 'add_paiement') if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_POST['action'] == 'add_paiement')
{ {
$facture = new Facture($db); $facture = new Facture($db);
$result=$facture->fetch($facid); $result=$facture->fetch($facid);
if ($result >= 0) if ($result >= 0)
{ {
$facture->fetch_client(); $facture->fetch_client();
$total = $facture->total_ttc; $title='';
if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer");
if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer");
print_fiche_titre($title);
$title='';
if ($facture->type != 2) $title.=$langs->trans("EnterPaymentReceivedFromCustomer");
if ($facture->type == 2) $title.=$langs->trans("EnterPaymentDueToCustomer");
print_fiche_titre($title);
print '<form name="add_paiement" action="paiement.php" method="post">'; // Initialise donnees pour page de confirmation
print '<input type="hidden" name="action" value="add_paiement">'; if ($_POST["action"] == 'add_paiement')
print '<input type="hidden" name="facid" value="'.$facture->id.'">'; {
print '<input type="hidden" name="socid" value="'.$facture->socid.'">'; $i=0;
print '<input type="hidden" name="type" value="'.$facture->type.'">';
print '<table class="border" width="100%">'; $formquestion[$i++]=array('type' => 'hidden','name' => 'facid', 'value' => $facture->id);
$formquestion[$i++]=array('type' => 'hidden','name' => 'socid', 'value' => $facture->socid);
$formquestion[$i++]=array('type' => 'hidden','name' => 'type', 'value' => $facture->type);
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$facture->client->getNomUrl(4)."</td></tr>\n";
print '<tr><td>'.$langs->trans('Date').'</td><td>'; }
if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear']))
$sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); print '<form name="add_paiement" action="paiement.php" method="post">';
else print '<input type="hidden" name="action" value="add_paiement">';
$sel_date=''; print '<input type="hidden" name="facid" value="'.$facture->id.'">';
$html->select_date($sel_date,'','','','',"add_paiement"); print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
print '<input type="hidden" name="type" value="'.$facture->type.'">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$facture->client->getNomUrl(4)."</td></tr>\n";
print '<tr><td>'.$langs->trans('Date').'</td><td>';
if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear']))
$sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
else
$sel_date='';
$html->select_date($sel_date,'','','','',"add_paiement");
print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>';
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid');
print "</td>\n";
print '<td rowspan="3" valign="top">';
print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_4.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
print '<tr><td>'.$langs->trans('Numero');
print ' <em>(Numéro chèque ou virement)</em>'; // \todo a traduire
print '</td>';
print '<td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"></td></tr>';
print '<tr>';
if ($conf->banque->enabled)
{
if ($facture->type != 2) print '<td>'.$langs->trans('AccountToCredit').'</td>';
if ($facture->type == 2) print '<td>'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
$html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1);
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>'; }
else
{
print '<td colspan="2">&nbsp;</td>';
}
print "</tr>\n";
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid');
print "</td>\n";
print '<td rowspan="3" valign="top">'; /*
print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_4.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>'; * Liste factures impayées
*/
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.type, ';
$sql.= $db->pdate('f.datef').' as df, ';
$sql.= ' sum(pf.amount) as am';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
$sql.= ' WHERE f.fk_soc = '.$facture->socid;
$sql.= ' AND f.paye = 0';
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée
if ($facture->type != 2)
{
$sql .= ' AND type in (0,1)'; // Facture standard ou de remplacement
}
else
{
$sql .= ' AND type = 2';
}
$sql .= ' GROUP BY f.facnumber';
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num > 0)
{
print '<tr><td>'.$langs->trans('Numero'); $i = 0;
print ' <em>(Numéro chèque ou virement)</em>'; // \todo a traduire print '<tr><td colspan="3">';
print '</td>'; print '<table class="noborder" width="100%">';
print '<td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"></td></tr>'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Invoice').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
print '<td align="right">'.$langs->trans('Received').'</td>';
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>';
print '<td align="right">'.$langs->trans('PaymentAmount').'</td>';
print '<td align="right">&nbsp;</td>';
print "</tr>\n";
print '<tr>'; $var=True;
if ($conf->banque->enabled) $total=0;
{ $totalrecu=0;
if ($facture->type != 2) print '<td>'.$langs->trans('AccountToCredit').'</td>';
if ($facture->type == 2) print '<td>'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
$html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1);
print '</td>';
}
else
{
print '<td colspan="2">&nbsp;</td>';
}
print "</tr>\n";
/* while ($i < $num)
* Autres factures impayées
*/
$sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.type, ';
$sql.= $db->pdate('f.datef').' as df, ';
$sql.= ' sum(pf.amount) as am';
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
$sql.= ' WHERE f.fk_soc = '.$facture->socid;
$sql.= ' AND f.paye = 0';
$sql.= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée
if ($facture->type != 2)
{
$sql .= ' AND type in (0,1)'; // Facture standard ou de remplacement
}
else
{
$sql .= ' AND type = 2';
}
$sql .= ' GROUP BY f.facnumber';
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num > 0)
{ {
$i = 0; $objp = $db->fetch_object($resql);
print '<tr><td colspan="3">'; $var=!$var;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('Invoice').'</td>';
print '<td align="center">'.$langs->trans('Date').'</td>'; print '<td>';
print '<td align="right">'.$langs->trans('AmountTTC').'</td>'; $facturestatic->ref=$objp->facnumber;
print '<td align="right">'.$langs->trans('Received').'</td>'; $facturestatic->id=$objp->facid;
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>'; $facturestatic->type=$objp->type;
print '<td align="center">'.$langs->trans('Amount').'</td>'; print $facturestatic->getNomUrl(1,'');
print "</td>\n";
// Date
print '<td align="center">'.dolibarr_print_date($objp->df)."</td>\n";
// Prix
print '<td align="right">'.price($objp->total_ttc).'</td>';
// Recu
print '<td align="right">'.price($objp->am).'</td>';
// Reste a payer
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
// Montant
print '<td align="right">';
$namef = 'amount_'.$objp->facid;
print '<input type="text" size="8" name="'.$namef.'" value="'.$_POST[$namef].'">';
print "</td>";
// Warning
print '<td align="center" width="16">';
if ($amounts[$facturestatic->id] && $amounts[$facturestatic->id] > $amountsresttopay[$facturestatic->id])
{
print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
}
print '</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $total+=$objp->total;
$total=0; $total_ttc+=$objp->total_ttc;
$totalrecu=0; $totalrecu+=$objp->am;
$i++;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td><a href="facture.php?facid='.$objp->facid.'">';
$facturestatic->ref=$objp->facnumber;
$facturestatic->id=$objp->rowid;
$facturestatic->type=$objp->type;
print $facturestatic->getNomUrl(1,'');
print "</a></td>\n";
if ($objp->df > 0 )
{
print '<td align="center">';
print dolibarr_print_date($objp->df)."</td>\n";
}
else
{
print '<td align="center"><b>!!!</b></td>';
}
print '<td align="right">'.price($objp->total_ttc).'</td>';
print '<td align="right">'.price($objp->am).'</td>';
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
print '<td align="center">';
$namef = 'amount_'.$objp->facid;
print '<input type="text" size="8" name="'.$namef.'">';
print "</td></tr>\n";
$total+=$objp->total;
$total_ttc+=$objp->total_ttc;
$totalrecu+=$objp->am;
$i++;
}
if ($i > 1)
{
// Print total
print '<tr class="liste_total">';
print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').':</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($total_ttc - $totalrecu).'</b></td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
}
print "</table></td></tr>\n";
} }
$db->free($resql); if ($i > 1)
} {
else // Print total
{ print '<tr class="liste_total">';
dolibarr_print_error($db); print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').':</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($total_ttc - $totalrecu).'</b></td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
}
print "</table></td></tr>\n";
} }
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
/*
* // Bouton Enregistrer
*/ if ($_POST["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 "</form>\n";
print '</table>';
// Message d'erreur
if ($fiche_erreur_message)
{
print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
}
// Formulaire confirmation
if ($_POST["action"] == 'add_paiement')
{
// print '<tr><td colspan="3">';
print '<br />';
$text=$langs->trans('ConfirmCustomerPayment',$totalpaiement,$langs->trans("Currency".$conf->monnaie));
$html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type,$langs->trans('ReceivedCustomersPayments'),$text,'confirm_paiement',$formquestion);
// print '</td></tr>';
}
print "</form>\n";
} }
} }
@ -411,7 +478,7 @@ if (! $_GET['action'] && ! $_POST['action'])
print_barre_liste($langs->trans('Payments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num); print_barre_liste($langs->trans('Payments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('Bill'),'paiement.php','facnumber','','','',$sortfield); print_liste_field_titre($langs->trans('Invoice'),'paiement.php','facnumber','','','',$sortfield);
print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','',$sortfield); print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','',$sortfield);
print_liste_field_titre($langs->trans('Type'),'paiement.php','libelle','','','',$sortfield); print_liste_field_titre($langs->trans('Type'),'paiement.php','libelle','','','',$sortfield);
print_liste_field_titre($langs->trans('Amount'),'paiement.php','fa_amount','','','align="right"',$sortfield); print_liste_field_titre($langs->trans('Amount'),'paiement.php','fa_amount','','','align="right"',$sortfield);

View File

@ -129,7 +129,7 @@ dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$paiement->
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$html->form_confirm('fiche.php?id='.$paiement->id, 'Supprimer le paiement', 'Etes-vous sûr de vouloir supprimer ce paiement ?', 'confirm_delete'); $html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), 'Etes-vous sûr de vouloir supprimer ce paiement ?', 'confirm_delete');
print '<br>'; print '<br>';
} }
@ -139,7 +139,7 @@ if ($_GET['action'] == 'delete')
if ($_GET['action'] == 'valide') if ($_GET['action'] == 'valide')
{ {
$facid = $_GET['facid']; $facid = $_GET['facid'];
$html->form_confirm('fiche.php?id='.$paiement->id.'&amp;facid='.$facid, 'Valider le paiement', 'Etes-vous sûr de vouloir valider ce paiment, auncune modification n\'est possible une fois le paiement validé ?', 'confirm_valide'); $html->form_confirm('fiche.php?id='.$paiement->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), 'Etes-vous sûr de vouloir valider ce paiment, auncune modification n\'est possible une fois le paiement validé ?', 'confirm_valide');
print '<br>'; print '<br>';
} }
@ -168,14 +168,26 @@ if ($conf->banque->enabled)
print '</tr>'; print '</tr>';
} }
} }
// Date
print '<tr><td valign="top" width="140">'.$langs->trans('Date').'</td><td colspan="3">'.dolibarr_print_date($paiement->date).'</td></tr>'; print '<tr><td valign="top" width="140">'.$langs->trans('Date').'</td><td colspan="3">'.dolibarr_print_date($paiement->date).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
if ($paiement->numero) // Mode
{ print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$paiement->type_code).'</td></tr>';
// Numero
//if ($paiement->montant)
//{
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
} //}
// Montant
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Note
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
print '</table>'; print '</table>';

View File

@ -2278,7 +2278,7 @@ class Facture extends CommonObject
* \param socid Id societe * \param socid Id societe
* \return array Tableau des factures ($id => $ref) * \return array Tableau des factures ($id => $ref)
*/ */
function list_avoir_invoices($socid=0) function list_qualified_avoir_invoices($socid=0)
{ {
global $conf; global $conf;
@ -2287,13 +2287,13 @@ class Facture extends CommonObject
$sql = "SELECT f.rowid as rowid, f.facnumber"; $sql = "SELECT f.rowid as rowid, f.facnumber";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source AND ff.type=1"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=1)";
$sql.= " WHERE f.fk_statut >= 1 AND f.paye = 0"; $sql.= " WHERE f.fk_statut >= 1 AND f.paye = 0";
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
$sql.= " ORDER BY f.facnumber"; $sql.= " ORDER BY f.facnumber";
dolibarr_syslog("Facture.class::list_avoir_invoices sql=$sql"); dolibarr_syslog("Facture.class::list_qualified_avoir_invoices sql=$sql");
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -1174,7 +1174,7 @@ class Form
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if ($useempty) if ($useempty)
{ {
print '<option value="'.$obj->rowid.'">&nbsp</option>'; print '<option value="'.$obj->rowid.'">&nbsp;</option>';
} }
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
@ -1501,7 +1501,7 @@ class Form
* \param title title * \param title title
* \param question question * \param question question
* \param action action * \param action action
* \param formquestion an array with forms compementary inputs * \param formquestion an array with forms complementary inputs
*/ */
function form_confirm($page, $title, $question, $action, $formquestion='') function form_confirm($page, $title, $question, $action, $formquestion='')
@ -1524,7 +1524,14 @@ class Form
print '<tr><td colspan="3" valign="top">'.$formquestion['text'].'</td></tr>'; print '<tr><td colspan="3" valign="top">'.$formquestion['text'].'</td></tr>';
foreach ($formquestion as $key => $input) foreach ($formquestion as $key => $input)
{ {
if ($input['type'] == 'text') print '<tr><td valign="top">'.$input['label'].'</td><td colspan="2"><input type="text" class="flat" name="'.$input['name'].'" size="'.$input['size'].'" value="'.$input['value'].'"></td></tr>'; if ($input['type'] == 'text')
{
print '<tr><td valign="top">'.$input['label'].'</td><td colspan="2"><input type="text" class="flat" name="'.$input['name'].'" size="'.$input['size'].'" value="'.$input['value'].'"></td></tr>';
}
if ($input['type'] == 'select')
{
// TODO
}
if ($input['type'] == 'radio') if ($input['type'] == 'radio')
{ {
$i=0; $i=0;
@ -1541,19 +1548,26 @@ class Form
} }
} }
} }
print '</tr></table>'; print '</table>';
print '</td>'; print '</td></tr>';
} }
// Ligne message // Ligne message
print '<tr class="valid"><td class="valid">'.$question.'</td>'; print '<tr class="valid">';
print '<td class="valid">'.$question.'</td>';
print '<td class="valid">'; print '<td class="valid">';
$this->selectyesno("confirm","no"); $this->selectyesno("confirm","no");
print '</td>'; print '</td>';
print '<td class="valid" align="center"><input class="button" type="submit" value="'.$langs->trans("Confirm").'"></td></tr>'; print '<td class="valid" align="center"><input class="button" type="submit" value="'.$langs->trans("Validate").'"></td>';
print '</tr>';
print '</table>'; print '</table>';
foreach ($formquestion as $key => $input)
{
if ($input['type'] == 'hidden') print '<input type="hidden" name="'.$input['name'].'" value="'.$input['value'].'">';
}
print "</form>\n"; print "</form>\n";
} }

View File

@ -40,13 +40,15 @@ Payments=Payments
PaymentType=Payment type PaymentType=Payment type
PaymentTypes=Payment types PaymentTypes=Payment types
ReceivedPayments=Received payments ReceivedPayments=Received payments
ReceivedCustomersPayments=Received customers payments ReceivedCustomersPayments=Payments received from customers
ReceivedCustomersPaymentsToValid=Received customers payments to validate ReceivedCustomersPaymentsToValid=Received customers payments to validate
PaymentsReportsForYear=Payments reports for %s PaymentsReportsForYear=Payments reports for %s
PaymentsReports=Payments reports PaymentsReports=Payments reports
PaymentsAlreadyDone=Payments already done PaymentsAlreadyDone=Payments already done
PaymentMode=Payment mode PaymentMode=Payment mode
PaymentConditionsShort=Payment conditions PaymentConditionsShort=Payment conditions
PaymentAmount=Payment amount
PaymentHigherThanReminderToPay=Payment higher than reminder to pay
ClassifyPayed=Classify 'Payed' ClassifyPayed=Classify 'Payed'
ClassifyPayedPartially=Classify 'Payed partially' ClassifyPayedPartially=Classify 'Payed partially'
ClassifyCanceled=Classify 'Abandonned' ClassifyCanceled=Classify 'Abandonned'
@ -119,6 +121,7 @@ ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture
ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction») ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix à prendre si les autres ne sont pas applicables ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix à prendre si les autres ne sont pas applicables
ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement
ConfirmCustomerPayment=Do you confirm this paiement input for <b>%s</b> %s ?
ValidateBill=Validate invoice ValidateBill=Validate invoice
NumberOfBills=Nb of invoices NumberOfBills=Nb of invoices
NumberOfBillsByMonth=Nb of invoices by month NumberOfBillsByMonth=Nb of invoices by month

View File

@ -40,13 +40,15 @@ Payments=Paiements
PaymentType=Type de paiement PaymentType=Type de paiement
PaymentTypes=Types de paiements PaymentTypes=Types de paiements
ReceivedPayments=Paiements reçus ReceivedPayments=Paiements reçus
ReceivedCustomersPayments=Paiements clients reçus ReceivedCustomersPayments=Paiements reçus du client
ReceivedCustomersPaymentsToValid=Paiements clients reçus à valider ReceivedCustomersPaymentsToValid=Paiements clients reçus à valider
PaymentsReportsForYear=Rapports de paiements pour %s PaymentsReportsForYear=Rapports de paiements pour %s
PaymentsReports=Rapports de paiements PaymentsReports=Rapports de paiements
PaymentsAlreadyDone=Versements déjà effectués PaymentsAlreadyDone=Versements déjà effectués
PaymentMode=Mode règlement PaymentMode=Mode règlement
PaymentConditionsShort=Conditions règlement PaymentConditionsShort=Conditions règlement
PaymentAmount=Montant paiement
PaymentHigherThanReminderToPay=Paiement supérieur au reste à payer
ClassifyPayed=Classer 'Payée' ClassifyPayed=Classer 'Payée'
ClassifyPayedPartially=Classer 'Payée partiellement' ClassifyPayedPartially=Classer 'Payée partiellement'
ClassifyCanceled=Classer 'Abandonnée' ClassifyCanceled=Classer 'Abandonnée'
@ -119,6 +121,7 @@ ConfirmClassifyPayedPartiallyAvoir=Ce choix est le choix
ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «escompte net de taxe») ConfirmClassifyPayedPartiallyNoVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: «escompte net de taxe»)
ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: mention définissant l'escompte ou du genre «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction») ConfirmClassifyPayedPartiallyVat=Ce choix est possible si votre facture était munie de la mention adéquate. (Exemple: mention définissant l'escompte ou du genre «seule la taxe correspondant au prix effectivement payé ouvre droit à déduction»)
ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement ConfirmClassifyPayedPartiallyAbandon=Ce choix sera celui dans le cas d'un mauvais payeur sans aucun espoir de recouvrement
ConfirmCustomerPayment=Confirmez-vous la saisie de ce paiement de <b>%s</b> %s ?
ValidateBill=Valider facture ValidateBill=Valider facture
NumberOfBills=Nb de factures NumberOfBills=Nb de factures
NumberOfBillsByMonth=Nb de factures par mois NumberOfBillsByMonth=Nb de factures par mois

View File

@ -73,12 +73,12 @@ class Paiement
function fetch($id) function fetch($id)
{ {
$sql = 'SELECT p.rowid,'.$this->db->pdate('p.datep').' as dp, p.amount, p.statut, p.fk_bank'; $sql = 'SELECT p.rowid,'.$this->db->pdate('p.datep').' as dp, p.amount, p.statut, p.fk_bank';
$sql .=', c.libelle as paiement_type'; $sql.= ', c.code as type_code, c.libelle as type_libelle';
$sql .= ', p.num_paiement, p.note, b.fk_account'; $sql.= ', p.num_paiement, p.note, b.fk_account';
$sql .= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.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 as b ON p.fk_bank = b.rowid ';
$sql .= ' WHERE p.fk_paiement = c.id'; $sql.= ' WHERE p.fk_paiement = c.id';
$sql .= ' AND p.rowid = '.$id; $sql.= ' AND p.rowid = '.$id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -93,7 +93,8 @@ class Paiement
$this->bank_line = $obj->fk_bank; $this->bank_line = $obj->fk_bank;
$this->montant = $obj->amount; $this->montant = $obj->amount;
$this->note = $obj->note; $this->note = $obj->note;
$this->type_libelle = $obj->paiement_type; $this->type_libelle = $obj->type_libelle;
$this->type_code = $obj->type_code;
$this->statut = $obj->statut; $this->statut = $obj->statut;
return 1; return 1;
} }

View File

@ -479,6 +479,9 @@ alter table llx_facturedet_rec add column total_tva real;
alter table llx_facturedet_rec add column total_ttc real; alter table llx_facturedet_rec add column total_ttc real;
update llx_facture set fk_facture_source=null where fk_facture_source is not null and type = 0;
update llx_boxes set fk_user = 0 where fk_user IS NULL; update llx_boxes set fk_user = 0 where fk_user IS NULL;
ALTER TABLE llx_boxes modify fk_user integer default 0 NOT NULL; ALTER TABLE llx_boxes modify fk_user integer default 0 NOT NULL;