forked from Wavyzz/dolibarr
Debug option MAIN_AUTOFILL_TOWNFROMZIP
This commit is contained in:
@@ -230,14 +230,12 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
print '<tr><td>'.$langs->trans('DeliveryAddressLabel').'</td><td><input type="text" size="30" name="label" value="'.$livraison->label.'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$livraison->nom.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
||||
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
||||
print $livraison->adresse;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'"';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
|
||||
print '>';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'">';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville,pays_id,departement_id)">';
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
||||
|
||||
@@ -340,10 +338,8 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print $livraison->adresse;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'"';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
|
||||
print '>';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'">';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville,pays_id,departement_id)">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
||||
|
||||
@@ -25,14 +25,17 @@ function barcode_coder_save(formNameID)
|
||||
|
||||
/*=================================================================
|
||||
Purpose: Pour la fonction de saisie auto des villes
|
||||
Input: postalcode,objectville
|
||||
Input: postalcode,objecttown,objectcountry,objectstate
|
||||
Author: Eric Seigne
|
||||
Licence: GPL
|
||||
==================================================================*/
|
||||
|
||||
function autofilltownfromzip_PopupPostalCode(postalcode,objectville)
|
||||
function autofilltownfromzip_PopupPostalCode(postalcode,objecttown,objectcountry,objectstate)
|
||||
{
|
||||
var url = 'searchpostalcode.php?cp=' + postalcode + '&targetobject=window.opener.document.formsoc.' + objectville.name;
|
||||
var url = 'searchpostalcode.php?cp=' + postalcode;
|
||||
url = url + '&targettown=window.opener.document.formsoc.' + objecttown.name;
|
||||
url = url + '&targetcountry=window.opener.document.formsoc.' + objectcountry.name;
|
||||
url = url + '&targetstate=window.opener.document.formsoc.' + objectstate.name;
|
||||
// alert(url);
|
||||
var hWnd = window.open(url, "SearchPostalCodeWindow", "width=" + 300 + ",height=" + 150 + ",resizable=yes,scrollbars=yes");
|
||||
if((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@@ -26,19 +26,16 @@
|
||||
*
|
||||
* Description:
|
||||
* ------------
|
||||
* @version $Id$
|
||||
* @revision $Id$
|
||||
* @author Eric Seigne
|
||||
* @project
|
||||
* @copyright Eric Seigne 13/06/2005
|
||||
*
|
||||
* ************************************************************************* */
|
||||
|
||||
/**
|
||||
\file htdocs/searchpostalcode.php
|
||||
\ingroup societe
|
||||
\brief Recherche de la ville correspondant au code postal saisi. 1er tour on cherche dans la table societe, si on a deux clients dans la meme ville c'est direct. Si jamais la recherche ne donne rien alors on lance la recherche dans la table des codes postaux.
|
||||
\version $Revision$
|
||||
* \file htdocs/searchpostalcode.php
|
||||
* \ingroup societe
|
||||
* \brief Recherche de la ville correspondant au code postal saisi. 1er tour on cherche dans la table societe, si on a deux clients dans la meme ville c'est direct. Si jamais la recherche ne donne rien alors on lance la recherche dans la table des codes postaux.
|
||||
* \version $Id$
|
||||
*/
|
||||
require("pre.inc.php");
|
||||
|
||||
@@ -49,19 +46,28 @@ function run_request($table)
|
||||
{
|
||||
global $db;
|
||||
$cp=isset($_GET["cp"])?trim($_GET["cp"]):'';
|
||||
$cp=eregi_replace('\*','%',$cp);
|
||||
|
||||
$sql = "SELECT DISTINCT ville, cp";
|
||||
$sql = "SELECT DISTINCT cp, ville, fk_departement, fk_pays, p.code as pays_code, p.libelle as pays_lib";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$table;
|
||||
$sql.= " WHERE cp ".($cp?"LIKE":"=")." '".addslashes($cp)."'";
|
||||
$sql.= " ORDER by ville";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_pays as p ON fk_pays = p.rowid';
|
||||
$sql.= " WHERE";
|
||||
if ($cp)
|
||||
{
|
||||
$cp=eregi_replace('\*','%',$cp);
|
||||
$sql.= " cp LIKE '".addslashes($cp)."' AND";
|
||||
$sql.= " (ville IS NOT NULL OR fk_departement IS NOT NULL OR fk_pays IS NOT NULL)";
|
||||
}
|
||||
else $sql.= " cp != '' AND cp IS NOT NULL";
|
||||
$sql.= " ORDER by fk_pays, ville, cp";
|
||||
$sql.= ' '.$db->plimit(50); // Avoid pb with bad criteria
|
||||
|
||||
//print $sql.'<br>';
|
||||
$result=$db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
//print $sql.'<br>';
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,66 +80,70 @@ if ($user->societe_id > 0)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
top_htmlhead("", $langs->trans("SearchTown"));
|
||||
|
||||
print "<body>";
|
||||
|
||||
print "
|
||||
$javascript="
|
||||
<script language=\"JavaScript\" type=\"text/javascript\">
|
||||
<!--
|
||||
function MAJ(target)
|
||||
function MAJ(targettown,targetcountry,targetstate)
|
||||
{
|
||||
var e2 = \"\";
|
||||
for (var i = 0; i < document.villes.elements.length && e2 == \"\"; i++)
|
||||
for (var i = 0; i < document.searchform.elements.length; i++)
|
||||
{
|
||||
var e = document.villes.elements[i];
|
||||
if (e.checked){
|
||||
e2 = e.value;
|
||||
target.value = unescape(e2);
|
||||
var e = document.searchform.elements[i];
|
||||
if (e.checked)
|
||||
{
|
||||
newtown = e.value;
|
||||
targettown.value = unescape(newtown);
|
||||
break;
|
||||
}
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
function change_categorie(urlbase,leselect)
|
||||
{
|
||||
if (leselect.options[leselect.selectedIndex].value!=\"dummy\")
|
||||
eval(\"location='\"+urlbase+\"?c=\"+leselect.options[leselect.selectedIndex].value+\"&objet=$objet'\");
|
||||
}
|
||||
//-->
|
||||
</script>\n";
|
||||
|
||||
top_htmlhead("", $langs->trans("SearchTown"));
|
||||
|
||||
print "<div><div><br>"; // Ouvre 3 div a la place de top_menu car le llxFooter en ferme 3
|
||||
// Same as llxHeader. Open what llxFooter close
|
||||
print '<body>';
|
||||
print $javascript;
|
||||
|
||||
print "<form method=\"post\" action=\"javascript:MAJ(" . $_GET['targetobject'] . ");\" name=\"villes\" enctype=\"application/x-www-form-urlencoded\">";
|
||||
print '<table summary="" width="100%"><tr><td>';
|
||||
print "<div><br>"; // Ouvre div a la place de top_menu car le llxFooter en ferme un
|
||||
|
||||
print "<form method=\"post\" action=\"javascript:MAJ(".$_GET['targettown'].",".$_GET['targetcountry'].",".$_GET['targetstate'].");\" name=\"searchform\" enctype=\"application/x-www-form-urlencoded\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print "<table class=\"noborder\" align=\"center\" width=\"90%\">";
|
||||
print "<table summary=\"listoftowns\" class=\"nobordernopadding\" align=\"center\" width=\"90%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print " <td colspan=\"3\" align=\"center\">";
|
||||
print " <b>Recherche code postal: " . $_GET['cp'] . " </b>";
|
||||
print " </td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$result = run_request("societe");
|
||||
$num=0;
|
||||
|
||||
$result = run_request("societe");
|
||||
if ($result)
|
||||
{
|
||||
$num=$db->num_rows($result);
|
||||
//print 'sql='.$sql.' num='.$num; exit;
|
||||
if($num == 0)
|
||||
{
|
||||
$result = run_request("postalcode");
|
||||
$num=$db->num_rows($result);
|
||||
}
|
||||
|
||||
// Si on n'a qu'un seul resultat on switche direct et on remplit le formulaire
|
||||
// Si on n'a pas ou un seul resultat on switche direct et on remplit le formulaire
|
||||
if($num <= 1)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$ville = $obj->ville;
|
||||
$ville_code = urlencode("$ville");
|
||||
print "<tr ".$bc[$var]."><td width=\"10%\">";
|
||||
print "<input type=\"radio\" name=\"choix\" value=\"$ville\" checked>";
|
||||
print "<script language=\"javascript\" type=\"text/javascript\">document.villes.submit();</script>\n";
|
||||
print '<input type="radio" name="town" value="'.$ville.'" checked>';
|
||||
print "<script language=\"javascript\" type=\"text/javascript\">document.searchform.submit();</script>\n";
|
||||
print "</td></tr>";
|
||||
}
|
||||
else
|
||||
@@ -142,31 +152,34 @@ else
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$ville = $obj->ville;
|
||||
$ville_code = urlencode("$ville");
|
||||
if ($obj->cp)
|
||||
$cp = "(" . $obj->cp . ")";
|
||||
else
|
||||
$cp = "";
|
||||
|
||||
if($bgcolor=="#DDDDFF")
|
||||
$bgcolor="#EEEEFF";
|
||||
else
|
||||
$bgcolor="#DDDDFF";
|
||||
$cp = $obj->cp;
|
||||
$ville = $obj->ville;
|
||||
|
||||
$dep = $obj->fk_departement;
|
||||
$dep_lib = $obj->fk_departement;
|
||||
|
||||
$country_code = $obj->pays_code;
|
||||
$temp=$obj->pays_code?$langs->transcountry("Country",$obj->pays_code):'';
|
||||
if ($temp == 'Country') $temp=$obj->pays_lib;
|
||||
$country_lib = $temp;
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var]."><td width=\"10%\">";
|
||||
print '<input type="radio" name="choix" value="'.$ville.'"> '.$ville.' '.$cp;
|
||||
print "</td></tr>";
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td>'.$country_lib.'</td>';
|
||||
print "<td width=\"80\" nowrap=\"nowrap\">";
|
||||
print '<input type="radio" name="town" value="'.$ville.'">'.$cp.'</td>';
|
||||
print '<td>'.$ville.'</td>';
|
||||
print "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$var=!$var;
|
||||
print "<tr><td align=\"center\" colspan=\"3\">";
|
||||
print "<input type=\"hidden\" name=\"nb_i\" value=\"$i\">";
|
||||
print "<input type=\"submit\" class=\"button\" name=\"envoyer\" value=\"".$langs->trans("Modify")."\">";
|
||||
print "<br><input type=\"hidden\" name=\"nb_i\" value=\"$i\">";
|
||||
print "<input type=\"submit\" class=\"button\" name=\"envoyer\" value=\"".$langs->trans("Select")."\">";
|
||||
print " ";
|
||||
print "<input type=\"button\" class=\"button\" value=\"".$langs->trans("Cancel")."\" onClick=\"window.close();\">";
|
||||
print "</td></tr>";
|
||||
|
||||
@@ -461,14 +461,12 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
||||
print '</textarea></td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
||||
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
|
||||
print $soc->adresse;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
|
||||
print '>';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'">';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville,pays_id,departement_id)">';
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||
|
||||
@@ -820,10 +818,8 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print $soc->adresse;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
|
||||
print '>';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
|
||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'">';
|
||||
if ($conf->use_javascript_ajax && $conf->global->MAIN_AUTOFILL_TOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville,pays_id,departement_id)">';
|
||||
print '</td>';
|
||||
|
||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||
|
||||
@@ -444,10 +444,10 @@ class Translate {
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
* \brief Return translation of a key depending on country
|
||||
* \param str string root to translate
|
||||
* \param countrycode country code (FR, ...)
|
||||
* \return string translated string
|
||||
*/
|
||||
function transcountry($str, $countrycode)
|
||||
{
|
||||
@@ -458,9 +458,9 @@ class Translate {
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
* \param str string root to translate
|
||||
* \param countrycode country code (FR, ...)
|
||||
* \return string translated string
|
||||
*/
|
||||
function transcountrynoentities($str, $countrycode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user