Fix: Some ajax features was broken

This commit is contained in:
Laurent Destailleur
2009-08-27 22:20:01 +00:00
parent 8843c70cd0
commit c296965865
12 changed files with 89 additions and 73 deletions

View File

@@ -19,7 +19,7 @@
/** /**
* \file htdocs/ajaxbox.php * \file htdocs/ajaxbox.php
* \brief Fichier de reponse sur evenement Ajax deplacement boxes * \brief File to return Ajax response on Box move
* \version $Id$ * \version $Id$
*/ */

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2007 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* *
* 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
@@ -18,10 +18,10 @@
*/ */
/** /**
\file htdocs/compta/facture/contact.php * \file htdocs/compta/facture/contact.php
\ingroup facture * \ingroup facture
\brief Onglet de gestion des contacts des factures * \brief Onglet de gestion des contacts des factures
\version $Id$ * \version $Id$
*/ */
require ("./pre.inc.php"); require ("./pre.inc.php");
@@ -142,6 +142,10 @@ if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer)
} }
/*
* View
*/
llxHeader('', $langs->trans("Bill"), "Facture"); llxHeader('', $langs->trans("Bill"), "Facture");
$html = new Form($db); $html = new Form($db);
@@ -192,7 +196,7 @@ if ($id > 0)
/* /*
* Ajouter une ligne de contact * Ajouter une ligne de contact
* Non affich<EFBFBD> en mode modification de ligne * Non affiche en mode modification de ligne
*/ */
if ($_GET["action"] != 'editline' && $user->rights->facture->creer) if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
{ {
@@ -224,7 +228,7 @@ if ($id > 0)
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
// On r<>cup<75>re les id des users d<>j<EFBFBD> s<>lectionn<6E>s // Ge get ids of alreadey selected users
//$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type //$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_users($user->id,'contactid',0,$userAlreadySelected); $html->select_users($user->id,'contactid',0,$userAlreadySelected);
print '</td>'; print '</td>';
@@ -250,12 +254,12 @@ if ($id > 0)
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td nowrap="nowrap">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); $selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany');
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td>';
//$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le seclectionner une deuxieme fois pour un autre type //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");

View File

@@ -226,11 +226,11 @@ class Form
$mode_company = substr($htmloption,-10,7); $mode_company = substr($htmloption,-10,7);
if ($mode_create == 'create') if ($mode_create == 'create')
{ {
$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_create()\',\'500\')"'; $htmloption = 'onChange="ac_delay(\'company_save_refresh_create()\',\'500\')"';
} }
else if ($mode_edit == 'edit') else if ($mode_edit == 'edit')
{ {
$htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_edit()\',\'500\')"'; $htmloption = 'onChange="ac_delay(\'company_save_refresh_edit()\',\'500\')"';
} }
else if ($mode_company == 'refresh') else if ($mode_company == 'refresh')
{ {
@@ -247,7 +247,8 @@ class Form
print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />'; print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />';
} }
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','working'); print ajax_indicator($htmlname,'working');
print ajax_autocompleter($pays_id,'pays','/societe/ajaxcountries.php','');
} }
else else
{ {
@@ -488,16 +489,23 @@ class Form
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$socid = $obj->rowid?$obj->rowid:''; $socid = $obj->rowid?$obj->rowid:'';
} }
// We call a page after a small delay when a new input has been selected
//$javaScript = "window.location=\'...\'";
//$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
$htmloption='';
print '<!-- Input text for third party with Ajax.Autocompleter (select_societes) -->'."\n";
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding">'; print '<td class="nobordernopadding">';
print '<div>';
if ($socid == 0) if ($socid == 0)
{ {
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value=""/>'; $langs->load("companies");
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$langs->trans("SelectCompany").'" '.$htmloption.' />';
} }
else else
{ {
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$obj->nom.'"/>'; print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
} }
print ajax_autocompleter(($socid?$socid:-1),$htmlname,'/societe/ajaxcompanies.php?filter='.urlencode($filter), ''); print ajax_autocompleter(($socid?$socid:-1),$htmlname,'/societe/ajaxcompanies.php?filter='.urlencode($filter), '');
print '</td>'; print '</td>';
@@ -767,14 +775,14 @@ 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_indicator($htmlname,'working'); print ajax_indicator($htmlname,'working'); // Indicator is et here
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>';
print '</tr>'; print '</tr>';
print '<tr class="nocellnopadd">'; print '<tr class="nocellnopadd">';
print '<td class="nobordernopadding" colspan="3">'; print '<td class="nobordernopadding" colspan="3">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,''); // Indicator is '' to disable it as it is alreay output
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }

View File

