Fix: fix hidden option MAIN_AUTOFILL_TOWNFROMZIP
This commit is contained in:
parent
4ecdeff287
commit
21987a4310
@ -109,7 +109,7 @@ if ($_GET["action"] == 'create')
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>';
|
||||||
|
|
||||||
// Reference client
|
// Reference client
|
||||||
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
|
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
|
||||||
@ -117,7 +117,7 @@ if ($_GET["action"] == 'create')
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Societe
|
// Societe
|
||||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->getNomUrl(1);
|
print '<tr><td class="fieldrequired">'.$langs->trans('Company').'</td><td colspan="2">'.$soc->getNomUrl(1);
|
||||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -140,12 +140,12 @@ if ($_GET["action"] == 'create')
|
|||||||
print '.';
|
print '.';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Date facture
|
// Date
|
||||||
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="2">';
|
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">';
|
||||||
$html->select_date('','','','','',"addprop");
|
$html->select_date('','','','','',"addprop");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("ValidityDuration").'</td><td colspan="2"><input name="duree_validite" size="5" value="'.$conf->global->PROPALE_VALIDITY_DURATION.'"> '.$langs->trans("days").'</td></tr>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("ValidityDuration").'</td><td colspan="2"><input name="duree_validite" size="5" value="'.$conf->global->PROPALE_VALIDITY_DURATION.'"> '.$langs->trans("days").'</td></tr>';
|
||||||
|
|
||||||
// Terms of payment
|
// Terms of payment
|
||||||
print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
|
print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
|
||||||
|
|||||||
@ -239,7 +239,7 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
|
|||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'">';
|
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)">';
|
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(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
|||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$livraison->cp.'">';
|
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)">';
|
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(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
print '<tr><td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$livraison->ville.'"></td></tr>';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
/* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2006-2010 Laurent Destailleur <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
|
||||||
@ -41,36 +41,6 @@ require("pre.inc.php");
|
|||||||
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
|
|
||||||
|
|
||||||
function run_request($table)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
$cp=isset($_GET["cp"])?trim($_GET["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.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_pays as p ON fk_pays = p.rowid';
|
|
||||||
$sql.= " WHERE";
|
|
||||||
if ($cp)
|
|
||||||
{
|
|
||||||
$cp=str_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);
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Security Access Client
|
// Security Access Client
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
@ -79,6 +49,12 @@ if ($user->societe_id > 0)
|
|||||||
$_GET["socid"] = $user->societe_id;
|
$_GET["socid"] = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Entry parameter are
|
||||||
|
// $_GET = array
|
||||||
|
// 'cp' => string '78180' (length=5)
|
||||||
|
// 'targettown' => string 'window.opener.document.formsoc.ville' (length=36)
|
||||||
|
// 'targetcountry' => string 'window.opener.document.formsoc.pays_id' (length=38)
|
||||||
|
// 'targetstate'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -104,10 +80,12 @@ function MAJ(targettown,targetcountry,targetstate)
|
|||||||
//-->
|
//-->
|
||||||
</script>\n";
|
</script>\n";
|
||||||
|
|
||||||
|
|
||||||
top_htmlhead("", $langs->trans("SearchTown"));
|
top_htmlhead("", $langs->trans("SearchTown"));
|
||||||
|
|
||||||
// Same as llxHeader. Open what llxFooter close
|
// Same as llxHeader. Open what llxFooter close
|
||||||
print '<body>';
|
print '<body>';
|
||||||
|
|
||||||
print $javascript;
|
print $javascript;
|
||||||
|
|
||||||
print '<table summary="" width="100%"><tr><td>';
|
print '<table summary="" width="100%"><tr><td>';
|
||||||
@ -131,19 +109,33 @@ if ($result)
|
|||||||
//print 'sql='.$sql.' num='.$num; exit;
|
//print 'sql='.$sql.' num='.$num; exit;
|
||||||
if($num == 0)
|
if($num == 0)
|
||||||
{
|
{
|
||||||
$result = run_request("postalcode");
|
if ($conf->global->MAIN_AUTOFILL_TOWNFROMZIP == 2)
|
||||||
$num=$db->num_rows($result);
|
{
|
||||||
|
$result = run_request("postalcode"); // If a table llx_postalcode exists
|
||||||
|
$num=$db->num_rows($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$showselect=1;
|
||||||
|
|
||||||
// If it has not, or only one result on switch and fill the form
|
// If it has not, or only one result on switch and fill the form
|
||||||
if($num <= 1)
|
if($num <= 1)
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($result);
|
$obj = $db->fetch_object($result);
|
||||||
$ville = $obj->ville;
|
$ville = $obj->ville;
|
||||||
$ville_code = urlencode("$ville");
|
$ville_code = urlencode("$ville");
|
||||||
print "<tr ".$bc[$var]."><td width=\"10%\">";
|
print "<tr ".$bc[$var]."><td width=\"10%\">";
|
||||||
print '<input type="radio" name="town" value="'.$ville.'" checked>';
|
if ($ville && $ville_code)
|
||||||
print "<script language=\"javascript\" type=\"text/javascript\">document.searchform.submit();</script>\n";
|
{
|
||||||
|
print '<input type="radio" name="town" value="'.$ville.'" checked>';
|
||||||
|
print "<script language=\"javascript\" type=\"text/javascript\">document.searchform.submit();</script>\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
print $langs->trans("ErrorRecordNotFound");
|
||||||
|
$showselect=0;
|
||||||
|
}
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -155,6 +147,7 @@ if ($result)
|
|||||||
|
|
||||||
$cp = $obj->cp;
|
$cp = $obj->cp;
|
||||||
$ville = $obj->ville;
|
$ville = $obj->ville;
|
||||||
|
$ville_code = urlencode("$ville");
|
||||||
|
|
||||||
$dep = $obj->fk_departement;
|
$dep = $obj->fk_departement;
|
||||||
$dep_lib = $obj->fk_departement;
|
$dep_lib = $obj->fk_departement;
|
||||||
@ -179,8 +172,11 @@ if ($result)
|
|||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr><td align=\"center\" colspan=\"3\">";
|
print "<tr><td align=\"center\" colspan=\"3\">";
|
||||||
print "<br><input type=\"hidden\" name=\"nb_i\" value=\"$i\">";
|
print "<br><input type=\"hidden\" name=\"nb_i\" value=\"$i\">";
|
||||||
print "<input type=\"submit\" class=\"button\" name=\"envoyer\" value=\"".$langs->trans("Select")."\">";
|
if ($showselect)
|
||||||
print " ";
|
{
|
||||||
|
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 "<input type=\"button\" class=\"button\" value=\"".$langs->trans("Cancel")."\" onClick=\"window.close();\">";
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
@ -189,4 +185,42 @@ print "</table></form><br>\n";
|
|||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date$ - $Revision$',0);
|
llxFooter('$Date$ - $Revision$',0);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @param unknown_type $table
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
function run_request($table)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$cp=isset($_GET["cp"])?trim($_GET["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.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_pays as p ON fk_pays = p.rowid';
|
||||||
|
$sql.= " WHERE";
|
||||||
|
if ($cp)
|
||||||
|
{
|
||||||
|
$cp=str_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);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -32,9 +32,9 @@ function barcode_coder_save(formNameID)
|
|||||||
Licence: GPL
|
Licence: GPL
|
||||||
==================================================================*/
|
==================================================================*/
|
||||||
|
|
||||||
function autofilltownfromzip_PopupPostalCode(postalcode,objecttown,objectcountry,objectstate)
|
function autofilltownfromzip_PopupPostalCode(url_root, postalcode,objecttown,objectcountry,objectstate)
|
||||||
{
|
{
|
||||||
var url = 'searchpostalcode.php?cp=' + postalcode;
|
var url = url_root + '/core/searchpostalcode.php?cp=' + postalcode;
|
||||||
url = url + '&targettown=window.opener.document.formsoc.' + objecttown.name;
|
url = url + '&targettown=window.opener.document.formsoc.' + objecttown.name;
|
||||||
url = url + '&targetcountry=window.opener.document.formsoc.' + objectcountry.name;
|
url = url + '&targetcountry=window.opener.document.formsoc.' + objectcountry.name;
|
||||||
url = url + '&targetstate=window.opener.document.formsoc.' + objectstate.name;
|
url = url + '&targetstate=window.opener.document.formsoc.' + objectstate.name;
|
||||||
|
|||||||
@ -503,7 +503,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create')
|
|||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'">';
|
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)">';
|
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(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||||
|
|
||||||
@ -886,7 +886,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
|||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'">';
|
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)">';
|
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(\''.DOL_URL_ROOT.'\',cp.value,ville,pays_id,departement_id)">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user