Fix search for reconcile

This commit is contained in:
Dany De Bontridder 2017-12-16 00:05:34 +01:00
parent f5c6fd7050
commit 9fd316ccd4
5 changed files with 52 additions and 32 deletions

View file

@ -1247,10 +1247,11 @@ function save_predf_op(obj)
* @param {type} ctl_concern
* @param {type} amount_id
* @param {type} ledger
* @param {type} p_id_target
* @param {type} p_id_targetDom Element (div) where to display the search result
* @param p_tiers id of the Tiers
* @returns {undefined}
*/
function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target)
function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target,p_tiers)
{
var dossier = g('gDossier').value;
if (amount_id === undefined)
@ -1268,24 +1269,31 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target)
amount_id = $(amount_id).innerHTML;
}
}
var target = "search_op";
removeDiv(target);
var tiers=""
if ( p_tiers ) tiers=p_tiers;
var target = "";
if ( p_id_target !="") {
target=p_id_target;
}else {
target = "search"+layer;
removeDiv(target);
}
var str_style = fixed_position(77, 99);
str_style += ";width:92%;overflow:auto;";
waiting_box();
var target = {gDossier: dossier,
var param_send = {gDossier: dossier,
ctlc: ctl_concern,
op: 'search_op',
ctl: target,
ac: 'JSSEARCH',
amount_id: amount_id,
ledger: ledger,
target: p_id_target};
target: target,
tiers:tiers
};
var qs = encodeJSON(target);
var qs = encodeJSON(param_send);
var action = new Ajax.Request('ajax_misc.php',
{
@ -1294,9 +1302,9 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target)
onFailure: null,
onSuccess: function (req) {
remove_waiting_box();
var div = {id: 'search_op', cssclass: 'inner_box', style: str_style, drag: 1};
var div = {id: target, cssclass: 'inner_box', style: str_style, drag: 1};
add_div(div);
$('search_op').innerHTML = req.responseText;
$(target).innerHTML = req.responseText;
req.responseText.evalScripts();
}
}
@ -1310,8 +1318,11 @@ function search_operation(obj)
try {
var dossier = g('gDossier').value;
waiting_box();
var target = "search_op";
var qs = Form.serialize('search_form_ajx') + "&op=search_op&ctl=search_op";
var target = "search"+layer;
if ( $(obj)["target"] ) {
target=$(obj)["target"].value;
}
var qs = Form.serialize('search_form_ajx') + "&op=search_op";
var action = new Ajax.Request('ajax_misc.php',
{
method: 'get',
@ -1319,7 +1330,7 @@ function search_operation(obj)
onFailure: null,
onSuccess: function (req) {
remove_waiting_box();
$('search_op').innerHTML = req.responseText;
$(target).innerHTML = req.responseText;
req.responseText.evalScripts();
}
}
@ -1342,12 +1353,14 @@ function set_reconcile(obj)
try
{
console.log(obj.elements);
var ctlc = obj.elements['ctlc'];
var tiers=obj.elements['tiers'];
if ( ! obj.elements['target']) return;
var target = obj.elements['target'].value;
for (var e = 0; e < obj.elements.length; e++)
{
var elmt = obj.elements[e];
if (elmt.type === "checkbox")
{
@ -1359,15 +1372,16 @@ function set_reconcile(obj)
$(ctlc.value).value += ',';
} else {
if (target != "" && $(target).value == "") {
$(target).value = elmt.value;
if (tiers && tiers.value != "") {
$(tiers.value).value = elmt.value;
}
}
$(ctlc.value).value += nValue;
}
}
}
removeDiv('search_op');
removeDiv(obj.elements['target'].value);
}
catch (e)
{

View file

@ -184,7 +184,7 @@ case 'de':
$op->get();
/* return an obj. ACH / FIN or VEN or null if nothing is found*/
$obj=$op->get_quant();
$oLedger=new Acc_Ledger($cn,$ledger);
if ( $obj==null || $obj->signature == 'ODS' )
{

View file

@ -38,6 +38,8 @@ require_once NOALYSS_INCLUDE.'/class/user.class.php';
$base=basename($_SERVER['SCRIPT_NAME']);
$inside=false;
$tiers=$http->get("tiers","string","");
// With the amount id, we find the amount in a html elt
if (isset($_GET['amount_id']))
{
put_global(array(
@ -45,8 +47,8 @@ if (isset($_GET['amount_id']))
array("key"=>'amount_max','value'=>$_GET['amount_id'])
));
}
$ledger=new Acc_Ledger_Search('ALL',1,'search_op');
$target=$http->get("target","string","");
$ledger=new Acc_Ledger_Search('ALL',1,$target);
if ($base == 'recherche.php' || $base == 'do.php')
{
@ -55,18 +57,18 @@ if ($base == 'recherche.php' || $base == 'do.php')
}
else
{
$div='search_op';
$action="";
$callback="";
echo HtmlInput::title_box(_('Recherche'), $div);
echo HtmlInput::title_box(_('Recherche'), $target);
echo '<form name="search_form_ajx" id="search_form_ajx" onsubmit="search_operation(this);return false">';
echo HtmlInput::get_to_hidden(array('ctlc','ledger','target'));
echo HtmlInput::get_to_hidden(array('ctlc','ledger'));
echo HtmlInput::hidden("target",$target);
$inside=true;
}
echo HtmlInput::hidden("tiers",$tiers);
echo $ledger->search_form();
echo HtmlInput::submit("viewsearch",_("Recherche"));
echo HtmlInput::button_close('search_op');
echo HtmlInput::button_close($target);
echo '</form>';
if ( isset ($_GET['amount_min'])&& isset($_GET['amount_max'])&& ($_GET['amount_max']!=0 ||$_GET['amount_min']!=0 ))
@ -96,11 +98,11 @@ if ( isset ($_GET['viewsearch']) )
else
$array=$_GET;
$array['p_action']='ALL';
if ( ! isset ($array['date_start']) || ! isset ($array['date_end']))
{
// get first date of current exercice
list($array['date_start'],$array['date_end'])=$g_user->get_limit_current_exercice();
}
if ( ! isset ($array['date_start']) || ! isset ($array['date_end']))
{
// get first date of current exercice
list($array['date_start'],$array['date_end'])=$g_user->get_limit_current_exercice();
}
list($sql,$where)=$ledger->build_search_sql($array);
// Count nb of line
@ -117,6 +119,7 @@ if ( isset ($_GET['viewsearch']) )
if ($step<$max_line ) echo '<h2 class="notice">'._('Liste limitée à ').$step._(' enregistrements. Le nombre d\'enregistrements trouvés est de ') .$max_line.'</h2>';
}
echo '<form method="get" onsubmit="set_reconcile(this);return false">';
echo HtmlInput::hidden("tiers",$tiers);
echo HtmlInput::submit("upd_rec",_("Mettre à jour"));
echo HtmlInput::get_to_hidden(array('ctlc','amount_id','ledger'));
echo HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcodesearch_op','accounting','unpaid','gDossier','ledger_type'));

View file

@ -37,6 +37,7 @@ class IConcerned extends HtmlInput
$this->paid='';
$this->id=$p_id;
$this->tiers=""; // id of the field for the tiers to be updated
$this->div=""; // Dom Element to show the search result
}
/*!\brief show the html input of the widget*/
public function input($p_name=null,$p_value=null)
@ -49,7 +50,7 @@ class IConcerned extends HtmlInput
$r=sprintf("
<image onclick=\"search_reconcile(".dossier::id().",'%s','%s','%s','%s')\" class=\"image_search\" src=\"image/magnifier13.png\" />
<image onclick=\"search_reconcile(".dossier::id().",'%s','%s','%s','%s','%s')\" class=\"image_search\" src=\"image/magnifier13.png\" />
<INPUT TYPE=\"text\" style=\"color:black;background:lightyellow;border:solid 1px grey;\" NAME=\"%s\" ID=\"%s\" VALUE=\"%s\" SIZE=\"8\" readonly>
<INPUT class=\"smallbutton\" TYPE=\"button\" onClick=\"$('%s').value=''\" value=\"X\">
@ -58,6 +59,7 @@ class IConcerned extends HtmlInput
$this->name,
$this->amount_id,
$this->paid,
$this->div,
$this->tiers,
$this->name,
$this->id,

View file

@ -207,6 +207,7 @@ if ($aRap != null ) {
if ( $access=='W') {
$wConcerned=new IConcerned("rapt".$div);
$wConcerned->amount_id=$obj->det->jr_montant;
$wConcerned->div="search_reconcile";
echo $wConcerned->input();
}