Hello friends
someone managed to develop a auto-fill editable?
There is a topic posted to a video, but no showed how.
Anyone know how?
Thank you
Auto-fill editable
- Marcelo Vitoria
- Veteran Member
- Posts: 65
- Joined: 2016-10-11 12:08
Auto-fill editable
Marcelo Vitoria
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.12 - AdminLTE - SPM
https://www.workspaceservices.com.br
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.12 - AdminLTE - SPM
https://www.workspaceservices.com.br
Re: Auto-fill editable
This sample is to change lookups values based on default values. If you want to change a text box, then use $j('#field').val(value)
In your tablename-dv.js file, listening to the change event of the field
My function actualizaLookupsEntidad in the same file:
My updateLookup function
My ajax-entidad-datos-defecto.php ajax "service"
In your tablename-dv.js file, listening to the change event of the field
Code: Select all
$j('#entidad_id-container').on('change', function(){
// Al cambiar entidad se localiza valores por defecto.
if ($j('#entidad_id').val() == '{empty_value}') return false;
valor_entidad = $j('#entidad_id').val();
$j.ajax({
url: 'hooks/ajax-entidad-datos-defecto.php',
data: { entidad_id: valor_entidad },
success: function(data){
if (data) {
actualizaLookupsEntidad(data);
}
}
});
});
Code: Select all
function actualizaLookupsEntidad(datos){
var dataJSON = JSON.parse(datos);
updateLookup('serie_id', dataJSON.serieid, dataJSON.seriecodigo + ' - ' + dataJSON.serie );
updateLookup('formaDePago_id', dataJSON.formadepagoid, dataJSON.formadepagoref + ' - ' + dataJSON.formadepago );
updateLookup('condicionDePago_id', dataJSON.condicionid, dataJSON.condicionref + ' - ' + dataJSON.condicion );
updateLookup('comercial_id', dataJSON.comercialid, dataJSON.comercialref + ' - ' + dataJSON.comercial );
}
Code: Select all
function updateLookup(field, idValue, textValue){
if (idValue) {
$j('#' + field).val(idValue);
$j('#' + field + '-container').select2('data', {id:idValue, text:textValue});
} else {
$j('#' + field).val(idValue);
$j('#' + field + '-container').select2('data', {id:null, text:'<No>'});
}
}
Code: Select all
<?php
$currDir = dirname(__FILE__) . '/..';
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
/* grant access to all users who have acess to the orders table */
$od_from = get_sql_from('entidad');
if(!$od_from){
header('HTTP/1.0 401 Unauthorized');
exit;
}
$entidad = makesafe($_REQUEST['entidad_id']);
if (!$entidad) die("Ocurrió un error");
//consultar siguiente
$sql = "SELECT
formadepago.nombreFormaDePago AS formadepago,
formadepago.ref AS formadepagoref,
formadepago.id AS formadepagoid,
seriedocumento.codigoSerie AS seriecodigo,
seriedocumento.id AS serieid,
seriedocumento.nombreSerie AS serie,
direccionentidad.id AS direccionid,
direccionentidad.nombreDireccion AS direccion,
condiciondepago.id AS condicionid,
condiciondepago.nombreCondicionDePago AS condicion,
condiciondepago.ref AS condicionref,
comercial.id AS comercialid,
comercial.ref AS comercialref,
comercial.nombreComercial AS comercial
FROM
entidad
LEFT JOIN seriedocumento ON entidad.seriePorDefecto_id = seriedocumento.id
LEFT JOIN direccionentidad ON entidad.id = direccionentidad.entidad_id AND direccionentidad.direccion_defecto = 1
LEFT JOIN formadepago ON entidad.formaDePagoVentas_id = formadepago.id
LEFT JOIN condiciondepago ON entidad.condicionDePagoVentas_id = condiciondepago.id
LEFT JOIN comercial ON entidad.comercial_id = comercial.id
WHERE entidad.id = {$entidad}";
$datos = sql($sql, $eo);
//$salida = array();
$valores_defecto = db_fetch_assoc($datos);
echo json_encode($valores_defecto);
/Giuseppe
Professional Outsourcing Services
Professional Outsourcing Services
Re: Auto-fill editable
Showing it In action:
https://vimeo.com/187784044
https://vimeo.com/187784044
/Giuseppe
Professional Outsourcing Services
Professional Outsourcing Services
- Marcelo Vitoria
- Veteran Member
- Posts: 65
- Joined: 2016-10-11 12:08
Re: Auto-fill editable
hello DevGiu
I am new to PHP, but I will try to implement your suggestion.
Thanks a lot for the help!
I am new to PHP, but I will try to implement your suggestion.
Thanks a lot for the help!
Marcelo Vitoria
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.12 - AdminLTE - SPM
https://www.workspaceservices.com.br
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.12 - AdminLTE - SPM
https://www.workspaceservices.com.br