2005-01-07 16:26:30 +01:00
< ? PHP
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2005-01-21 23:59:48 +01:00
* Copyright ( C ) 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-01-07 16:26:30 +01:00
*
* 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
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*
* $Id $
* $Source $
*/
2005-01-21 23:59:48 +01:00
/**
2005-09-10 16:24:10 +02:00
\file htdocs / compta / prelevement / fiche . php
\ingroup prelevement
\brief Fiche prelevement
\version $Revision $
2005-01-21 23:59:48 +01:00
*/
2005-01-07 16:26:30 +01:00
require ( " ./pre.inc.php " );
2005-08-03 18:05:00 +02:00
if ( ! $user -> rights -> prelevement -> bons -> lire )
accessforbidden ();
2005-01-21 23:59:48 +01:00
$langs -> load ( " bills " );
2005-01-07 16:26:30 +01:00
/*
* S<EFBFBD> curit<EFBFBD> acc<EFBFBD> s client
*/
2005-01-18 16:45:30 +01:00
if ( $user -> societe_id > 0 ) accessforbidden ();
if ( $_POST [ " action " ] == 'confirm_credite' && $_POST [ " confirm " ] == yes )
2005-01-07 16:26:30 +01:00
{
2005-01-18 16:45:30 +01:00
$bon = new BonPrelevement ( $db , " " );
$bon -> id = $_GET [ " id " ];
$bon -> set_credite ();
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
2005-01-07 16:26:30 +01:00
}
2005-01-21 14:57:02 +01:00
if ( $_POST [ " action " ] == 'infotrans' )
{
$bon = new BonPrelevement ( $db , " " );
2005-04-05 16:23:45 +02:00
$bon -> fetch ( $_GET [ " id " ]);
if ( $_FILES [ 'userfile' ][ 'name' ] && basename ( $_FILES [ 'userfile' ][ 'name' ], " .ps " ) == $bon -> ref )
{
2005-09-10 16:24:10 +02:00
$dir = $conf -> prelevement -> dir_output . '/bon/' ;
2005-01-21 14:57:02 +01:00
2005-04-05 16:23:45 +02:00
if ( doliMoveFileUpload ( $_FILES [ 'userfile' ][ 'tmp_name' ], $dir . " / " . $_FILES [ 'userfile' ][ 'name' ]))
{
$dt = mktime ( 12 , 0 , 0 , $_POST [ " remonth " ], $_POST [ " reday " ], $_POST [ " reyear " ]);
$bon -> set_infotrans ( $user , $dt , $_POST [ " methode " ]);
}
}
2005-08-03 17:17:53 +02:00
else
{
dolibarr_syslog ( " Fichier invalide " , LOG_WARN );
}
2005-01-21 14:57:02 +01:00
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
}
if ( $_POST [ " action " ] == 'infocredit' )
{
$bon = new BonPrelevement ( $db , " " );
2005-08-03 17:17:53 +02:00
$bon -> Fetch ( $_GET [ " id " ]);
2005-01-21 14:57:02 +01:00
$dt = mktime ( 12 , 0 , 0 , $_POST [ " remonth " ], $_POST [ " reday " ], $_POST [ " reyear " ]);
2005-08-03 17:17:53 +02:00
$error = $bon -> set_infocredit ( $user , $dt );
2005-01-21 14:57:02 +01:00
2005-08-03 17:17:53 +02:00
if ( $error == 0 )
{
Header ( " Location: fiche.php?id= " . $_GET [ " id " ]);
}
else
{
Header ( " Location: fiche.php?id= " . $_GET [ " id " ] . " &error= $error " );
}
2005-01-21 14:57:02 +01:00
}
2005-01-18 16:45:30 +01:00
llxHeader ( '' , 'Bon de pr<70> l<EFBFBD> vement' );
2005-01-07 16:26:30 +01:00
$h = 0 ;
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/fiche.php?id=' . $_GET [ " id " ];
2005-01-21 23:59:48 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Card " );
2005-01-07 16:26:30 +01:00
$hselected = $h ;
$h ++ ;
2005-09-10 16:24:10 +02:00
if ( $conf -> use_preview_tabs )
{
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/bon.php?id=' . $_GET [ " id " ];
$head [ $h ][ 1 ] = $langs -> trans ( " Preview " );
$h ++ ;
}
2005-03-11 16:57:57 +01:00
2005-03-01 14:34:13 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/lignes.php?id=' . $_GET [ " id " ];
2005-09-10 16:24:10 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Lines " );
2005-03-01 14:34:13 +01:00
$h ++ ;
2005-01-18 16:45:30 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/factures.php?id=' . $_GET [ " id " ];
2005-01-21 23:59:48 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Bills " );
2005-01-18 16:45:30 +01:00
$h ++ ;
2005-01-07 16:26:30 +01:00
2005-01-24 16:43:00 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/fiche-rejet.php?id=' . $_GET [ " id " ];
2005-09-10 16:24:10 +02:00
$head [ $h ][ 1 ] = $langs -> trans ( " Rejects " );
2005-01-24 16:43:00 +01:00
$h ++ ;
2005-01-21 14:57:02 +01:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/prelevement/fiche-stat.php?id=' . $_GET [ " id " ];
2005-01-21 23:59:48 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " Statistics " );
2005-01-21 14:57:02 +01:00
$h ++ ;
2005-01-11 15:40:08 +01:00
$prev_id = $_GET [ " id " ];
2005-01-21 14:57:02 +01:00
$html = new Form ( $db );
2005-01-11 15:40:08 +01:00
if ( $_GET [ " id " ])
{
$bon = new BonPrelevement ( $db , " " );
if ( $bon -> fetch ( $_GET [ " id " ]) == 0 )
{
2005-01-18 16:45:30 +01:00
dolibarr_fiche_head ( $head , $hselected , 'Pr<50> l<EFBFBD> vement : ' . $bon -> ref );
2005-08-03 17:17:53 +02:00
if ( isset ( $_GET [ " error " ]))
{
print '<div class="error">' . $bon -> ReadError ( $_GET [ " error " ]) . '</div>' ;
}
2005-01-18 16:45:30 +01:00
if ( $_GET [ " action " ] == 'credite' )
{
$html -> form_confirm ( " fiche.php?id= " . $bon -> id , " Classer comme cr<63> dit<69> " , " Etes-vous s<> r de vouloir classer ce bon de pr<70> l<EFBFBD> vement comme cr<63> dit<69> sur votre compte bancaire ? " , " confirm_credite " );
print '<br />' ;
}
2005-01-11 15:40:08 +01:00
print '<table class="border" width="100%">' ;
2005-01-21 23:59:48 +01:00
print '<tr><td width="20%">' . $langs -> trans ( " Ref " ) . '</td><td>' . $bon -> ref . '</td></tr>' ;
2005-08-03 17:17:53 +02:00
print '<tr><td width="20%">' . $langs -> trans ( " Date " ) . '</td><td>' . strftime ( " %e %B %Y " , $bon -> datec ) . '</td></tr>' ;
2005-01-21 23:59:48 +01:00
print '<tr><td width="20%">' . $langs -> trans ( " Amount " ) . '</td><td>' . price ( $bon -> amount ) . '</td></tr>' ;
print '<tr><td width="20%">' . $langs -> trans ( " File " ) . '</td><td>' ;
2005-01-11 15:40:08 +01:00
2005-02-09 20:37:21 +01:00
$relativepath = 'bon/' . $bon -> ref ;
2005-01-11 15:40:08 +01:00
2005-02-09 20:37:21 +01:00
print '<a href="' . DOL_URL_ROOT . '/document.php?type=text/plain&modulepart=prelevement&file=' . urlencode ( $relativepath ) . '">' . $bon -> ref . '</a>' ;
2005-01-11 15:40:08 +01:00
print '</td></tr>' ;
2005-01-21 14:57:02 +01:00
2005-03-01 17:06:16 +01:00
print '<tr><td width="20%">Statut</td><td>' ;
print '<img src="./statut' . $bon -> statut . '.png"> ' ;
print $lipre -> statuts [ $lipre -> statut ] . '</td></tr>' ;
2005-01-21 14:57:02 +01:00
if ( $bon -> date_trans <> 0 )
{
$muser = new User ( $db , $bon -> user_trans );
$muser -> fetch ();
print '<tr><td width="20%">Date Transmission / Par</td><td>' ;
2005-08-03 17:17:53 +02:00
print strftime ( " %e %B %Y " , $bon -> date_trans );
2005-01-21 14:57:02 +01:00
print ' par ' . $muser -> fullname . '</td></tr>' ;
print '<tr><td width="20%">M<> thode Transmission</td><td>' ;
print $bon -> methodes_trans [ $bon -> method_trans ];
print '</td></tr>' ;
}
if ( $bon -> date_credit <> 0 )
{
print '<tr><td width="20%">Cr<43> dit<69> le</td><td>' ;
2005-08-03 17:17:53 +02:00
print strftime ( " %e %B %Y " , $bon -> date_credit );
2005-01-21 14:57:02 +01:00
print '</td></tr>' ;
}
2005-01-18 16:45:30 +01:00
print '</table><br />' ;
2005-01-21 14:57:02 +01:00
if ( $bon -> date_trans == 0 )
{
2005-04-05 16:23:45 +02:00
print '<form method="post" name="userfile" action="fiche.php?id=' . $bon -> id . '" enctype="multipart/form-data">' ;
2005-01-21 14:57:02 +01:00
print '<input type="hidden" name="action" value="infotrans">' ;
print '<table class="border" width="100%">' ;
print '<tr><td width="20%">Date Transmission</td><td>' ;
print $html -> select_date ();
print '</td></tr>' ;
print '<tr><td width="20%">M<> thode Transmission</td><td>' ;
print $html -> select_array ( " methode " , $bon -> methodes_trans );
print '</td></tr>' ;
2005-04-05 16:23:45 +02:00
print '<tr><td width="20%">Fichier</td><td>' ;
print '<input type="file" name="userfile" size="30" maxlength="80"><br />' ;
print '</td></tr>' ;
2005-01-21 14:57:02 +01:00
print '<tr><td colspan="2" align="center">' ;
2005-09-10 16:26:15 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Send " ) . '">' ;
2005-01-21 14:57:02 +01:00
print '</td></tr>' ;
print '</table></form>' ;
}
if ( $bon -> date_trans <> 0 && $bon -> date_credit == 0 )
{
print '<form method="post" action="fiche.php?id=' . $bon -> id . '">' ;
print '<input type="hidden" name="action" value="infocredit">' ;
print '<table class="border" width="100%">' ;
print '<tr><td width="20%">Cr<43> dit<69> le</td><td>' ;
print $html -> select_date ();
print '</td></tr>' ;
print '<tr><td colspan="2" align="center">' ;
2005-09-10 16:26:15 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( " Send " ) . '">' ;
2005-01-21 14:57:02 +01:00
print '</td></tr>' ;
print '</table></form>' ;
}
2005-01-11 15:40:08 +01:00
}
else
{
2005-01-21 23:59:48 +01:00
dolibarr_print_error ( $db );
2005-01-11 15:40:08 +01:00
}
}
2005-01-18 16:45:30 +01:00
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
2005-01-11 15:40:08 +01:00
2005-01-18 16:45:30 +01:00
print " \n </div> \n <div class= \" tabsAction \" > \n " ;
2005-01-07 16:26:30 +01:00
2005-01-18 16:45:30 +01:00
if ( $_GET [ " action " ] == '' )
{
2005-01-07 16:26:30 +01:00
2005-01-18 16:45:30 +01:00
if ( $bon -> credite == 0 )
{
print " <a class= \" tabAction \" href= \" fiche.php?action=credite&id= $bon->id\ " > " . $langs->trans ( " Classer cr<EFBFBD> dit<EFBFBD> " ). " </ a > " ;
}
2005-01-07 16:26:30 +01:00
2005-01-18 16:45:30 +01:00
2005-01-07 16:26:30 +01:00
}
2005-01-18 16:45:30 +01:00
print " </div> " ;
2005-01-07 16:26:30 +01:00
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>