2
0
forked from Wavyzz/dolibarr

Add: dbut ajout autocompletion ajax sur la liste des socits

This commit is contained in:
Regis Houssin
2007-06-23 07:03:20 +00:00
parent 15de773bc0
commit 26190fc78d
7 changed files with 74 additions and 76 deletions

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2006-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007 Auguria SARL <info@auguria.org> * Copyright (C) 2007 Auguria SARL <info@auguria.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -54,50 +54,30 @@ if ($_POST["action"] == 'multiprix')
{ {
$res=$db->DDLDescTable(MAIN_DB_PREFIX."societe","price_level"); $res=$db->DDLDescTable(MAIN_DB_PREFIX."societe","price_level");
if(! $db->fetch_row($res)) if(! $db->fetch_row($res))
{
$field_desc = array('type'=>'TINYINT','value'=>'4','default'=>'1');
if ($_POST["activate_multiprix"])
{ {
$field_desc = array('type'=>'TINYINT','value'=>'4','default'=>'1'); // on ajoute le champ price_level dans la table societe
if ($_POST["activate_multiprix"]) if ($db->DDLAddField(MAIN_DB_PREFIX."societe","price_level",$field_desc) < 0)
{
// on ajoute le champ price_level dans la table societe
if ($db->DDLAddField(MAIN_DB_PREFIX."societe","price_level",$field_desc) < 0)
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
exit; exit;
} }
// on cr<63>e la table societe_prices }
else dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"]);
{ dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
/* Header("Location: produit.php");
* La table est desormais cree par un fichier SQL comme les autres tables exit;
* }
* $table = MAIN_DB_PREFIX."societe_prices";
* $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
* $fields['fk_soc'] = array('type'=>'int','value'=>'11','null'=>'not null','default'=> '0');
* $fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null');
* $fields['datec'] = array('type'=>'datetime','default'=> 'null');
* $fields['fk_user_author'] = array('type'=>'int','value'=>'11','default'=> 'null');
* $fields['price_level'] = array('type'=>'tinyint','value'=>'4','default'=> '1');
* if ($db->DDLCreateTable($table,$fields,"rowid","InnoDB") < 0)
* {
* dolibarr_print_error($db);
* exit;
* }
*/
}
}
dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"]);
dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
Header("Location: produit.php");
exit;
}
else else
{ {
dolibarr_syslog("Table definition for ".MAIN_DB_PREFIX."societe already ok"); dolibarr_syslog("Table definition for ".MAIN_DB_PREFIX."societe already ok");
dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"]); dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"]);
dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6"); dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6");
Header("Location: produit.php"); Header("Location: produit.php");
exit; exit;
} }
} }
else if ($_POST["action"] == 'sousproduits') else if ($_POST["action"] == 'sousproduits')
{ {

View File

@@ -65,6 +65,19 @@ if ($_GET["action"] == 'setcodecompta')
} }
} }
if ($_POST["action"] == 'usesearchtoselectcompany')
{
if (dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $_POST["activate_usesearchtoselectcompany"]))
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dolibarr_print_error($db);
}
}
/* /*
* Affichage page configuration module societe * Affichage page configuration module societe
@@ -201,40 +214,38 @@ print '<br>';
// Autres options // Autres options
/* $html=new Form($db);
print_titre($langs->trans("OtherOptions"));
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>'; print " <td>".$langs->trans("Parameters")."</td>\n";
print '<td>'.$langs->trans("Value").'</td>'; print " <td align=\"right\" width=\"60\">".$langs->trans("Value")."</td>\n";
print '<td>'.$langs->trans("Description").'</td>'; print " <td width=\"80\">&nbsp;</td></tr>\n";
print '<td>&nbsp;</td>';
print "</tr>\n";
print '<form action="'.$_SERVER["societe.php"].'" method="POST">';
print '<input type="hidden" name="action" value="setxxx">';
print '<input type="hidden" name="constname" value="XXX">';
// utilisation formulaire Ajax sur choix soci<63>t<EFBFBD>
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].' class="value">'; print "<form method=\"post\" action=\"societe.php\">";
print '<td nowrap="nowrap">'.$langs->trans("UseXXX")."</td>\n"; print "<input type=\"hidden\" name=\"action\" value=\"usesearchtoselectcompany\">";
print '<td>'; print "<tr ".$bc[$var].">";
print $form->selectyesno('constvalue',! $conf->global->XXX,1); print '<td width="80%">'.$langs->trans("UseSearchToSelectCompany").'</td>';
print '</td>'; if (! $conf->use_ajax)
print '<td>'.$langs->trans("XXXDesc").'</td>'; {
print '<td align="right">'; print '<td nowrap="nowrap" align="right" colspan="2">';
print '<input class="button" type="submit" value="'.$langs->trans('Modify').'" name="button"> &nbsp; '; print $langs->trans("NotAvailableWhenAjaxDisabled");
print '</td>'; print "</td>";
print "</tr>\n"; }
else
{
print '<td width="60" align="right">';
print $html->selectyesno("activate_usesearchtoselectcompany",$conf->global->COMPANY_USE_SEARCH_TO_SELECT,1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td>";
}
print '</tr>';
print '</form>'; print '</form>';
print "</table>\n"; print '</table>';
*/
$db->close(); $db->close();