@@ -455,10 +455,7 @@ class FormCompany
// 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_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) if ($selected && $conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) $sql.= " WHERE rowid = ".$selected;
{
$sql.= " WHERE rowid = ".$selected;
}
$sql .= " ORDER BY nom ASC"; $sql .= " ORDER BY nom ASC";
$resql = $object->db->query($sql); $resql = $object->db->query($sql);
@@ -466,31 +463,36 @@ class FormCompany
{ {
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
{ {
$langs->load("companies"); $socid=0;
if ($selected)
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$socid = $obj->rowid?$obj->rowid:''; $socid = $obj->rowid?$obj->rowid:'';
$javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&amp;".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;"; }
// On applique un delai d'execution pour le bon fonctionnement // We call a page after a small delay when a new input has been selected
$javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&amp;".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;";
$htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"'; $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"';
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n";
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td class="nobordernopadding">'; print '<td class="nobordernopadding">';
print '<div>';
if ($obj->rowid == 0) if ($obj->rowid == 0)
{ {
print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$langs->trans("SelectCompany").'" '.$htmloption.' />'; $langs->load("companies");
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$langs->trans("SelectCompany").'" '.$htmloption.' />';
} }
else else
{ {
print '<input type="text" size="30" id="newcompany" name="newcompany" value="'.$obj->nom.'" '.$htmloption.' />'; print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$obj->nom.'" '.$htmloption.' />';
} }
print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php',''); print ajax_autocompleter(($socid?$socid:-1),$htmlname,'/societe/ajaxcompanies.php','');
print '</td>'; print '</td>';
print '<td class="nobordernopadding" align="left" width="16">'; print '<td class="nobordernopadding" align="left" width="16">';
print ajax_indicator($htmlname,'working'); print ajax_indicator($htmlname,'working');
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print "\n";
return $socid; return $socid;
} }
else else

View File

@@ -19,7 +19,7 @@
*/ */
/** /**
* \file htdocs/lib/agenda.lib.php * \file htdocs/lib/ajax.lib.php
* \brief Page called by Ajax request for produts * \brief Page called by Ajax request for produts
* \version $Id$ * \version $Id$
*/ */
@@ -117,7 +117,7 @@ function ajax_updaterWithID($htmlname,$keysearch,$id,$url,$option='',$indicator=
} }
/** /**
* \brief Get vlaue of field, do Ajax process and return result * \brief Get value of field, do Ajax process and return result
* \param htmlname nom et id du champ * \param htmlname nom et id du champ
* \param url chemin du fichier de reponse : /chemin/fichier.php * \param url chemin du fichier de reponse : /chemin/fichier.php
* \param indicator nom de l'image gif sans l'extension * \param indicator nom de l'image gif sans l'extension
@@ -125,9 +125,10 @@ function ajax_updaterWithID($htmlname,$keysearch,$id,$url,$option='',$indicator=
*/ */
function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working') function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working')
{ {
if ($indicator) $script.= ajax_indicator($htmlname,$indicator); $script='';
$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 id="result'.$htmlname.'" class="autocomplete"></div>'; $script.= '<div id="result'.$htmlname.'" class="autocomplete"></div>';
$script.= '<script type="text/javascript">'; $script.= '<script type="text/javascript">';
$script.= 'new Ajax.Autocompleter(\''.$htmlname.'\',\'result'.$htmlname.'\',\''.DOL_URL_ROOT.$url.'\',{ $script.= 'new Ajax.Autocompleter(\''.$htmlname.'\',\'result'.$htmlname.'\',\''.DOL_URL_ROOT.$url.'\',{

View File

@@ -41,13 +41,13 @@ function autofilltownfromzip_PopupPostalCode(postalcode,objecttown,objectcountry
if((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window; if((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window;
} }
function autofilltownfromzip_save_refresh_edit() function company_save_refresh_edit()
{ {
document.formsoc.action.value="edit"; document.formsoc.action.value="edit";
document.formsoc.submit(); document.formsoc.submit();
} }
function autofilltownfromzip_save_refresh_create() function company_save_refresh_create()
{ {
document.formsoc.action.value="create"; document.formsoc.action.value="create";
document.formsoc.submit(); document.formsoc.submit();

View File

@@ -767,7 +767,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<!-- Includes for Scriptaculous (Used by Drag and drop and PWC) -->'."\n"; print '<!-- Includes for Scriptaculous (Used by Drag and drop and PWC) -->'."\n";
//print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n"; //print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n";
//print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls,slider,sound"></script>'."\n"; //print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js?load=builder,effects,dragdrop,controls,slider,sound"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js?load=effects,dragdrop"></script>'."\n"; $listofscripts='effects,dragdrop';
if ($conf->global->COMPANY_USE_SEARCH_TO_SELECT) $listofscripts.=',controls'; // For Ajax.Autocompleter
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js?load='.$listofscripts.'"></script>'."\n";
} }
// Those ones are required only with option "confirm by ajax popup" // Those ones are required only with option "confirm by ajax popup"

View File

@@ -20,7 +20,7 @@
/** /**
* \file htdocs/product/ajaxproducts.php * \file htdocs/product/ajaxproducts.php
* \brief File to return Ajax question of product list * \brief File to return Ajax response on product list request
* \version $Id$ * \version $Id$
*/ */

View File

@@ -266,7 +266,8 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
* View * View
*/ */
llxHeader(); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('','',$help_url);
$form = new Form($db); $form = new Form($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);

View File

@@ -100,20 +100,23 @@ if ($mode == 'search')
} }
$db->free($result); $db->free($result);
} }
// S<>curit<69> acc<63>s client }
// Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
}
/* /*
* View * View
*/ */
llxHeader($langs->trans("ThirdParty"),'','EN:Third_Parties|FR:Tiers|ES:Empresas'); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader($langs->trans("ThirdParty"),'',$help_url);
$form=new Form($db); $form=new Form($db);
$companystatic=new Societe($db); $companystatic=new Societe($db);

View File

@@ -16,14 +16,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*/ */
/** /**
\file htdocs/societe/ajaxcompanies.php * \file htdocs/societe/ajaxcompanies.php
\brief Fichier de reponse sur evenement Ajax * \brief File to return Ajax response on third parties request
\version $Revision$ * \version $Id$
*/ */
define('NOTOKENRENEWAL',1); // Disables token renewal define('NOTOKENRENEWAL',1); // Disables token renewal

View File

@@ -15,15 +15,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/ */
/** /**
\file htdocs/societe/ajaxcountries.php * \file htdocs/societe/ajaxcountries.php
\brief Fichier de reponse sur evenement Ajax * \brief File to return Ajax response on country request
\version $Revision$ * \version $Id$
*/ */
define('NOTOKENRENEWAL',1); // Disables token renewal define('NOTOKENRENEWAL',1); // Disables token renewal