diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/.buildpath dolibarr-2.9.0-patchF1/.buildpath --- dolibarr-2.9.0/.buildpath 1970-01-01 01:00:00.000000000 +0100 +++ dolibarr-2.9.0-patchF1/.buildpath 2011-01-20 12:01:01.000000000 +0100 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/htdocs/compta/ajax_autocompletion_facnumber.php dolibarr-2.9.0-patchF1/htdocs/compta/ajax_autocompletion_facnumber.php --- dolibarr-2.9.0/htdocs/compta/ajax_autocompletion_facnumber.php 1970-01-01 01:00:00.000000000 +0100 +++ dolibarr-2.9.0-patchF1/htdocs/compta/ajax_autocompletion_facnumber.php 2011-01-20 10:12:03.000000000 +0100 @@ -0,0 +1,71 @@ + + * + * 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. + */ + +/** + * \file htdocs/compta/autocompletion_facnumber.php + * \ingroup facture + * \brief Autocompletion for facnumber while creating/modifying new facture + * \version $Id: autocompletion_facnumber.php,v 1.728.2.4 2011/01/14 18:07:42 eldy Exp $ + */ + +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); +require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); +if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); + +$langs->load('bills'); +$langs->load('companies'); +$langs->load('products'); +$langs->load('main'); + +$sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); +$mesg=isset($_GET['mesg'])?$_GET['mesg']:''; +$projectid=isset($_GET['projectid'])?$_GET['projectid']:0; + +// Security check +$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'facture', '','','','fk_soc',$fieldid); + +$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; + +/******************************************************************************/ +/* Appel de la methode autocompletion */ +/******************************************************************************/ +if (!empty($_REQUEST['term'])) { + $fact=new Facture($db); + $fact->socid = $socid; + $retour=$fact->fetch_autocomplete_facnumber($_REQUEST['term']); + if ($retour>0 ) { + echo $fact->json_facnumber_list; + } else { + //echo $fact->error; + } + $db->close(); +} else { + echo "Parametre reference manquant"; +} + +?> diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/htdocs/compta/facture/class/facture.class.php dolibarr-2.9.0-patchF1/htdocs/compta/facture/class/facture.class.php --- dolibarr-2.9.0/htdocs/compta/facture/class/facture.class.php 2010-08-13 00:43:17.000000000 +0200 +++ dolibarr-2.9.0-patchF1/htdocs/compta/facture/class/facture.class.php 2011-01-20 12:08:22.000000000 +0100 @@ -100,6 +100,8 @@ var $modelpdf; var $products=array(); var $lignes=array(); + var $facnumber_list=array(); + var $json_facnumber_list=array(); //! Pour board var $nbtodo; var $nbtodolate; @@ -220,7 +222,7 @@ $sql.= ", note_public"; $sql.= ", ref_client"; $sql.= ", fk_facture_source, fk_user_author, fk_projet"; - $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; + $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -663,6 +665,63 @@ } + + /** + * \brief Get object and lines from database for autocompletion on facnumber + * \param ref first caracters for the facnumber to autocomplete + * \return int >0 if OK, <0 if KO + */ + function fetch_autocomplete_facnumber($ref='') + { + global $conf; + + $sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut,"; + $sql.= " ff.rowid as rowidnext"; + $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"; + $sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))"; + $sql.= " AND f.entity = ".$conf->entity; + $sql.= " AND f.paye = 0"; // Pas classee payee completement + $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait + $sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement + if ($this->socid > 0) $sql.=" AND f.fk_soc = ".$this->socid; + if ($ref) $sql.= " AND f.facnumber LIKE '".strtoupper($ref)."%'"; + $sql.= " ORDER BY f.facnumber"; + + dol_syslog("Facture::fetch_autocomplete_facnumber sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + while ($obj = $this->db->fetch_object($result)) { + $rowFacture['id'] = $obj->rowid; + $rowFacture['value'] = $obj->facnumber; + array_push($this->facnumber_list,$rowFacture); + } + $this->json_facnumber_list = json_encode($this->facnumber_list); + return 1; + } + else + { + $this->error='Bill with ref '.$ref.' not found sql='.$sql; + dol_syslog('Facture::fetch_autocomplete_facnumber Error '.$this->error, LOG_ERR); + return -2; + } + } + else + { + $this->error=$this->db->error(); + dol_syslog('Facture::fetch_autocomplete_facnumber Error '.$this->error, LOG_ERR); + return -1; + } + } + + + + + /** * \brief Recupere les lignes de factures dans this->lignes * \return int 1 if OK, < 0 if KO @@ -736,7 +795,9 @@ } } + + /** * \brief Update database * \param user User that modify diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/htdocs/compta/facture.php dolibarr-2.9.0-patchF1/htdocs/compta/facture.php --- dolibarr-2.9.0/htdocs/compta/facture.php 2010-09-12 20:07:42.000000000 +0200 +++ dolibarr-2.9.0-patchF1/htdocs/compta/facture.php 2011-01-20 13:53:02.000000000 +0100 @@ -519,12 +519,15 @@ $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
'; } - if (! ($_POST['fac_replacement'] > 0)) + // Le test est different selon qu'on est en mode autocompletion ou non + if ( !$conf->global->USE_AUTOCOMPLETION_FACTURE && ! ($_POST['fac_replacement'] > 0 ) || + ( $conf->global->USE_AUTOCOMPLETION_FACTURE && ! ($_POST['fac_replacement'] > 0 ) && empty($_POST['autocomplete_fac_replacement']) )) { $error=1; $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("ReplaceInvoice")).'
'; } + if (! $error) { // This is a replacement invoice @@ -553,7 +556,8 @@ // Credit note invoice if ($_POST['type'] == 2) { - if (! $_POST['fac_avoir'] > 0) + if ( !$conf->global->USE_AUTOCOMPLETION_FACTURE && ! ($_POST['fac_avoir'] > 0 ) || + ( $conf->global->USE_AUTOCOMPLETION_FACTURE && ! ($_POST['fac_avoir'] > 0 ) && empty($_POST['autocomplete_fac_avoir']) )) { $error=1; $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->trans("CorrectInvoice")).'
'; @@ -627,7 +631,7 @@ $facture->note = trim($_POST['note']); $facture->ref_client = $_POST['ref_client']; $facture->modelpdf = $_POST['model']; - + // Source facture $facture->fac_rec = $_POST['fac_rec']; @@ -662,7 +666,7 @@ $facture->amount = $_POST['amount']; $facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_percent = $_POST['remise_percent']; - + // If creation from other modules if ($_POST['origin'] && $_POST['originid']) { @@ -1509,24 +1513,23 @@ $optionsav.=' ('.$newinvoice->getLibStatut(1,$value).')'; $optionsav.=''; } - + print ''.$langs->trans('Type').''; print ''."\n"; // Standard invoice print ''."\n"; // Deposit print ''."\n"; // Proforma @@ -1535,32 +1538,73 @@ print ''."\n"; } - + // Replacement - print ''."\n"; @@ -1570,22 +1614,66 @@ if (! $optionsav) print ' disabled="true"'; print '>'; print ''."\n"; @@ -1802,7 +1890,7 @@ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid'; $sql.= ' WHERE pt.fk_contrat = '.$object->id; $sql.= ' ORDER BY pt.rowid ASC'; - } + } if ($_GET['origin'] && $_GET['originid']) { print '
'; @@ -2214,6 +2302,7 @@ $facthatreplace->fetch($facidnext); print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')'; } + print ''; // Discounts diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/htdocs/conf/conf.php.old dolibarr-2.9.0-patchF1/htdocs/conf/conf.php.old --- dolibarr-2.9.0/htdocs/conf/conf.php.old 2011-01-18 11:28:38.000000000 +0100 +++ dolibarr-2.9.0-patchF1/htdocs/conf/conf.php.old 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ - diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/htdocs/langs/fr_FR/bills.lang dolibarr-2.9.0-patchF1/htdocs/langs/fr_FR/bills.lang --- dolibarr-2.9.0/htdocs/langs/fr_FR/bills.lang 2010-08-04 00:09:27.000000000 +0200 +++ dolibarr-2.9.0-patchF1/htdocs/langs/fr_FR/bills.lang 2011-01-20 13:42:28.000000000 +0100 @@ -24,6 +24,7 @@ InvoiceAvoir=Facture avoir InvoiceAvoirAsk=Facture avoir pour correction de la facture InvoiceAvoirDesc=La facture d'avoir est une facture négative destinée à compenser un montant de facture qui diffère du montant réellement versé (suite à un trop versé par le client par erreur ou un manque non versé par le client suite à un retour produit par exemple). +InvoiceAutocomplete=

