Added payment num and date edition feature / draft payment for payments of provider invoices

This commit is contained in:
ywarnier 2008-06-01 19:19:00 +00:00
parent 940de2a055
commit 1747533bc2
5 changed files with 158 additions and 12 deletions

View File

@ -49,6 +49,7 @@ class PaiementFourn
var $bank_account; // Id compte bancaire du paiement
var $bank_line; // Id de la ligne d'<27>criture bancaire
var $note;
var $statut; //Status of payment. 0 = unvalidated; 1 = validated
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement
@ -486,5 +487,59 @@ class PaiementFourn
if ($withpicto != 2) $result.=$lien.$this->rowid.$lienfin;
return $result;
}
/**
* \brief Updates the payment number
* \param string New num
* \return int -1 on error, 0 otherwise
*/
function update_num($num)
{
if(!empty($num) && $this->statut!=1)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET num_paiement = \''.$this->db->escape($num).'\' WHERE rowid = '.$this->id;
dolibarr_syslog("PaiementFourn::update_num sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->numero = $this->db->escape($num);
return 0;
}
else
{
$this->error='PaiementFourn::update_num Error -1 '.$this->db->error();
dolibarr_syslog('PaiementFourn::update_num error '.$this->error);
return -1;
}
}
return -1; //no num given or already validated
}
/**
* \brief Updates the payment date
* \param string New date
* \return int -1 on error, 0 otherwise
*/
function update_date($date)
{
if(!empty($date) && $this->statut!=1)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET datep = '.$this->db->idate($date).' WHERE rowid = '.$this->id;
dolibarr_syslog("PaiementFourn::update_date sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
$this->datepaye = $date;
$this-> date = $date;
return 0;
}
else
{
$this->error='PaiementFourn::update_date Error -1 '.$this->db->error();
dolibarr_syslog('PaiementFourn::update_date error '.$this->error);
return -1;
}
}
return -1; //no date given or already validated
}
}
?>

View File

