diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 0f12ab0cfc8..00e988688ea 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -546,17 +546,12 @@ class BonPrelevement extends CommonObject // TODO Call trigger to create a notification using notification module } else - { + { dol_syslog(get_class($this)."::set_infotrans Erreur 1", LOG_ERR); dol_syslog($this->db->error()); $error++; } - /* - * End of procedure - * - */ - if ($error == 0) { $this->db->commit(); @@ -1047,6 +1042,44 @@ class BonPrelevement extends CommonObject } + /** + * Get object and lines from database + * + * @return int >0 if OK, <0 if KO + */ + function delete() + { + $this->db->begin(); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = '".$this->id."')"; + $resql1=$this->db->query($sql); + if (! $resql1) dol_print_error($this->db); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = '".$this->id."'"; + $resql2=$this->db->query($sql); + if (! $resql2) dol_print_error($this->db); + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = '".$this->id."'"; + $resql3=$this->db->query($sql); + if (! $resql3) dol_print_error($this->db); + + $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = '".$this->id."'"; + $resql4=$this->db->query($sql); + if (! $resql4) dol_print_error($this->db); + + if ($resql1 && $resql2 && $resql3) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } + + /** * Returns clickable name (with picto) * diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 2ca9479f441..3b688c13331 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -103,8 +103,6 @@ $rej = new RejetPrelevement($db, $user); /* * Liste des factures - * - * */ $sql = "SELECT pl.rowid, pl.amount, pl.statut"; $sql.= " , s.rowid as socid, s.nom"; @@ -141,10 +139,10 @@ if ($resql) { $obj = $db->fetch_object($resql); - print ""; - print ' '; - print ''; + print ""; + print ''; + print img_picto('', 'statut'.$obj->statut).' '; print substr('000000'.$obj->rowid, -6); print ''; print ''.stripslashes($obj->nom)."\n"; @@ -164,7 +162,7 @@ if ($resql) print ' '; print ''.$langs->trans("Total").''; print ''.price($total)."\n"; - print ' '; + print ' '; print "\n\n"; $db->free($resql); } diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php index cd99849de9c..af2b1bbf495 100644 --- a/htdocs/compta/prelevement/fiche.php +++ b/htdocs/compta/prelevement/fiche.php @@ -42,14 +42,28 @@ if ($user->societe_id > 0) accessforbidden(); $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); + /* * Actions */ +if ( $action == 'confirm_delete' ) +{ + $bon = new BonPrelevement($db,""); + $bon->fetch($id); + + $res=$bon->delete(); + if ($res > 0) + { + header("Location: index.php"); + exit; + } +} if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes') { $bon = new BonPrelevement($db,""); - $bon->id = $id; + $bon->fetch($id); + $bon->set_credite(); header("Location: fiche.php?id=".$id); @@ -63,14 +77,15 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) $bon = new BonPrelevement($db,""); $bon->fetch($id); + $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); + + /* if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref) { $dir = $conf->prelevement->dir_output.'/receipts'; if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0) { - $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int')); - $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); } @@ -81,7 +96,15 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send) { dol_syslog("Fichier invalide",LOG_WARNING); $mesg='BadFile'; - } + }*/ + + $error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha')); + + if ($error) + { + header("Location: fiche.php?id=".$id."&error=$error"); + exit; + } } if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) @@ -92,15 +115,11 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) $error = $bon->set_infocredit($user, $dt); - if ($error == 0) - { - header("Location: fiche.php?id=".$id); - } - else + if ($error) { header("Location: fiche.php?id=".$id."&error=$error"); + exit; } - exit; } @@ -108,132 +127,139 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit) * View */ -llxHeader('',$langs->trans("WithdrawalReceipt")); - +$bon = new BonPrelevement($db,""); $form = new Form($db); -if ($id) +llxHeader('',$langs->trans("WithdrawalReceipt")); + + +if ($id > 0) { - $bon = new BonPrelevement($db,""); + $bon->fetch($id); - if ($bon->fetch($id) == 0) + $head = prelevement_prepare_head($bon); + dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalReceipt"), '', 'payment'); + + if (GETPOST('error','alpha')!='') { - $head = prelevement_prepare_head($bon); - dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalReceipt"), '', 'payment'); + print '
'.$bon->ReadError(GETPOST('error','alpha')).'
'; + } - if (GETPOST('error','alpha')!='') - { - print '
'.$bon->ReadError(GETPOST('error','alpha')).'
'; - } + /*if ($action == 'credite') + { + $ret=$form->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); + if ($ret == 'html') print '
'; + }*/ - if ($action == 'credite') - { - $ret=$form->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1); - if ($ret == 'html') print '
'; - } + print ''; - print '
'; + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; - $relativepath = 'receipts/'.$bon->ref; - - print ''.$relativepath.''; + if($bon->date_trans <> 0) + { + $muser = new User($db); + $muser->fetch($bon->user_trans); + print ''; + print ''; - - // Status - print ''; - print ''; - print ''; - - if($bon->date_trans <> 0) - { - $muser = new User($db); - $muser->fetch($bon->user_trans); - - print ''; - print ''; - } - if($bon->date_credit <> 0) - { - print ''; - } - - print '
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("Ref").''.$bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec,'day').'
'.$langs->trans("Amount").''.price($bon->amount).'
'.$langs->trans("File").''; + // Status + print '
'.$langs->trans('Status').''.$bon->getLibStatut(1).'
'.$langs->trans("TransData").''; + print dol_print_date($bon->date_trans,'day'); + print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; + print $bon->methodes_trans[$bon->method_trans]; print '
'.$langs->trans('Status').''.$bon->getLibStatut(1).'
'.$langs->trans("TransData").''; - print dol_print_date($bon->date_trans,'day'); - print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; - print $bon->methodes_trans[$bon->method_trans]; - print '
'.$langs->trans('CreditDate').''; - print dol_print_date($bon->date_credit,'day'); - print '
'; - dol_fiche_end(); - - if($bon->date_trans == 0 && $user->rights->prelevement->bons->send) - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("NotifyTransmision").'
'.$langs->trans("TransData").''; - print $form->select_date('','','','','',"userfile"); - print '
'.$langs->trans("TransMetod").''; - print $form->selectarray("methode",$bon->methodes_trans); - print '
'.$langs->trans("File").''; - print ''; - print '
'; - print '

