Withdrawals: Visual enhancements. Solve payment date pb.
This commit is contained in:
parent
77cb4b1fba
commit
a6b29bf9d6
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -39,29 +39,39 @@ class RejetPrelevement
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* Class constructor
|
||||||
* \param DB Handler acces base de donnees
|
* @param DB Database Handler access
|
||||||
* \param user Utilisateur
|
* @param user User
|
||||||
*/
|
*/
|
||||||
function RejetPrelevement($DB, $user)
|
function RejetPrelevement($DB, $user)
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
$this->db = $DB ;
|
$this->db = $DB ;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
$this->motifs = array();
|
$this->motifs = array();
|
||||||
/* $this->motifs[0] = "Non renseigne";
|
$this->facturer = array();
|
||||||
$this->motifs[1] = "Provision insuffisante";
|
|
||||||
$this->motifs[2] = "Tirage conteste";
|
$this->motifs[0] = $langs->trans("StatusMotif0");
|
||||||
$this->motifs[3] = "Pas de bon <20> payer";
|
$this->motifs[1] = $langs->trans("StatusMotif1");
|
||||||
$this->motifs[4] = "Opposition sur compte";
|
$this->motifs[2] = $langs->trans("StatusMotif2");
|
||||||
$this->motifs[5] = "RIB inexploitable";
|
$this->motifs[3] = $langs->trans("StatusMotif3");
|
||||||
$this->motifs[6] = "Compte solde";
|
$this->motifs[4] = $langs->trans("StatusMotif4");
|
||||||
$this->motifs[7] = "Decision judiciaire";
|
$this->motifs[5] = $langs->trans("StatusMotif5");
|
||||||
$this->motifs[8] = "Autre motif";*/
|
$this->motifs[6] = $langs->trans("StatusMotif6");
|
||||||
|
$this->motifs[7] = $langs->trans("StatusMotif7");
|
||||||
|
$this->motifs[8] = $langs->trans("StatusMotif8");
|
||||||
|
|
||||||
|
$this->facturer[0]=$langs->trans("NoInvoiceRefused");
|
||||||
|
$this->facturer[1]=$langs->trans("InvoiceRefused");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function create($user, $id, $motif, $date_rejet, $bonid, $facturation=0)
|
function create($user, $id, $motif, $date_rejet, $bonid, $facturation=0)
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->bon_id = $bonid;
|
$this->bon_id = $bonid;
|
||||||
@ -72,9 +82,7 @@ class RejetPrelevement
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
// Insert refused line into database
|
||||||
/* Insert la ligne de rejet dans la base */
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_rejet (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_rejet (";
|
||||||
$sql.= "fk_prelevement_lignes";
|
$sql.= "fk_prelevement_lignes";
|
||||||
$sql.= ", date_rejet";
|
$sql.= ", date_rejet";
|
||||||
@ -100,8 +108,7 @@ class RejetPrelevement
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tag la ligne de prev comme rejetee */
|
// Tag the line to refused
|
||||||
|
|
||||||
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes ";
|
$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes ";
|
||||||
$sql.= " SET statut = 3";
|
$sql.= " SET statut = 3";
|
||||||
$sql.= " WHERE rowid = ".$id;
|
$sql.= " WHERE rowid = ".$id;
|
||||||
@ -118,39 +125,39 @@ class RejetPrelevement
|
|||||||
$fac = new Facture($this->db);
|
$fac = new Facture($this->db);
|
||||||
$fac->fetch($facs[$i]);
|
$fac->fetch($facs[$i]);
|
||||||
|
|
||||||
/* Emet un paiement negatif */
|
// Make a negative payment
|
||||||
|
|
||||||
$pai = new Paiement($this->db);
|
$pai = new Paiement($this->db);
|
||||||
|
|
||||||
$pai->amounts = array();
|
$pai->amounts = array();
|
||||||
// On remplace la virgule eventuelle par un point sinon
|
|
||||||
// certaines install de PHP renvoie uniquement la partie
|
/*
|
||||||
// entiere negative
|
* We replace the comma with a point otherwise some
|
||||||
|
* PHP installs sends only the part integer negative
|
||||||
|
*/
|
||||||
|
|
||||||
$pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1);
|
$pai->amounts[$facs[$i]] = price2num($fac->total_ttc * -1);
|
||||||
$pai->datepaye = $this->db->idate($date_rejet);
|
$pai->datepaye = $date_rejet;
|
||||||
$pai->paiementid = 3; // prelevement
|
$pai->paiementid = 3; // type of payment: withdrawal
|
||||||
$pai->num_paiement = "Rejet";
|
$pai->num_paiement = $langs->trans("StatusRefused");
|
||||||
|
|
||||||
if ($pai->create($this->user, 1) == -1) // on appelle en no_commit
|
if ($pai->create($this->user, 1) == -1) // we call with no_commit
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog("RejetPrelevement::Create Erreur creation paiement facture ".$facs[$i]);
|
dol_syslog("RejetPrelevement::Create Erreur creation paiement facture ".$facs[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Valide le paiement */
|
// Payment validation
|
||||||
|
|
||||||
if ($pai->valide() < 0)
|
if ($pai->valide() < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dol_syslog("RejetPrelevement::Create Erreur validation du paiement");
|
dol_syslog("RejetPrelevement::Create Erreur validation du paiement");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tag la facture comme impayee */
|
// Tag invoice as unpaid
|
||||||
dol_syslog("RejetPrelevement::Create set_unpaid fac ".$fac->ref);
|
dol_syslog("RejetPrelevement::Create set_unpaid fac ".$fac->ref);
|
||||||
$fac->set_unpaid($fac->id, $user);
|
$fac->set_unpaid($fac->id, $user);
|
||||||
|
|
||||||
/* Envoi un email <20> l'emetteur de la demande de prev */
|
// Send email to sender of the standing order request
|
||||||
$this->_send_email($fac);
|
$this->_send_email($fac);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,8 +175,8 @@ class RejetPrelevement
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Envoi mail
|
* Envoi mail
|
||||||
* \param fac Invoice object
|
* @param fac Invoice object
|
||||||
*/
|
*/
|
||||||
function _send_email($fac)
|
function _send_email($fac)
|
||||||
{
|
{
|
||||||
@ -240,20 +247,16 @@ class RejetPrelevement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recupere la liste des factures concernees
|
* Retrieve the list of invoices
|
||||||
*/
|
*/
|
||||||
function _get_list_factures()
|
function _get_list_factures()
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
/*
|
|
||||||
* Renvoie toutes les factures associ<EFBFBD>e <EFBFBD> un pr<EFBFBD>l<EFBFBD>vement
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
//Returns all invoices of a withdrawal
|
||||||
$sql = "SELECT f.rowid as facid";
|
$sql = "SELECT f.rowid as facid";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||||
@ -287,16 +290,14 @@ class RejetPrelevement
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recupere l'objet prelevement
|
* Retrieve withdrawal object
|
||||||
* \param rowid id de la facture a recuperer
|
* @param rowid id of invoice to retrieve
|
||||||
*/
|
*/
|
||||||
function fetch($rowid)
|
function fetch($rowid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT pr.date_rejet as dr, motif";
|
$sql = "SELECT pr.date_rejet as dr, motif, afacturer";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_rejet as pr";
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_rejet as pr";
|
||||||
$sql.= " WHERE pr.fk_prelevement_lignes =".$rowid;
|
$sql.= " WHERE pr.fk_prelevement_lignes =".$rowid;
|
||||||
|
|
||||||
@ -310,6 +311,7 @@ class RejetPrelevement
|
|||||||
$this->id = $rowid;
|
$this->id = $rowid;
|
||||||
$this->date_rejet = $this->db->jdate($obj->dr);
|
$this->date_rejet = $this->db->jdate($obj->dr);
|
||||||
$this->motif = $this->motifs[$obj->motif];
|
$this->motif = $this->motifs[$obj->motif];
|
||||||
|
$this->invoicing = $this->facturer[$obj->afacturer];
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ if ($_GET["id"])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "Erreur";
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -125,8 +125,6 @@ if ($_GET["id"])
|
|||||||
print '<div class="error">'.$bon->ReadError($_GET["error"]).'</div>';
|
print '<div class="error">'.$bon->ReadError($_GET["error"]).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'credite')
|
if ($_GET["action"] == 'credite')
|
||||||
{
|
{
|
||||||
$ret=$html->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
|
$ret=$html->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
|
||||||
@ -165,12 +163,12 @@ if ($_GET["id"])
|
|||||||
}
|
}
|
||||||
if($bon->date_credit <> 0)
|
if($bon->date_credit <> 0)
|
||||||
{
|
{
|
||||||
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
|
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td>>';
|
||||||
print dol_print_date($bon->date_credit,'day');
|
print dol_print_date($bon->date_credit,'day');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table><br>';
|
print '</table>';
|
||||||
|
|
||||||
if($bon->date_trans == 0)
|
if($bon->date_trans == 0)
|
||||||
{
|
{
|
||||||
@ -188,10 +186,10 @@ if ($_GET["id"])
|
|||||||
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
|
||||||
print '<input class="flat" type="file" name="userfile" size="80"><br>';
|
print '<input class="flat" type="file" name="userfile" size="80"><br>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td colspan="2" align="center">';
|
print '</table>';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Send").'">';
|
dol_fiche_end();
|
||||||
print '</td></tr>';
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Send").'">';
|
||||||
print '</table></form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bon->date_trans <> 0 && $bon->date_credit == 0)
|
if($bon->date_trans <> 0 && $bon->date_credit == 0)
|
||||||
@ -203,12 +201,11 @@ if ($_GET["id"])
|
|||||||
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
|
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
|
||||||
print $html->select_date('','','','','',"infocredit");
|
print $html->select_date('','','','','',"infocredit");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td colspan="2" align="center">';
|
print '</table>';
|
||||||
print '<input type="submit" class="button" value="'.$langs->trans("Send").'">';
|
dol_fiche_end();
|
||||||
print '</td></tr>';
|
print '<center><input type="submit" class="button" value="'.$langs->trans("Send").'">';
|
||||||
print '</table></form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -216,24 +213,22 @@ if ($_GET["id"])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* Barre d'action */
|
/* Barre d'action */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
/*
|
||||||
print "\n</div>\n<div class=\"tabsAction\">\n";
|
print "\n</div>\n<div class=\"tabsAction\">\n";
|
||||||
|
|
||||||
/*if ($bon->statut == 0)
|
if ($bon->statut == 0)
|
||||||
{
|
{
|
||||||
print "<a class=\"butAction\" href=\"fiche.php?action=credite&id=$bon->id\">".$langs->trans("ClassCredited")."</a>";
|
print "<a class=\"butAction\" href=\"fiche.php?action=credite&id=$bon->id\">".$langs->trans("ClassCredited")."</a>";
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$');
|
llxFooter('$Date$ - $Revision$');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user