From 5f957884d194fc92415b168831e389021fabf80b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Oct 2008 10:37:36 +0000 Subject: [PATCH] Make a useless state of payment validation optionnal --- htdocs/compta/paiement/fiche.php | 13 +- htdocs/fourn/facture/fiche.php | 4 +- htdocs/fourn/facture/paiement.php | 249 +++++++++++++++--------------- htdocs/fourn/paiement/fiche.php | 221 +++++++++++++------------- htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/fr_FR/bills.lang | 1 + 6 files changed, 252 insertions(+), 237 deletions(-) diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index b38a4a3d066..38c1115a6ef 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -145,7 +145,7 @@ if ($_GET['action'] == 'delete') if ($_GET['action'] == 'valide') { $facid = $_GET['facid']; - $html->form_confirm('fiche.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), 'Etes-vous sûr de vouloir valider ce règlement, auncune modification n\'est possible une fois le règlement validé ?', 'confirm_valide'); + $html->form_confirm('fiche.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); print '
'; } @@ -267,12 +267,14 @@ print ''; print '
'; -if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') +if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) { - if ($user->rights->facture->paiement) + if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') { - print ''.$langs->trans('Valid').''; - + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } } } if ($user->societe_id == 0 && $allow_delete && $_GET['action'] == '') @@ -282,6 +284,7 @@ if ($user->societe_id == 0 && $allow_delete && $_GET['action'] == '') print ''.$langs->trans('Delete').''; } } + print '
'; $db->close(); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0790a678da9..48de1c1b171 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -317,9 +317,11 @@ if ($_POST['action'] == 'classin') $facture->setProject($_POST['projetid']); } + /* -* Affichage page +* View */ + $addons=''; llxHeader('','', $addons); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 4851b3d7733..7afb3f9c3d7 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -100,7 +100,7 @@ if ($action == 'add_paiement') $mesg = '
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Amount')).'
'; $error++; } - */ + */ if (! $error) { @@ -182,7 +182,7 @@ if ($action == 'add_paiement') } /* - * Affichage + * View */ llxHeader(); @@ -199,6 +199,9 @@ if ($action == 'create' || $action == 'add_paiement') $facture = new FactureFournisseur($db); $facture->fetch($facid); + $datefacture=dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture); + $sql = 'SELECT s.nom, s.rowid as socid,'; $sql.= ' f.rowid as ref, f.facnumber, f.amount, f.total_ttc as total'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -213,134 +216,130 @@ if ($action == 'create' || $action == 'add_paiement') $num = $db->num_rows($resql); if ($num) { - $obj = $db->fetch_object($resql); - $total = $obj->total; + $obj = $db->fetch_object($resql); + $total = $obj->total; - print_fiche_titre($langs->trans('DoPayment')); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + print_fiche_titre($langs->trans('DoPayment')); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->banque->enabled) - { - print ''; - } - else - { - print ''; - } - /* - * Autres factures impayees - */ - $sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df'; - $sql .= ', sum(pf.amount) as am'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; - $sql .= ' WHERE f.fk_soc = '.$facture->socid; - $sql .= ' AND f.paye = 0'; - $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee - $sql .= ' GROUP BY f.facnumber'; - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num > 0) - { - $i = 0; - print '\n"; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } - /* - * - */ - print ''; - print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''.$obj->nom.'
'.$langs->trans('Date').''; - 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,'','','','',"addpaiement"); - print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; - $html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); - print ''; - print '
'.$langs->trans('Numero').'
'.$langs->trans('Account').''; - $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); - print '
 
'; - print $langs->trans('Invoices').'
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->banque->enabled) + { + print ''; + } + else + { + print ''; + } + /* + * Autres factures impayees + */ + $sql = 'SELECT f.rowid as facid,f.rowid as ref,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df'; + $sql .= ', sum(pf.amount) as am'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; + $sql .= ' WHERE f.fk_soc = '.$facture->socid; + $sql .= ' AND f.paye = 0'; + $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee + $sql .= ' GROUP BY f.facnumber'; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num > 0) + { + $i = 0; + print '\n"; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } + $var=True; + $total=0; + $totalrecu=0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ''; + print ''; + print ''; + if ($objp->df > 0 ) + { + print ''; + } + else + { + print ''; + } + print ''; + print ''; + print ''; + print '\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + print "
'.$langs->trans('Ref').''.$langs->trans('RefSupplier').''.$langs->trans('Date').''.$langs->trans('AmountTTC').''.$langs->trans('AlreadyPayed').''.$langs->trans('RemainderToPay').''.$langs->trans('Amount').'
'.$langs->trans('Payment').'
'.$langs->trans('Company').''.$obj->nom.'
'.$langs->trans('Date').''; + $html->select_date($dateinvoice,'','','','',"addpaiement"); + print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; + $html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); + print ''; + print '
'.$langs->trans('Numero').'
'.$langs->trans('Account').''; + $html->select_comptes(empty($_POST['accountid'])?'':$_POST['accountid'],'accountid',0,'',1); + print '
 
'; + print $langs->trans('Invoices').'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $var=True; - $total=0; - $totalrecu=0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print ''; - if ($objp->df > 0 ) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''; - print ''; - print '\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; - $i++; - } - if ($i > 1) - { - // Print total - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - print "
'.$langs->trans('Ref').''.$langs->trans('RefSupplier').''.$langs->trans('Date').''.$langs->trans('AmountTTC').''.$langs->trans('AlreadyPayed').''.$langs->trans('RemainderToPay').''.$langs->trans('Amount').'
'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref; - print ''.$objp->facnumber.''; - print dolibarr_print_date($objp->df).'!!!'.price($objp->total_ttc).''.price($objp->am).''.price($objp->total_ttc - $objp->am).''; - $namef = 'amount_'.$objp->facid; - print ''; - print "
'.$langs->trans('TotalTTC').':'.price($total_ttc).''.price($totalrecu).''.price($total_ttc - $totalrecu).' 
'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->ref; + print ''.$objp->facnumber.''; + print dolibarr_print_date($objp->df).'!!!'.price($objp->total_ttc).''.price($objp->am).''.price($objp->total_ttc - $objp->am).''; + $namef = 'amount_'.$objp->facid; + print ''; + print "
'.$langs->trans('TotalTTC').':'.price($total_ttc).''.price($totalrecu).''.price($total_ttc - $totalrecu).' 
'; - print '
'; + /* + * + */ + print ''; + print ''; + print ''; } } } diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index bbdcd1cc0ef..411633c74a9 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -19,12 +19,12 @@ */ /** - \file htdocs/fourn/paiement/fiche.php - \ingroup facture, fournisseur - \brief Onglet paiement d'un paiement fournisseur - \remarks Fichier presque identique a compta/paiement/fiche.php - \version $Id$ -*/ + \file htdocs/fourn/paiement/fiche.php + \ingroup facture, fournisseur + \brief Onglet paiement d'un paiement fournisseur + \remarks Fichier presque identique a compta/paiement/fiche.php + \version $Id$ + */ require('./pre.inc.php'); @@ -43,7 +43,7 @@ $mesg=''; /* * Actions */ - + if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->fournisseur->facture->supprimer) { $db->begin(); @@ -53,14 +53,14 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user- $result = $paiement->delete(); if ($result > 0) { - $db->commit(); - Header('Location: '.DOL_URL_ROOT.'/fourn/facture/paiement.php'); - exit; + $db->commit(); + Header('Location: '.DOL_URL_ROOT.'/fourn/facture/paiement.php'); + exit; } else { $mesg='
'.$paiement->error.'
'; - $db->rollback(); + $db->rollback(); } } @@ -72,14 +72,14 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user- $paiement->id = $_GET['id']; if ($paiement->valide() >= 0) { - $db->commit(); + $db->commit(); Header('Location: fiche.php?id='.$paiement->id); - exit; + exit; } else { $mesg='
'.$paiement->error.'
'; - $db->rollback(); + $db->rollback(); } } @@ -114,7 +114,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'); + $html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete'); print '
'; } @@ -123,32 +123,32 @@ 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'); + $html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); print '
'; } 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 ($res === 0) { + $mesg = '
'.$langs->trans('PaymentNumberUpdateSucceeded').'
'; + } else { + $mesg = '
'.$langs->trans('PaymentNumberUpdateFailed').'
'; + } } 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').'
'; - } + $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').'
'; + } } @@ -158,84 +158,90 @@ print ''; print ''.$langs->trans('Ref').''.$paiement->id.''; if ($conf->banque->enabled) { - if ($paiement->bank_account) - { - // Si compte renseigné, on affiche libelle - $bank=new Account($db); - $bank->fetch($paiement->bank_account); + if ($paiement->bank_account) + { + // Si compte renseigné, on affiche libelle + $bank=new Account($db); + $bank->fetch($paiement->bank_account); - $bankline=new AccountLine($db); - $bankline->fetch($paiement->bank_line); + $bankline=new AccountLine($db); + $bankline->fetch($paiement->bank_line); - print ''; - print ''.$langs->trans('BankAccount').''; - print ''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.''; - print ''.$langs->trans('BankLineConciliated').''.yn($bankline->rappro).''; - print ''; - } + print ''; + print ''.$langs->trans('BankAccount').''; + print ''.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.''; + print ''.$langs->trans('BankLineConciliated').''.yn($bankline->rappro).''; + print ''; + } } - //switch through edition options for date (only available when statut is -not 1- (=validated)) - if (empty($_GET['action']) || $_GET['action']!='edit_date') - { - print ''; - print ''; - if ($paiement->statut == 0 && $_GET['action'] != 'edit_date') print ''; - print '
'; - print $langs->trans('Date'); - print ''.img_edit($langs->trans('Modify')).'
'; - print ''; - print ''.dolibarr_print_date($paiement->date,'day').''; - } - else - { - print ''; - print ''.$langs->trans('Date').''; - print ''; - print '
'; - if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) - $sel_date=dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - else - $sel_date=$paiement->date; - $html->select_date($sel_date,'','','','',"addpaiement"); - print ''; - print '
'; - print ''; - print ''; - } +//switch through edition options for date (only available when statut is -not 1- (=validated)) +if (empty($_GET['action']) || $_GET['action']!='edit_date') +{ + print ''; + print ''; + if ($paiement->statut == 0 && $_GET['action'] != 'edit_date') print ''; + print '
'; + print $langs->trans('Date'); + print ''.img_edit($langs->trans('Modify')).'
'; + print ''; + print ''.dolibarr_print_date($paiement->date,'day').''; +} +else +{ + print ''; + print ''.$langs->trans('Date').''; + print ''; + print '
'; + if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear'])) + $sel_date=dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + else + $sel_date=$paiement->date; + $html->select_date($sel_date,'','','','',"addpaiement"); + print ''; + print '
'; + print ''; + print ''; +} - print ''.$langs->trans('Type').''.$paiement->type_libelle.''; +print ''.$langs->trans('Type').''.$paiement->type_libelle.''; - //switch through edition options for number (only available when statut is -not 1- (=validated)) - if (empty($_GET['action']) || $_GET['action'] != 'edit_num') - { - print ''; - print ''; - if ($paiement->statut == 0 && $_GET['action'] != 'edit_num') print ''; - print '
'; - print $langs->trans('Numero'); - print ''.img_edit($langs->trans('Modify')).'
'; - print ''; - print ''.$paiement->numero.''; - } - else - { - print ''; - print ''.$langs->trans('Numero').''; - print ''; - print '
'; - if (!empty($_POST['new_num'])) - $num = $this->db->escape($_POST['new_num']); - else - $num = $paiement->numero; - print ''; - print ''; - print '
'; - print ''; - } +//switch through edition options for number (only available when statut is -not 1- (=validated)) +if (empty($_GET['action']) || $_GET['action'] != 'edit_num') +{ + print ''; + print ''; + if ($paiement->statut == 0 && $_GET['action'] != 'edit_num') print ''; + print '
'; + print $langs->trans('Numero'); + print ''.img_edit($langs->trans('Modify')).'
'; + print ''; + print ''.$paiement->numero.''; +} +else +{ + print ''; + print ''.$langs->trans('Numero').''; + print ''; + print '
'; + if (!empty($_POST['new_num'])) + $num = $this->db->escape($_POST['new_num']); + else + $num = $paiement->numero; + print ''; + print ''; + print '
'; + print ''; +} print ''.$langs->trans('Amount').''.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).''; -print ''.$langs->trans('Status').''.$paiement->getLibStatut(4).''; + +if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) +{ + print ''.$langs->trans('Status').''.$paiement->getLibStatut(4).''; +} + print ''.$langs->trans('Note').''.nl2br($paiement->note).''; + print ''; if ($mesg) print '
'.$mesg; @@ -271,8 +277,8 @@ if ($resql) { $var=True; - $facturestatic=new FactureFournisseur($db); - + $facturestatic=new FactureFournisseur($db); + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -312,12 +318,15 @@ print ''; */ print '
'; -if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') +if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) { - if ($user->rights->fournisseur->facture->valider) + if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') { - print ''.$langs->trans('Valid').''; + if ($user->rights->fournisseur->facture->valider) + { + print ''.$langs->trans('Valid').''; + } } } if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '') diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index fd6a994726e..5e67f5f422b 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -148,6 +148,7 @@ ConfirmClassifyPayedPartiallyReasonOtherDesc=Use this choice if all other does n ConfirmClassifyAbandonReasonOther=Other ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other cases. For example because you plan to create a replacing invoice. ConfirmCustomerPayment=Do you confirm this paiement input for %s %s ? +ConfirmValidatePayment=Etes-vous sur de vouloir valider ce paiment, auncune modification n'est possible une fois le paiement validé ? ValidateBill=Validate invoice NumberOfBills=Nb of invoices NumberOfBillsByMonthHT=Nb of invoices by month (net of tax) diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index b4686cfaba9..93bc7e84786 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -148,6 +148,7 @@ ConfirmClassifyPayedPartiallyReasonOtherDesc=Ce choix sera celui dans tout autre ConfirmClassifyAbandonReasonOther=Autre ConfirmClassifyAbandonReasonOtherDesc=Ce choix sera celui dans tout autre cas. Par exemple suite à intention de créer une facture de remplacement. ConfirmCustomerPayment=Confirmez-vous la saisie de ce réglement de %s %s ? +ConfirmValidatePayment=Etes-vous sur de vouloir valider ce paiment, auncune modification n'est possible une fois le paiement validé ? ValidateBill=Valider facture NumberOfBills=Nb de factures NumberOfBillsByMonth=Nb de factures par mois