L'autocomplétion est active. Vous pouvez saisir les premiers caractères d'une facture non payée et choisir dans la liste déroulante. ReplaceInvoice=Remplace la facture %s ReplacementInvoice=Remplacement facture ReplacedByInvoice=Remplacée par la facture %s diff -BNaur --exclude=CVS --exclude='*.patch' --exclude='.#*' --exclude=.project --exclude='*~' --exclude='*.rej' --exclude='*.orig' --exclude='*.bak' --exclude=conf.php --exclude=documents dolibarr-2.9.0/.settings/org.eclipse.php.core.prefs dolibarr-2.9.0-patchF1/.settings/org.eclipse.php.core.prefs --- dolibarr-2.9.0/.settings/org.eclipse.php.core.prefs 1970-01-01 01:00:00.000000000 +0100 +++ dolibarr-2.9.0-patchF1/.settings/org.eclipse.php.core.prefs 2011-01-20 12:01:01.000000000 +0100 @@ -0,0 +1,3 @@ +#Thu Jan 20 12:01:01 CET 2011 +eclipse.preferences.version=1 +include_path=0;/dolibarr-2.9.0-patchF1
'; print ''; - print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); - print $desc; + print ''; + print $html->textwithpicto($text,$langs->transnoentities("InvoiceStandardDesc"),1); print '
'; print ''; print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); - print $desc; + + print $html->textwithpicto($text,$langs->transnoentities("InvoiceDepositDesc"),1); print '
'; print ''; print ''; - $desc=$html->textwithpicto($langs->trans("InvoiceProForma"),$langs->transnoentities("InvoiceProFormaDesc"),1); + print $html->textwithpicto($text,$langs->transnoentities("InvoiceProFormaDesc"),1); print $desc; print '
'; + print '
'; print ''; print ''; - $text=$langs->trans("InvoiceReplacementAsk").' '; - $text.='trans("NoReplacableInvoice").''; + } + $text.=''; + } else { + + // Associer le champ autocompletion avec le source pour recupérer les données en ajax + // Le paramètre minLength: 4 permet de déclencher l'autocomplétion à partir de 4 caractères + print ' + + '; + + // Champ caché qui contiendra le rowId de la facture + $text.=''; + // Champ autocompletion sur le numero de facture + $text.=''; + } + + if (!$conf->global->USE_AUTOCOMPLETION_FACTURE) { + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + } else { + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc").$langs->transnoentities("InvoiceAutocomplete"),1); } - $text.=''; - $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1); + print $desc; print '
'; - $text=$langs->transnoentities("InvoiceAvoirAsk").' '; + $text=$langs->transnoentities("InvoiceAvoirAsk"); // $text.=''; - $text.='trans("NoInvoiceToCorrect").''; + } + $text.=''; + + } else { + + // Associer le champ autocompletion avec le source pour recupérer les données en ajax + // Le paramètre minLength: 4 permet de déclencher l'autocomplétion à partir de 4 caractères + print ' + + '; + + // Champ caché qui contiendra le rowId de la facture + $text.=''; + // Champ autocompletion sur le numero de facture de l'avoir + $text.=''; + } + + if (!$conf->global->USE_AUTOCOMPLETION_FACTURE) { + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + } else { + $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc").$langs->transnoentities("InvoiceAutocomplete"),1); } - $text.=''; - $desc=$html->textwithpicto($text,$langs->transnoentities("InvoiceAvoirDesc"),1); + + //.' ('.$langs->trans("FeatureNotYetAvailable").')',$langs->transnoentities("InvoiceAvoirDesc"),1); print $desc; print '