@ -115,7 +115,7 @@ dolibarr_fiche_head($head, $hselected, $langs->trans('SupplierPayment'));
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');
print '<br>';
print '<br />';
}
/*
@ -124,17 +124,40 @@ if ($_GET['action'] == 'delete')
if ($_GET['action'] == 'valide')
{
$html->form_confirm('fiche.php?id='.$paiement->id, 'Valider le paiement', '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 />';
}
if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
{
$res = $paiement->update_num($_POST['new_num']);
if ($res === 0) {
$mesg = $langs->trans('PaymentNumberUpdateSucceeded');
} else {
$mesg = $langs->trans('PaymentNumberUpdateFailed');
}
}
if ($mesg) print $mesg.'<br>';
if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
{
$datepaye = dolibarr_mktime(12, 0 , 0,
$_POST['remonth'],
$_POST['reday'],
$_POST['reyear']);
$res = $paiement->update_date($datepaye);
if ($res === 0) {
$mesg = $langs->trans('PaymentDateUpdateSucceeded');
} else {
$mesg = $langs->trans('PaymentDateUpdateFailed');
}
}
if ($mesg) print $mesg.'<br />';
print '<table class="border" width="100%">';
print '<tr>';
print '<td valign="top" width="140">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
print '<td valign="top" width="140" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
if ($conf->banque->enabled)
{
if ($paiement->bank_account)
@ -147,21 +170,77 @@ if ($conf->banque->enabled)
$bankline->fetch($paiement->bank_line);
print '<tr>';
print '<td valign="top" width="140">'.$langs->trans('BankAccount').'</td>';
print '<td valign="top" width="140" colspan="2">'.$langs->trans('BankAccount').'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$bank->id.'">'.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.'</a></td>';
print '<td>'.$langs->trans('BankLineConciliated').'</td><td>'.yn($bankline->rappro).'</td>';
print '</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>';
//switch through edition options for date (only available when statut is -not 1- (=validated))
if($paiement->statut == 0)
{
if(empty($_GET['action']) or $_GET['action']!='edit_date')
{
print '<tr><td valign="top">'.$langs->trans('Date').'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'&action=edit_date">'.img_edit().'</a></td>';
print '<td colspan="3">'.dolibarr_print_date($paiement->date).'</td></tr>';
}
else
{
print '<tr><form name="formsoc" method="post" action="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'"><input type="hidden" name="action" value="update_date" />';
print '<td valign="top" width="140" colspan="2">'.$langs->trans('Date').'</td>';
print '<td colspan="3">';
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=$paiement->date;
$html->select_date($sel_date,'','','','',"addpaiement");
print '<input type="submit" name="submit" value="'.$langs->trans('Validate').'" />';
print '</td>';
print '</form></tr>';
}
}
else
{
print '<tr><td valign="top" colspan="2">'.$langs->trans('Date').'</td>';
print '<td colspan="3">'.dolibarr_print_date($paiement->date).'</td></tr>';
}
print '<tr><td valign="top" colspan="2">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
//switch through edition options for number (only available when statut is -not 1- (=validated))
if ($paiement->numero)
{
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
if ($paiement->statut == 0)
{
if(empty($_GET['action']) or $_GET['action'] != 'edit_num')
{
print '<tr><td valign="top">'.$langs->trans('Numero').'</td>';
print '<td align="right"><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'&action=edit_num">'.img_edit().'</a></td>';
print '<td colspan="3">'.$paiement->numero.'</td></tr>';
}
else
{
print '<tr><form name="formsoc" method="post" action="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement->id.'"><input type="hidden" name="action" value="update_num" />';
print '<td valign="top" width="140" colspan="2">'.$langs->trans('Date').'</td>';
print '<td colspan="3">';
if (!empty($_POST['new_num']))
$num = $this->db->escape($_POST['new_num']);
else
$num = $paiement->numero;
print '<input type="text" name="new_num" value="'.$num.'"/>';
print '<input type="submit" name="submit" value="'.$langs->trans('Validate').'" />';
print '</td>';
print '</form></tr>';
}
}
else
{
print '<tr><td valign="top" colspan="2">'.$langs->trans('Numero').'</td>';
print '<td colspan="3">'.$paiement->numero.'</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>';
print '<tr><td valign="top">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>';
print '<tr><td valign="top" colspan="2">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
print '</table>';
@ -180,7 +259,7 @@ if ($resql)
$i = 0;
$total = 0;
print '<br>'.$langs->trans("Invoices").'<br>';
print '<br /><b>'.$langs->trans("Invoices").'</b><br />';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';

View File

@ -115,3 +115,7 @@ CashBudget=Cash budget
ExportDataset_banque_1=Bank transactions and account statement
TransactionOnTheOtherAccount=Transaction on the other account
TransactionWithOtherAccount=Account transfert
PaymentNumberUpdateSucceeded=Payment number updated succesfully
PaymentNumberUpdateFailed=Payment number could not be updated
PaymentDateUpdateSucceeded=Payment date update succesfully
PaymentDateUpdateFailed=Payment date could not be updated

View File

@ -116,3 +116,7 @@ CashBudget=Presupuesto de tesorer
ExportDataset_banque_1=Transacción bancaria y extracto
TransactionOnTheOtherAccount=Transacción sobre la otra cuenta
TransactionWithOtherAccount=Transferencia de cuenta
PaymentNumberUpdateSucceeded=Numero de pago modificado
PaymentNumberUpdateFailed=Numero de pago no pudo ser modificado
PaymentDateUpdateSucceeded=Fecha de pago modificada
PaymentDateUpdateFailed=Fecha de pago no pudo ser modificada

View File

@ -115,3 +115,7 @@ CashBudget=Budget de tr
ExportDataset_banque_1=Transaction bancaire et relevé
TransactionOnTheOtherAccount=Transaction sur l'autre compte
TransactionWithOtherAccount=Transfert de compte
PaymentNumberUpdateSucceeded=Numéro de paiement mis à jour
PaymentNumberUpdateFailed=Impossible de mettre le numéro de paiement à jour
PaymentDateUpdateSucceeded=Date de paiement mise à jour
PaymentDateUpdateFailed=Impossible de mettre la date de paiement à jour