Fix: Pb with autocompletefor records with no country and state

This commit is contained in:
Laurent Destailleur 2010-10-31 20:09:50 +00:00
parent 1b9b787622
commit c96915b3ce
8 changed files with 61 additions and 26 deletions

View File

@ -88,6 +88,7 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
$fields = php2js($fields); $fields = php2js($fields);
$script.= '<!-- Autocomplete -->'."\n";
$script.= '<script type="text/javascript">'; $script.= '<script type="text/javascript">';
$script.= 'jQuery(document).ready(function() { $script.= 'jQuery(document).ready(function() {
var fields = '.$fields.'; var fields = '.$fields.';
@ -107,8 +108,9 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
jQuery("#departement_id").html(item.states); jQuery("#departement_id").html(item.states);
} }
for (i=0;i<length;i++) { for (i=0;i<length;i++) {
if (item[fields[i]]) { if (item[fields[i]]) { // If defined
jQuery("#" + fields[i]).val(item[fields[i]]); //alert(item[fields[i]]);
jQuery("#" + fields[i]).val(item[fields[i]]);
} }
} }
} }
@ -117,14 +119,31 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='')
}); });
}, },
select: function( event, ui ) { select: function( event, ui ) {
// TODO move this to specific request
if (ui.item.states) {
jQuery("#departement_id").html(ui.item.states);
}
for (i=0;i<length;i++) { for (i=0;i<length;i++) {
//alert(fields[i] + " = " + ui.item[fields[i]]); //alert(fields[i] + " = " + ui.item[fields[i]]);
if (ui.item[fields[i]]) { if (fields[i]=="selectpays_id")
jQuery("#" + fields[i]).val(ui.item[fields[i]]); {
if (ui.item[fields[i]] > 0) // Do not erase country if unknown
{
jQuery("#" + fields[i]).val(ui.item[fields[i]]);
// If we set new country and new state, we need to set a new list of state to allow change
if (ui.item.states && ui.item["departement_id"] != jQuery("#departement_id").value) {
jQuery("#departement_id").html(ui.item.states);
}
}
}
else if (fields[i]=="departement_id")
{
if (ui.item[fields[i]] > 0) // Do not erase state if unknown
{
jQuery("#" + fields[i]).val(ui.item[fields[i]]); // This may fails if not correct country
}
}
else if (ui.item[fields[i]]) { // If defined
//alert(fields[i]);
//alert(ui.item[fields[i]]);
jQuery("#" + fields[i]).val(ui.item[fields[i]]);
} }
} }
} }

View File

@ -61,6 +61,8 @@ $langs->load("paypal");
llxHeaderPayBox($langs->trans("PaymentForm")); llxHeaderPayBox($langs->trans("PaymentForm"));
print '<span id="dolpaymentspan"></span>'."\n";
print $langs->trans("YourPaymentHasNotBeenRecorded"); print $langs->trans("YourPaymentHasNotBeenRecorded");

View File

@ -60,6 +60,8 @@ $langs->load("paypal");
llxHeaderPayBox($langs->trans("PaymentForm")); llxHeaderPayBox($langs->trans("PaymentForm"));
print '<span id="dolpaymentspan"></span>'."\n";
print $langs->trans("YourPaymentHasBeenRecorded"); print $langs->trans("YourPaymentHasBeenRecorded");

View File

@ -78,9 +78,9 @@ if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly')
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral')
{ {
dol_syslog("expresscheckout redirect with CallMarkExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum"); dol_syslog("expresscheckout redirect with CallMarkExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL); //$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL);
//$resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $resArray = CallMarkExpressCheckout ($paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL,
//$shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum); $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum);
} }
// For direct payment with credit card // For direct payment with credit card
if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly') if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'cconly')

View File

@ -411,6 +411,14 @@ if ($_REQUEST["source"] == 'order')
print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="EMAIL" size="48" value="'.$email.'"></td></tr>'."\n"; print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="EMAIL" size="48" value="'.$email.'"></td></tr>'."\n";
// Shipping address // Shipping address
$shipToName=$order->client->nom;
$shipToStreet=$order->client->address;
$shipToCity=$order->client->ville;
$shipToState=$order->client->departement_code;
$shipToCountryCode=$order->client->pays_code;
$shipToZip=$order->client->cp;
$shipToStreet2='';
$phoneNum=$order->client->tel;
print '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n"; print '<input type="hidden" name="shipToName" value="'.$shipToName.'">'."\n";
print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n"; print '<input type="hidden" name="shipToStreet" value="'.$shipToStreet.'">'."\n";
print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n"; print '<input type="hidden" name="shipToCity" value="'.$shipToCity.'">'."\n";

View File

@ -60,6 +60,8 @@ $langs->load("paypal");
llxHeaderPaypal($langs->trans("PaymentForm")); llxHeaderPaypal($langs->trans("PaymentForm"));
print '<span id="dolpaymentspan"></span>'."\n";
print $langs->trans("YourPaymentHasNotBeenRecorded"); print $langs->trans("YourPaymentHasNotBeenRecorded");
//require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php"); //require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php");

View File

@ -62,6 +62,8 @@ $langs->load("paypal");
llxHeaderPaypal($langs->trans("PaymentForm")); llxHeaderPaypal($langs->trans("PaymentForm"));
print '<span id="dolpaymentspan"></span>'."\n";
print $langs->trans("YourPaymentHasBeenRecorded"); print $langs->trans("YourPaymentHasBeenRecorded");
//require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php"); //require_once(DOL_DOCUMENT_ROOT."/paypal/lib/paypalfunctions.php");