From 5ea6cf58aefa55ae5db64988b15d75bca2f41b6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Nov 2007 23:18:09 +0000 Subject: [PATCH] Debut correction pour gestion cas utilisation no UCIN06 --- .settings/org.eclipse.core.resources.prefs | 3 + htdocs/compta/facture.php | 159 +++++++++++---------- htdocs/facture.class.php | 31 ++-- 3 files changed, 107 insertions(+), 86 deletions(-) create mode 100644 .settings/org.eclipse.core.resources.prefs diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..1de1d5f9920 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Sun Nov 25 21:04:17 GMT 2007 +eclipse.preferences.version=1 +encoding/=ISO-8859-1 diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 024e0fc55d4..677a704425f 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Éric Seigne + * Copyright (C) 2004 �ric Seigne * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2007 Regis Houssin @@ -26,7 +26,7 @@ /** \file htdocs/compta/facture.php \ingroup facture - \brief Page de création d'une facture + \brief Page de cr�ation d'une facture \version $Revision$ */ @@ -57,21 +57,21 @@ $sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); $mesg=isset($_GET['mesg'])?urldecode($_GET['mesg']):''; $socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; -// Sécurité accés client +// S�curit� acc�s client if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } -// Récupération de l'id de projet +// R�cup�ration de l'id de projet $projetid = 0; if ($_GET["projetid"]) { $projetid = $_GET["projetid"]; } -// Nombre de ligne pour choix de produit/service prédéfinis +// Nombre de ligne pour choix de produit/service pr�d�finis $NBLINES=4; @@ -137,7 +137,7 @@ if ($_GET['action'] == 'valid') // On verifie signe facture if ($facture->type == 2) { - // Si avoir, le signe doit etre négatif + // Si avoir, le signe doit etre n�gatif if ($facture->total_ht >= 0) { $mesg='
'.$langs->trans("ErrorInvoiceAvoirMustBeNegative").'
'; @@ -222,7 +222,7 @@ if ($_POST['action'] == 'set_ref_client') $facture->set_ref_client($_POST['ref_client']); } -// Classe à "validée" +// Classe � "valid�e" if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->facture->valider) { $fac = new Facture($db); @@ -251,7 +251,7 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo $fac = new Facture($db); $fac->fetch($_GET['facid']); - // On vérifie si la facture a des paiements + // On v�rifie si la facture a des paiements $sql = 'SELECT pf.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; $sql.= ' WHERE pf.fk_facture = '.$fac->id; @@ -273,24 +273,24 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo $resteapayer = $fac->total_ttc - $totalpaye; - // On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées + // On v�rifie si les lignes de factures ont �t� export�es en compta et/ou ventil�es $ventilExportCompta = $fac->getVentilExportCompta(); - // On vérifie si aucun paiement n'a été effectué + // On v�rifie si aucun paiement n'a �t� effectu� if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0) { $fac->set_draft($user); } } -// Classe à "payée" +// Classe � "pay�e" if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement) { $fac = new Facture($db); $fac->fetch($_GET['facid']); $result = $fac->set_payed($user); } -// Classe à "payée partiellement" +// Classe � "pay�e partiellement" if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement) { $fac = new Facture($db); @@ -306,7 +306,7 @@ if ($_POST['action'] == 'confirm_payed_partially' && $_POST['confirm'] == 'yes' $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Reason")).'
'; } } -// Classe à "abandonnée" +// Classe � "abandonn�e" if ($_POST['action'] == 'confirm_canceled' && $_POST['confirm'] == 'yes') { $fac = new Facture($db); @@ -345,7 +345,7 @@ if ($_POST['action'] == 'confirm_converttoreduc' && $_POST['confirm'] == 'yes' & $i++; } - // Insère une remise par famille de taux tva + // Ins�re une remise par famille de taux tva $discount = new DiscountAbsolute($db); $discount->desc='(CREDIT_NOTE)'; $discount->tva_tx=abs($fac->total_ttc); @@ -425,7 +425,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_percent = $_POST['remise_percent']; - // Propriétés particulieres a facture de remplacement + // Propri�t�s particulieres a facture de remplacement $facture->fk_facture_source = $_POST['fac_replacement']; $facture->type = 1; @@ -461,7 +461,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_percent = $_POST['remise_percent']; - // Propriétés particulieres a facture avoir + // Propri�t�s particulieres a facture avoir $facture->fk_facture_source = $_POST['fac_avoir']; $facture->type = 2; @@ -476,7 +476,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) if ($_POST['type'] == 0 && $_POST['fac_rec'] > 0) { - // Si facture récurrente + // Si facture r�currente $datefacture = dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $facture->socid = $_POST['socid']; @@ -488,7 +488,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $facture->ref_client = $_POST['ref_client']; $facture->modelpdf = $_POST['model']; - // Propriétés particulieres a facture recurrente + // Propri�t�s particulieres a facture recurrente $facture->fac_rec = $_POST['fac_rec']; $facture->type = 0; @@ -588,7 +588,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) } /* - * Si création depuis commande + * Si cr�ation depuis commande */ if ($_POST['commandeid']) { @@ -640,7 +640,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) } /* - * Si création depuis contrat + * Si cr�ation depuis contrat */ if ($_POST['contratid']) { @@ -700,7 +700,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) } - // Fin création facture, on l'affiche + // Fin cr�ation facture, on l'affiche if ($facid > 0 && ! $error) { $db->commit(); @@ -748,7 +748,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday']; } } - // Si ajout champ produit prédéfini + // Si ajout champ produit pr�d�fini if ($_POST['action'] == 'addligne_predef') { if ($_POST['date_start_predefyear'] && $_POST['date_start_predefmonth'] && $_POST['date_start_predefday']) @@ -846,7 +846,7 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $mesg='
'.$fac->error.'
'; } - $_GET['facid']=$_POST['facid']; // Pour réaffichage de la fiche en cours d'édition + $_GET['facid']=$_POST['facid']; // Pour r�affichage de la fiche en cours d'�dition } if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save')) @@ -880,12 +880,12 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST } facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); - $_GET['facid']=$_POST['facid']; // Pour réaffichage de la fiche en cours d'édition + $_GET['facid']=$_POST['facid']; // Pour r�affichage de la fiche en cours d'�dition } if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { - Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_POST['facid']); // Pour réaffichage de la fiche en cours d'édition + Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_POST['facid']); // Pour r�affichage de la fiche en cours d'�dition exit; } @@ -941,13 +941,13 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c if ($_POST['sendto']) { - // Le destinataire a été fourni via le champ libre + // Le destinataire a �t� fourni via le champ libre $sendto = $_POST['sendto']; $sendtoid = 0; } elseif ($_POST['receiver']) { - // Le destinataire a été fourni via la liste déroulante + // Le destinataire a �t� fourni via la liste d�roulante if ($_POST['receiver'] < 0) // Id du tiers { $sendto = $fac->client->email; @@ -980,11 +980,11 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c } $actiontypecode='AC_FAC'; - $actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'.
'; + $actionmsg ='Mail envoy� par '.$from.' � '.$sendto.'.
'; if ($message) { - $actionmsg.='Texte utilisé dans le corps du message:
'; + $actionmsg.='Texte utilis� dans le corps du message:
'; $actionmsg.=$message; } @@ -994,9 +994,9 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c { $subject = 'Relance facture '.$fac->ref; $actiontypecode='AC_FAC'; - $actionmsg='Mail envoyé par '.$from.' à '.$sendto.'.
'; + $actionmsg='Mail envoy� par '.$from.' � '.$sendto.'.
'; if ($message) { - $actionmsg.='Texte utilisé dans le corps du message:
'; + $actionmsg.='Texte utilis� dans le corps du message:
'; $actionmsg.=$message; } $actionmsg2='Relance facture par mail'; @@ -1086,12 +1086,12 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['c { $langs->load("other"); $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
'; - dolibarr_syslog('Impossible de lire les données de la facture. Le fichier facture n\'a peut-être pas été généré.'); + dolibarr_syslog('Impossible de lire les donn�es de la facture. Le fichier facture n\'a peut-�tre pas �t� g�n�r�.'); } } /* - * Générer ou regénérer le document PDF + * G�n�rer ou reg�n�rer le document PDF */ if ($_REQUEST['action'] == 'builddoc') // En get ou en post { @@ -1209,9 +1209,9 @@ if ($_GET['action'] == 'create') /* \todo L'info "Reference commande client" est une carac de la commande et non de la facture. - Elle devrait donc etre stockée sur l'objet commande liée à la facture et non sur la facture. + Elle devrait donc etre stock�e sur l'objet commande li�e � la facture et non sur la facture. Pour ceux qui veulent l'utiliser au niveau de la facture, positionner la - constante FAC_USE_CUSTOMER_ORDER_REF à 1. + constante FAC_USE_CUSTOMER_ORDER_REF � 1. */ if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) { @@ -1243,7 +1243,12 @@ if ($_GET['action'] == 'create') $optionsav=""; foreach ($facids as $key => $value) { - $optionsav.=''; + $newinvoice=new Facture($db); + $newinvoice->fetch($key); + $optionsav.=''; } print ''.$langs->trans('Type').''; @@ -1322,12 +1327,12 @@ if ($_GET['action'] == 'create') $html->select_date('','','','','',"add"); print ''; - // Conditions de réglement + // Conditions de r�glement print ''.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements($cond_reglement_id,'cond_reglement_id'); print ''; - // Mode de réglement + // Mode de r�glement print ''.$langs->trans('PaymentMode').''; $html->select_types_paiements($mode_reglement_id,'mode_reglement_id'); print ''; @@ -1369,7 +1374,7 @@ if ($_GET['action'] == 'create') } print ''; - // Note privée + // Note priv�e if (! $user->societe_id) { print ''; @@ -1444,7 +1449,7 @@ if ($_GET['action'] == 'create') { print ''; - // Zone de choix des produits prédéfinis à la création + // Zone de choix des produits pr�d�finis � la cr�ation print ''; print ''; print ''; @@ -1468,7 +1473,7 @@ if ($_GET['action'] == 'create') print ''; print ''; print ''; - // Si le module service est actif, on propose des dates de début et fin à la ligne + // Si le module service est actif, on propose des dates de d�but et fin � la ligne if ($conf->service->enabled) { print ''; } - // Tiers Société + // Tiers Soci�t� print ''; print ''; print ''; @@ -2014,11 +2019,11 @@ else // Already payed print ''; - // Facturé + // Factur� print ''; $resteapayeraffiche=$resteapayer; - // Payé partiellement 'escompte' + // Pay� partiellement 'escompte' if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'escompte') { print ''; $resteapayeraffiche=0; } - // Payé partiellement ou Abandon 'badcustomer' + // Pay� partiellement ou Abandon 'badcustomer' if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'badcustomer') { print ''; //$resteapayeraffiche=0; } - // Payé partiellement ou Abandon 'product_returned' + // Pay� partiellement ou Abandon 'product_returned' if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'product_returned') { print ''; $resteapayeraffiche=0; } - // Payé partiellement ou Abandon 'abandon' + // Pay� partiellement ou Abandon 'abandon' if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'abandon') { print ''; - // Conditions de réglement + // Conditions de r�glement print '
'.$langs->trans('ProductsAndServices').''.$langs->trans('Qty').'% '; @@ -1494,7 +1499,7 @@ if ($_GET['action'] == 'create') } /* - * Factures récurrentes + * Factures r�currentes */ if (! $conf->global->FACTURE_DISABLE_RECUR) { @@ -1725,7 +1730,7 @@ else */ if ($_GET['action'] == 'valid') { - // on vérifie si la facture est en numérotation provisoire + // on v�rifie si la facture est en num�rotation provisoire $facref = substr($fac->ref, 1, 4); if ($facref == 'PROV') { @@ -1750,7 +1755,7 @@ else } /* - * Confirmation du classement payé + * Confirmation du classement pay� */ if ($_GET['action'] == 'payed' && $resteapayer <= 0) { @@ -1783,7 +1788,7 @@ else $arrayreasons[$close[$key]['code']]=$close[$key]['reason']; } - // Crée un tableau formulaire + // Cr�e un tableau formulaire $formquestion=array( 'text' => $langs->trans("ConfirmClassifyPayedPartiallyQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), @@ -1799,7 +1804,7 @@ else */ if ($_GET['action'] == 'canceled') { - // S'il y a une facture de remplacement pas encore validée (etat brouillon), + // S'il y a une facture de remplacement pas encore valid�e (etat brouillon), // on ne permet pas de classer abandonner la facture. if ($facidnext) { @@ -1826,7 +1831,7 @@ else $arrayreasons[$close[1]['code']]=$close[1]['reason']; $arrayreasons[$close[2]['code']]=$close[2]['reason']; - // Crée un tableau formulaire + // Cr�e un tableau formulaire $formquestion=array( 'text' => $langs->trans("ConfirmCancelBillQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), @@ -1871,8 +1876,8 @@ else /* \todo L'info "Reference commande client" est une carac de la commande et non de la facture. - Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture. - Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1. + Elle devrait donc etre stock�e sur l'objet commande li� � la facture et non sur la facture. + Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF � 1. */ if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) { @@ -1899,7 +1904,7 @@ else print '
'.$langs->trans('Company').''.$soc->getNomUrl(1,'compta').'
'.$langs->trans('AlreadyPayed').' :'.price($totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans("Billed").' :'.price($fac->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'; @@ -2026,7 +2031,7 @@ else print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'; @@ -2034,7 +2039,7 @@ else print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'; @@ -2042,7 +2047,7 @@ else print ''.price($fac->total_ttc - $totalpaye).''.$langs->trans('Currency'.$conf->monnaie).'
'; @@ -2086,7 +2091,7 @@ else } print '
'; print ''; - // Lit lignes de facture pour déterminer montant + // Lit lignes de facture pour d�terminer montant // On s'en sert pas mais ca sert pour debuggage $sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,'; $sql .= ' l.remise_percent, l.subprice'; @@ -2328,7 +2333,7 @@ else print ''; print "\n"; - // Ajout produit produits/services personalisés + // Ajout produit produits/services personalis�s print ''; print ''; print ''; @@ -2476,7 +2481,7 @@ else $var=true; print ''; print ''; @@ -2551,7 +2556,7 @@ else if (! $conf->global->PRODUIT_CHANGE_PROD_DESC) { - // éditeur wysiwyg + // �diteur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -2595,10 +2600,10 @@ else { print '
'; - // Editer une facture déjà validée, sans paiement effectué et pas exporté en compta + // Editer une facture d�j� valid�e, sans paiement effectu� et pas export� en compta if ($fac->statut == 1) { - // On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées + // On v�rifie si les lignes de factures ont �t� export�es en compta et/ou ventil�es $ventilExportCompta = $fac->getVentilExportCompta(); if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier @@ -2608,7 +2613,7 @@ else } } - // Récurrente + // R�currente if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0) { if (! $facidnext) @@ -2627,7 +2632,7 @@ else } else { - // Générer + // G�n�rer if ($fac->statut >= 1 && $user->rights->facture->creer) { if ($fac->paye == 0) @@ -2694,14 +2699,14 @@ else } } - // Classer 'payé' + // Classer 'pay�' if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement && (($fac->type != 2 && $resteapayer <= 0) || ($fac->type == 2 && $resteapayer >= 0)) ) { print ''.$langs->trans('ClassifyPayed').''; } - // Classer 'fermée' (possible si validée et pas encore classée payée) + // Classer 'ferm�e' (possible si valid�e et pas encore class�e pay�e) if ($fac->statut == 1 && $fac->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement) { @@ -2742,7 +2747,7 @@ else print ''; // ancre /* - * Documents générés + * Documents g�n�r�s */ $filename=sanitize_string($fac->ref); $filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref); @@ -2756,7 +2761,7 @@ else $somethingshown=$html->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); /* - * Propales rattachées + * Propales rattach�es */ $sql = 'SELECT '.$db->pdate('p.datep').' as dp, p.total_ht, p.ref, p.ref_client, p.rowid as propalid'; $sql .= ' FROM '.MAIN_DB_PREFIX.'propal as p'; @@ -2810,7 +2815,7 @@ else } /* - * Commandes rattachées + * Commandes rattach�es */ if($conf->commande->enabled) { @@ -2866,7 +2871,7 @@ else print '
'; print $langs->trans('PaymentConditionsShort'); @@ -2129,7 +2134,7 @@ else } print '
'; if (($objp->info_bits & 2) == 2) { - // Ligne remise prédéfinie, on permet pas modif + // Ligne remise pr�d�finie, on permet pas modif } else { @@ -2392,7 +2397,7 @@ else print ' - '.nl2br($objp->product); print '
'; } - // éditeur wysiwyg + // �diteur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -2468,7 +2473,7 @@ else print '
 