'; - print '
'; - print ''; - } - - if($bon->date_trans <> 0 && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit) - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("NotifyCredit").'
'.$langs->trans('CreditDate').''; - print $form->select_date('','','','','',"infocredit"); - print '

'; - print '
'; - print ''; - } } - else + if($bon->date_credit <> 0) { - dol_print_error($db); + print ''.$langs->trans('CreditDate').''; + print dol_print_date($bon->date_credit,'day'); + print ''; + } + + print ''; + + print '
'; + + print '
'; + print $langs->trans("WithdrawalFile").''; + $relativepath = 'receipts/'.$bon->ref; + print ''.$relativepath.''; + print '
'; + + dol_fiche_end(); + + + + + if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +/* print '';*/ + print '
'.$langs->trans("NotifyTransmision").'
'.$langs->trans("TransData").''; + print $form->select_date('','','','','',"userfile",1,1); + print '
'.$langs->trans("TransMetod").''; + print $form->selectarray("methode",$bon->methodes_trans); + print '
'.$langs->trans("File").''; + print ''; + print '
'; + print '

'; + print '
'; + print ''; + } + + if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited') + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("NotifyCredit").'
'.$langs->trans('CreditDate').''; + print $form->select_date('','','','','',"infocredit",1,1); + print '
'; + print '
'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice"); + print '
'; + print ''; + } + + + // Actions + if ($action != 'settransmitted' && $action != 'setcredited') + { + print "\n
\n"; + + if (empty($bon->date_trans) && $user->rights->prelevement->bons->send) + { + print "id."\">".$langs->trans("SetToStatusSent").""; + } + + if (! empty($bon->date_trans) && $bon->date_credit == 0) + { + print "id."\">".$langs->trans("ClassCredited").""; + } + + print "id."\">".$langs->trans("Delete").""; + + print "
"; } } -/* ************************************************************************** */ -/* */ -/* Barre d'action */ -/* */ -/* ************************************************************************** */ - -/* -print "\n\n
\n"; - -if ($bon->statut == 0) -{ - print "id\">".$langs->trans("ClassCredited").""; -} -*/ -print "
"; - -$db->close(); llxFooter(); + +$db->close(); ?> diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 8dba0b37cae..53100598544 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -117,14 +117,12 @@ if ($result) $obj = $db->fetch_object($result); $var=!$var; - print ""; - - print ' '; - - print ''.$obj->ref."\n"; + print ""; + print ''; + print img_picto('', 'statut'.$obj->statut).' '; + print $obj->ref."\n"; print ''.dol_print_date($db->jdate($obj->datec),"dayhour")."\n"; - print ''.price($obj->amount)."\n"; print "\n"; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 5488f674620..fe9fa0a9b99 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -81,6 +81,9 @@ WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your cou ShowWithdraw=Show Withdraw IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one withdrawal payment not yet processed, it won't be set as payed to allow to manage withdrawal before. DoStandingOrdersBeforePayments=This tabs allows you to request for a standing order. Once it will be finished, you can type the payment to close the invoice. +WithdrawalFile=Withdrawal file +SetToStatusSent=Set to status "File Sent" +ThisWillAlsoAddPaymentOnInvoice=This will also create payments onto invoices and will classify them to paid ### Notifications InfoCreditSubject=Payment of standing order %s by the bank diff --git a/htdocs/langs/fr_FR/withdrawals.lang b/htdocs/langs/fr_FR/withdrawals.lang index 39f62c0f5c1..27c00e307cf 100644 --- a/htdocs/langs/fr_FR/withdrawals.lang +++ b/htdocs/langs/fr_FR/withdrawals.lang @@ -81,6 +81,9 @@ WithdrawalFileNotCapable=Impossible de générer un fichier de bons de prélève ShowWithdraw=Voir prélèvement IfInvoiceNeedOnWithdrawPaymentWontBeClosed=Toutefois, si la facture a au moins un paiement par prélèvement non traité, elle ne le sera pas afin de permettre la gestion du prélèvement d'abord. DoStandingOrdersBeforePayments=Cet onglet permet de faire une demande de prélèvement bancaire. Une fois réalisé, vous pourrez saisir le paiement sur la facture pour la clore. +WithdrawalFile=Fichier de prélèvement +SetToStatusSent=Mettre status "Fichier envoyé" +ThisWillAlsoAddPaymentOnInvoice=Ceci créera également les paiements sur les factures et les classera payées ### Notifications InfoCreditSubject=Crédit prélèvement %s à la banque