Task #986 - Mise à jour automatique du field Bénéficiaire lorsqu'un montant est lettré dans Import Banque & Trésorerie

Update fields supplier or customer with the person who makes the payment
+ new function select_depot for #1055
This commit is contained in:
Dany De Bontridder 2014-11-25 19:55:56 +01:00
parent c21889921f
commit cacd6f2e21
7 changed files with 67 additions and 12 deletions

View file

@ -1190,11 +1190,18 @@ function save_predf_op(obj)
return false;
}
/**
*ctl_concern is the widget to update
*amount_id is either a html obj. or an amount
*amount_id is either a html obj. or an amount and the field tiers if given
* @param {type} dossier
* @param {type} ctl_concern
* @param {type} amount_id
* @param {type} ledger
* @param {type} p_id_target
* @returns {undefined}
*/
function search_reconcile(dossier, ctl_concern, amount_id, ledger)
function search_reconcile(dossier, ctl_concern, amount_id, ledger,p_id_target)
{
var dossier = g('gDossier').value;
if (amount_id === undefined)
@ -1227,7 +1234,8 @@ function search_reconcile(dossier, ctl_concern, amount_id, ledger)
ctl: target,
ac: 'JSSEARCH',
amount_id: amount_id,
ledger: ledger};
ledger: ledger,
target : p_id_target};
var qs = encodeJSON(target);
@ -1272,14 +1280,20 @@ function search_operation(obj)
alert(e.message);
}
}
/**
* Update the field e_concerned, from class_iconcerned
* Value is the field where to put the quick-code but only if one checkbox has been
* selected
* @param {type} obj
* @returns {undefined}
*/
function set_reconcile(obj)
{
try
{
var ctlc = obj.elements['ctlc'];
var target=obj.elements['target'].value;
for (var e = 0; e < obj.elements.length; e++)
{
@ -1292,6 +1306,11 @@ function set_reconcile(obj)
var nValue = str_name.replace("jr_concerned", "");
if ($(ctlc.value).value != '') {
$(ctlc.value).value += ',';
} else {
if ( target !="" && $(target).value == "") {
$(target).value=elmt.value;
}
}
$(ctlc.value).value += nValue;
}

View file

@ -626,7 +626,7 @@ class Acc_Ledger extends jrn_def_sql
* @return HTML string
*/
public function list_operation_to_reconcile($sql)
public function list_operation_to_reconcile($sql,$p_target)
{
global $g_parameter, $g_user;
$gDossier = dossier::id();
@ -650,7 +650,7 @@ class Acc_Ledger extends jrn_def_sql
if ($Max == 0)
return array(0, _("Aucun enregistrement trouvé"));
$r.=HtmlInput::hidden("target", $p_target);
$r.='<table class="result">';
@ -689,7 +689,7 @@ class Acc_Ledger extends jrn_def_sql
// Radiobox
//
$r.='<td><INPUT TYPE="CHECKBOX" name="jr_concerned' . $row['jr_id'] . '" ID="jr_concerned' . $row['jr_id'] . '"> </td>';
$r.='<td><INPUT TYPE="CHECKBOX" name="jr_concerned' . $row['jr_id'] . '" ID="jr_concerned' . $row['jr_id'] . '" value="'.$row['quick_code'].'"> </td>';
//internal code
// button modify
$r.="<TD>";
@ -3825,6 +3825,37 @@ class Acc_Ledger extends jrn_def_sql
$lib=$this->db->get_value('select pcm_lib from tmp_pcmn where pcm_val=$1',array($p_value));
return $lib;
}
/**
* Let you select the repository before confirming a sale or a purchase.
* Returns an empty string if the company doesn't use stock
* @brief Let you select the repository before confirming a sale or a purchase.
* @global type $g_parameter check if company is using stock
* @param type $p_readonly
* @param type $p_repo
* @return string
*/
public function select_depot($p_readonly, $p_repo)
{
global $g_parameter;
$r='<div id="repo_div_id">';
// Show the available repository
if ($g_parameter->MY_STOCK=='Y')
{
$sel=HtmlInput::select_stock($this->db, 'repo', 'W');
$sel->readOnly=$p_readonly;
if ($p_readonly==true)
$sel->selected=$p_repo;
$r.="<p class=\"decale\">"._('Dans le dépôt')." : ";
$r.=$sel->input();
$r.='</p>';
} else
{
$r.='<span class="notice">'.'Stock non utilisé'.'</span>';
}
$r.='</div>';
return $r;
}
}
?>

View file

@ -431,6 +431,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
${"e_concerned" . $i} = (isset(${"e_concerned" . $i})) ? ${"e_concerned" . $i} : ""
;
$wConcerned = new IConcerned("e_concerned" . $i, ${"e_concerned" . $i});
$wConcerned->tiers="e_other" . $i;
$wConcerned->setReadOnly($pview_only);
$wConcerned->amount_id = "e_other" . $i . "_amount";

View file

@ -36,6 +36,7 @@ class IConcerned extends HtmlInput
$this->amount_id=null;
$this->paid='';
$this->id=$p_id;
$this->tiers=""; // id of the field for the tiers to be updated
}
/*!\brief show the html input of the widget*/
public function input($p_name=null,$p_value=null)
@ -48,7 +49,8 @@ class IConcerned extends HtmlInput
$r=sprintf("
<INPUT TYPE=\"button\" class=\"smallbutton\" onClick=\"search_reconcile(".dossier::id().",'%s','%s','%s')\" value=\"?\">
<image onclick=\"search_reconcile(".dossier::id().",'%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\">
@ -56,6 +58,7 @@ class IConcerned extends HtmlInput
$this->name,
$this->amount_id,
$this->paid,
$this->tiers,
$this->name,
$this->id,
$this->value,

View file

@ -107,7 +107,8 @@ if ( isset ($_GET['viewsearch']) )
list($sql,$where)=$ledger->build_search_sql($array);
// Count nb of line
$max_line=$cn->count_sql($sql);
list($count,$content)=$ledger->list_operation_to_reconcile($sql);
$target=HtmlInput::default_value_get("target", "");
list($count,$content)=$ledger->list_operation_to_reconcile($sql,$target);
$bar=navigation_bar($offset,$max_line,$step,$page);
if (! $inside ) {

View file

@ -10,7 +10,7 @@
<?php $class=($i%2==0)?'odd':'even';?>
<tr class="<?php echo $class;?>">
<td style="padding-right:55px">
<a href="javascript:void(0)" class="one" onclick="<?php echo $array[$i]['javascript']?>">
<a href="javascript:void(0)" class="detail" onclick="<?php echo $array[$i]['javascript']?>">
<?php echo $array[$i]['quick_code']?>
</a>
</td>

View file

@ -19,7 +19,7 @@ for ($i=0;$i<count($aHeading);$i++) :
$span='<span id="sorttable_sortfwdind">&nbsp;&nbsp;&#x25BE;</span>';
$sort= 'class="sorttable_sorted"';
}
echo '<th style="color:blue;padding: 0 5 1 10" '.$sort.'>'.$aHeading[$i]->ad_text.$span.'</th>';
echo '<th '.$sort.'>'.$aHeading[$i]->ad_text.$span.'</th>';
endfor;
?>
</tr>