'; - // éditeur wysiwyg + // �diteur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -2511,7 +2516,7 @@ else } print ''; - // Ajout de produits/services prédéfinis + // Ajout de produits/services pr�d�finis if ($conf->produit->enabled) { print '
'; /* - * Liste des actions propres à la facture + * Liste des actions propres � la facture */ $sql = 'SELECT a.id, '.$db->pdate('a.datea').' as da, a.label, a.note,'; $sql.= ' u.login'; @@ -2947,7 +2952,7 @@ else $liste[$key]=$value; } - // Créé l'objet formulaire mail + // Cr�� l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->fromname = $user->fullname; @@ -2962,7 +2967,7 @@ else $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__FACREF__']=$fac->ref; - // Tableau des paramètres complémentaires du post + // Tableau des param�tres compl�mentaires du post $formmail->param['action']='send'; $formmail->param['models']='facture_send'; $formmail->param['facid']=$fac->id; @@ -3003,7 +3008,7 @@ else $liste[$key]=$value; } - // Créé l'objet formulaire mail + // Cr�� l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->fromname = $user->fullname; @@ -3017,7 +3022,7 @@ else $formmail->withdeliveryreceipt=1; // Tableau des substitutions $formmail->substit['__FACREF__']=$fac->ref; - // Tableau des paramètres complémentaires + // Tableau des param�tres compl�mentaires $formmail->param['action']='relance'; $formmail->param['models']='facture_relance'; $formmail->param['facid']=$fac->id; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 7baed40f0e5..b9e75f19045 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -2345,25 +2345,26 @@ class Facture extends CommonObject /** * \brief Renvoi liste des factures qualifiables pour correction par avoir - * Statut >= validée + classée payée completement ou classée payée partiellement + pas deja remplacée + pas deja avoir + * Les factures qui respectent les regles suivantes sont retournees: + * (validée + paiement en cours) ou classée (payée completement ou payée partiellement) + pas deja remplacée + pas deja avoir * \param socid Id societe * \return array Tableau des factures ($id => $ref) */ function list_qualified_avoir_invoices($socid=0) { - global $conf; - $return = array(); - $sql = "SELECT f.rowid as rowid, f.facnumber"; + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, pf.fk_paiement"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=1)"; - $sql.= " WHERE f.fk_statut >= 1"; - $sql.= " AND (f.paye = 1"; // Classée payée complètement - $sql.= " OR f.close_code IS NOT NULL)"; // Classée payée partiellement + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; +// $sql.= " WHERE f.fk_statut >= 1"; +// $sql.= " AND (f.paye = 1"; // Classée payée complètement +// $sql.= " OR f.close_code IS NOT NULL)"; // Classée payée partiellement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement - $sql.= " AND f.type != 2"; // Facture non avoir + $sql.= " AND f.type != 2"; // Type non 2 si facture non avoir if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid; $sql.= " ORDER BY f.facnumber"; @@ -2373,7 +2374,19 @@ class Facture extends CommonObject { while ($obj=$this->db->fetch_object($resql)) { - $return[$obj->rowid]=$obj->facnumber; + $qualified=0; + // if statut is 1, record is qualified only if some paiement + // has already been made. + // If not, we must not do credit note but a replacement invoice. + if ($obj->fk_statut == 1 && $obj->fk_paiement) $qualified=1; + if ($obj->fk_statut == 2) $qualified=1; + if ($qualified) + { + + //$ref=$obj->facnumber; + $ref=($obj->fk_paiement?1:0); + $return[$obj->rowid]=$ref; + } } return $return;