View File

@@ -387,7 +387,7 @@ class CommonObject
// On recherche les societes // On recherche les societes
$sql = "SELECT s.rowid, s.nom FROM"; $sql = "SELECT s.rowid, s.nom FROM";
$sql .= " ".MAIN_DB_PREFIX."societe as s"; $sql .= " ".MAIN_DB_PREFIX."societe as s";
if ($conf->use_ajax && $conf->global->CODE_DE_TEST == 1) if ($conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
{ {
$sql.= " WHERE rowid = ".$selected; $sql.= " WHERE rowid = ".$selected;
} }
@@ -396,7 +396,7 @@ class CommonObject
$resql = $object->db->query($sql); $resql = $object->db->query($sql);
if ($resql) if ($resql)
{ {
if ($conf->use_ajax && $conf->global->CODE_DE_TEST == 1) if ($conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
{ {
$langs->load("companies"); $langs->load("companies");
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
@@ -406,6 +406,8 @@ class CommonObject
// On applique un delai d'execution pour le bon fonctionnement // On applique un delai d'execution pour le bon fonctionnement
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"'; $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding">';
print '<div>'; print '<div>';
if ($obj->rowid == 0) if ($obj->rowid == 0)
{ {
@@ -415,8 +417,12 @@ class CommonObject
{ {
print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$obj->nom.'" '.$htmloption.' />'; print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$obj->nom.'" '.$htmloption.' />';
} }
print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php','');
print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php','working'); print '</td>';
print '<td class="nobordernopadding" align="left" width="16">';
print ajax_indicator($htmlname,'working');
print '</td></tr>';
print '</table>';
return $socid; return $socid;
} }
else else

View File

@@ -397,7 +397,7 @@ class Form
{ {
$htmloption = 'onChange="ac_delay(\'company_save_refresh()\',\'500\')"'; $htmloption = 'onChange="ac_delay(\'company_save_refresh()\',\'500\')"';
} }
print '<div>'; print '<div>';
if ($obj->rowid == 0) if ($obj->rowid == 0)
{ {
@@ -409,7 +409,6 @@ class Form
} }
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','working'); print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','working');
} }
else else
{ {
@@ -893,7 +892,7 @@ class Form
print '<td class="nobordernopadding" width="80" nowrap="nowrap">'; print '<td class="nobordernopadding" width="80" nowrap="nowrap">';
print $langs->trans("RefOrLabel").':</td>'; print $langs->trans("RefOrLabel").':</td>';
print '<td class="nobordernopadding" align="left" width="16">'; print '<td class="nobordernopadding" align="left" width="16">';
print ajax_updater_indicator($htmlname,'working'); print ajax_indicator($htmlname,'working');
print '</td>'; print '</td>';
print '<td align="left"><input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'"> '; print '<td align="left"><input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'"> ';
print '</td>'; print '</td>';

View File

@@ -21,6 +21,7 @@ DictionnarySetup=Dictionnary setup
DisableJavascript=Disable JavaScript functions DisableJavascript=Disable JavaScript functions
DisableAjax=Disable AJAX functions DisableAjax=Disable AJAX functions
UseSearchToSelectProduct=Use a search form to choose a product (intead of using a list box) UseSearchToSelectProduct=Use a search form to choose a product (intead of using a list box)
UseSearchToSelectProduct=Use a search form to choose a company (intead of using a list box)
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
JavascriptDisabled=JavaScript disabled JavascriptDisabled=JavaScript disabled
UsePopupCalendar=Use popup for dates input UsePopupCalendar=Use popup for dates input

View File

@@ -21,6 +21,7 @@ DictionnarySetup=Dictionnaires
DisableJavascript=D<>sactiver les fonctions javascript DisableJavascript=D<>sactiver les fonctions javascript
DisableAjax=D<>sactiver les fonctions ajax DisableAjax=D<>sactiver les fonctions ajax
UseSearchToSelectProduct=Utiliser un formulaire de recherche pour choix d'un produit (plut<75>t que liste d<>roulante) UseSearchToSelectProduct=Utiliser un formulaire de recherche pour choix d'un produit (plut<75>t que liste d<>roulante)
UseSearchToSelectCompany=Utiliser un formulaire de recherche pour choix d'un tiers (plut<75>t que liste d<>roulante)
NotAvailableWhenAjaxDisabled=Non disponible quand Ajax d<>sactiv<69> NotAvailableWhenAjaxDisabled=Non disponible quand Ajax d<>sactiv<69>
JavascriptDisabled=Javascript d<>sactiv<69> JavascriptDisabled=Javascript d<>sactiv<69>
UsePopupCalendar=Utiliser les popups pour la saisie des dates UsePopupCalendar=Utiliser les popups pour la saisie des dates

View File

@@ -2733,7 +2733,7 @@ function num_lines($texte)
return $nblines; return $nblines;
} }
function ajax_updater_indicator($htmlname,$indicator='working') function ajax_indicator($htmlname,$indicator='working')
{ {
$script.='<span id="indicator'.$htmlname.'" style="display: none">'.img_picto('Working...',$indicator.'.gif').'</span>'; $script.='<span id="indicator'.$htmlname.'" style="display: none">'.img_picto('Working...',$indicator.'.gif').'</span>';
return $script; return $script;
@@ -2751,7 +2751,7 @@ function ajax_updater_indicator($htmlname,$indicator='working')
function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working') function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
{ {
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">'; $script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
if ($indicator) $script.=ajax_updater_indicator($htmlname,$indicator); if ($indicator) $script.=ajax_indicator($htmlname,$indicator);
$script.='<script type="text/javascript">'; $script.='<script type="text/javascript">';
$script.='var myIndicator'.$htmlname.' = { $script.='var myIndicator'.$htmlname.' = {
onCreate: function(){ onCreate: function(){
@@ -2791,7 +2791,7 @@ function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
*/ */
function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working') function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working')
{ {
$script.= '<span id="indicator'.$htmlname.'" style="display: none">'.img_picto('Working...',$indicator.'.gif').'</span>'; if ($indicator) $script.= ajax_indicator($htmlname,$indicator);
$script.= '<input type="hidden" name="'.$htmlname.'_id" id="'.$htmlname.'_id" value="'.$selected.'" />'; $script.= '<input type="hidden" name="'.$htmlname.'_id" id="'.$htmlname.'_id" value="'.$selected.'" />';
$script.= '</div>'; $script.= '</div>';
$script.= '<div id="result'.$htmlname.'" class="autocomplete"></div>'; $script.= '<div id="result'.$htmlname.'" class="autocomplete"></div>';