Task #1236 - Ajout d'une pièce jointe dands le rapprochement (COMPTA/MENUFIN/FREC)
#1236 : ajout d'une pièce pour les réconciliations bancaires + indication de ce qui est sélectionné
This commit is contained in:
parent
a6de3a8761
commit
f49c313ed2
8 changed files with 192 additions and 46 deletions
|
|
@ -301,7 +301,7 @@ case 'loadfile':
|
|||
$cn->start();
|
||||
// remove the file
|
||||
$grpt=$cn->get_value('select jr_grpt_id from jrn where jr_id=$1',array($jr_id));
|
||||
$cn->save_upload_document($grpt);
|
||||
$cn->save_receipt($grpt);
|
||||
$cn->commit();
|
||||
// Show a link to the new file
|
||||
$op->get();
|
||||
|
|
|
|||
|
|
@ -2140,7 +2140,7 @@ class Acc_Ledger extends jrn_def_sql
|
|||
*/
|
||||
if (isset($_FILES["pj"]))
|
||||
{
|
||||
$this->db->save_upload_document($seq);
|
||||
$this->db->save_receipt($seq);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -941,7 +941,7 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
// first record we upload the files and
|
||||
// keep variable to update other row of jrn
|
||||
if (isset($_FILES))
|
||||
$oid = $this->db->save_upload_document($seq);
|
||||
$oid = $this->db->save_receipt($seq);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -795,7 +795,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
|
|||
if ( isset ($_FILES))
|
||||
{
|
||||
if ( sizeof($_FILES) != 0 )
|
||||
$this->db->save_upload_document($seq);
|
||||
$this->db->save_receipt($seq);
|
||||
}
|
||||
$str_file="";
|
||||
/* Generate an document and save it into the database (Note de frais only)
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
|
|||
/* Save the attachment or generate doc */
|
||||
if (isset($_FILES['pj'])) {
|
||||
if (strlen(trim($_FILES['pj']['name'])) != 0)
|
||||
$this->db->save_upload_document($seq);
|
||||
$this->db->save_receipt($seq);
|
||||
else
|
||||
/* Generate an invoice and save it into the database */
|
||||
if (isset($_POST['gen_invoice'])) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,68 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
|||
global $g_failed,$g_succeed;
|
||||
require_once NOALYSS_INCLUDE.'/class/class_acc_ledger_fin.php';
|
||||
bcscale(2);
|
||||
?>
|
||||
<script>
|
||||
function update_selected(p_node,p_amount) {
|
||||
try {
|
||||
if (p_node.checked )
|
||||
{
|
||||
var selected=parseFloat($('selected_amount').innerHTML)+p_amount;
|
||||
$('selected_amount').innerHTML=Math.round(selected*100)/100;
|
||||
} else {
|
||||
var selected=parseFloat($('selected_amount').innerHTML)-p_amount;
|
||||
$('selected_amount').innerHTML=Math.round(selected*100)/100;
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
if (console) {console.error('update_selected :'+e.message);}
|
||||
}
|
||||
}
|
||||
function update_remain(p_node,p_amount) {
|
||||
try {
|
||||
if ( parseFloat($('delta_amount').innerHTML) == 0) return;
|
||||
if (p_node.checked )
|
||||
{
|
||||
var selected=parseFloat($('remain_amount').innerHTML)-p_amount;
|
||||
$('remain_amount').innerHTML=Math.round(selected*100)/100;
|
||||
} else {
|
||||
var selected=parseFloat($('remain_amount').innerHTML)+p_amount;
|
||||
$('remain_amount').innerHTML=Math.round(selected*100)/100;
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
if (console) {console.error('update_remain :'+e.message);}
|
||||
|
||||
}
|
||||
}
|
||||
function update_delta() {
|
||||
try {
|
||||
var delta=parseFloat($('end_extrait').value)-parseFloat($('start_extrait').value);
|
||||
delta=Math.round(delta*100)/100;
|
||||
$('delta_amount').innerHTML=delta;
|
||||
var remain=delta-parseFloat($('selected_amount').innerHTML);
|
||||
$('remain_amount').innerHTML=Math.round(remain*100)/100;
|
||||
} catch(e) {
|
||||
if (console) {console.error('update_delta :' +e.message);}
|
||||
}
|
||||
}
|
||||
function recompute(p_form) {
|
||||
try {
|
||||
var form=$(p_form);
|
||||
var i=0;
|
||||
for (i=0;i<form.length;i++) {
|
||||
var e=form.elements[i];
|
||||
if (e.type=='checkbox') {
|
||||
e.click();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
if (console) {console.error('recompute :' +e.message);}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo '<div class="content">';
|
||||
$Ledger = new Acc_Ledger_Fin($cn, 0);
|
||||
if (!isset($_REQUEST['p_jrn']))
|
||||
|
|
@ -45,6 +107,22 @@ if (isset($_GET["p_jrn"]) && $jrn_priv == "X")
|
|||
NoAccess();
|
||||
return;
|
||||
}
|
||||
$end_extrait=HtmlInput::default_value_post("end_extrait", 0);
|
||||
$start_extrait=HtmlInput::default_value_post("start_extrait", 0);
|
||||
if ( isNumber($end_extrait) == 0 )
|
||||
{
|
||||
echo '<span class="notice">';
|
||||
echo _('Donnée invalide');
|
||||
echo '</span>';
|
||||
$end_extrait=0;
|
||||
}
|
||||
if ( isNumber($start_extrait) == 0 )
|
||||
{
|
||||
echo '<span class="notice">';
|
||||
echo _('Donnée invalide');
|
||||
echo '</span>';
|
||||
$start_extrait=0;
|
||||
}
|
||||
//-------------------------
|
||||
// save
|
||||
//-------------------------
|
||||
|
|
@ -60,7 +138,7 @@ if (isset($_POST['save']))
|
|||
$cn->exec_sql('update jrn set jr_pj_number=$1 where jr_id=$2', array($_POST['ext'], $array[$i]));
|
||||
$tot = bcadd($tot, $cn->get_value('select qf_amount from quant_fin where jr_id=$1', array($array[$i])));
|
||||
}
|
||||
$diff = bcsub($_POST['end_extrait'], $_POST['start_extrait']);
|
||||
$diff = bcsub($end_extrait, $start_extrait);
|
||||
if ($diff != 0 && $diff != $tot)
|
||||
{
|
||||
$remain=bcsub($tot,$diff);
|
||||
|
|
@ -68,11 +146,26 @@ if (isset($_POST['save']))
|
|||
alert("D'après l'extrait il y aurait du avoir un montant de $diff à rapprocher alors qu'il y a $tot rapprochés, mise à jour annulée, la différence est de $remain");
|
||||
echo '<div class="error">';
|
||||
echo '<p>'.$g_failed._("D'après l'extrait il y aurait du avoir un montant de $diff à rapprocher alors qu'il y a $tot rapprochés, la différence est de $remain <br>mise à jour annulée").'</p>';
|
||||
/* if file : warning that file is not uploaded*/
|
||||
echo '<p>'.
|
||||
_('Attention : Fichier non chargé').
|
||||
'</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<div class="content">'.$g_succeed.' Mise à jour extrait '.$_POST['ext'].'</div>';
|
||||
// -- chargement fichier
|
||||
$oid=$cn->upload('file_receipt');
|
||||
|
||||
if ( $oid != false ) {
|
||||
for ($i = 0; $i < count($array); $i++)
|
||||
{
|
||||
$cn->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_id=$4",
|
||||
array($oid,$_FILES['file_receipt']['name'] ,$_FILES['file_receipt']['type'],$array[$i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cn->commit();
|
||||
|
|
@ -97,7 +190,7 @@ echo HtmlInput::submit('ref', 'Rafraîchir');
|
|||
echo '</form>';
|
||||
echo '<span id="bkname" style="display:block">' . hb(h($Ledger->get_bank_name())) . '</span>';
|
||||
|
||||
echo '<form method="post" id="rec1">';
|
||||
echo '<form method="post" id="rec1" enctype="multipart/form-data">';
|
||||
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::get_to_hidden(array('sa', 'p_action', 'p_jrn'));
|
||||
|
|
@ -112,15 +205,22 @@ $operation = $cn->get_array("select jr_id,jr_internal,
|
|||
echo '<p>';
|
||||
$iextrait = new IText('ext');
|
||||
if ( isset ($_POST['ext'])) $iextrait->value=$_POST['ext']; else $iextrait->value = $Ledger->guess_pj();
|
||||
|
||||
$nstart_extrait = new INum('start_extrait');
|
||||
if( isset($_POST['start_extrait'])) $nstart_extrait->value=$_POST['start_extrait'];
|
||||
$nstart_extrait->value=$start_extrait;
|
||||
$nstart_extrait->javascript='onchange="format_number(this,2);update_delta();"';
|
||||
|
||||
$nend_extrait = new INum('end_extrait');
|
||||
if( isset($_POST['end_extrait'])) $nend_extrait->value=$_POST['end_extrait'];
|
||||
$nend_extrait->value=$end_extrait;
|
||||
$nend_extrait->javascript='onchange="format_number(this,2);update_delta();"';
|
||||
|
||||
echo "Extrait / relevé :" . $iextrait->input();
|
||||
echo 'solde Début' . $nstart_extrait->input();
|
||||
echo 'solde Fin' . $nend_extrait->input();
|
||||
echo IButton::tooggle_checkbox('rec1');
|
||||
$select_all=new IButton('select_all');
|
||||
$select_all->label=_('Inverser la sélection');
|
||||
$select_all->javascript="recompute('rec1')";
|
||||
echo $select_all->input();
|
||||
echo '</p>';
|
||||
echo '<p>';
|
||||
echo _('Cherche').HtmlInput::infobulle(25);
|
||||
|
|
@ -141,6 +241,9 @@ echo tr($r);
|
|||
$iradio = new ICheckBox('op[]');
|
||||
$tot_not_reconcilied = 0;
|
||||
$diff = 0;
|
||||
$delta=bcsub($end_extrait,$start_extrait);
|
||||
$selected_amount=0;
|
||||
$remain_amount=$delta;
|
||||
for ($i = 0; $i < count($operation); $i++)
|
||||
{
|
||||
$row = $operation[$i];
|
||||
|
|
@ -156,6 +259,7 @@ for ($i = 0; $i < count($operation); $i++)
|
|||
$tot_not_reconcilied+=$row['jr_montant'];
|
||||
$iradio->value = $row['jr_id'];
|
||||
$iradio->selected=false;
|
||||
$iradio->javascript=sprintf(' onchange = "update_selected(this,%s);update_remain(this,%s)"',$amount,$amount);
|
||||
if (isset($_POST['op']))
|
||||
{
|
||||
for ($x=0;$x<count($_POST['op']);$x++)
|
||||
|
|
@ -163,11 +267,13 @@ for ($i = 0; $i < count($operation); $i++)
|
|||
if ($row['jr_id']==$_POST['op'][$x])
|
||||
{
|
||||
$iradio->selected=true;
|
||||
$selected_amount+=$amount;
|
||||
$remain_amount-=$amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$r.=td(HtmlInput::hidden('jrid['.$i.']', $row['jr_id']) . $iradio->input(), ' style="text-align:center" ');
|
||||
$r.=td(HtmlInput::hidden('jrid['.$i.']', $row['jr_id']) . $iradio->input(), 'sorttable_customkey="1" style="text-align:center" ');
|
||||
if ($i % 2 == 0)
|
||||
echo tr($r, ' class="odd" ');
|
||||
else
|
||||
|
|
@ -186,7 +292,24 @@ $saldo_reconcilied = $bk_card->get_solde_detail($filter_year . " and j_grpt in (
|
|||
|
||||
/* solde compte */
|
||||
$saldo = $bk_card->get_solde_detail($filter_year);
|
||||
|
||||
echo '<div style="float:right;margin-right:100px;font-size:120%;font-weight:bolder">';
|
||||
echo '<table id="total_div_id">';
|
||||
echo '
|
||||
<tr>
|
||||
<td>'._('Différence relevé').'</td>
|
||||
<td id="delta_amount" class="num" >'.$delta.'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>'._('Montant sélectionné').'</td>
|
||||
<td class="num" id="selected_amount">'.$selected_amount.'</td>
|
||||
</tr>
|
||||
<td>'._('Reste à selectionner').'</td>
|
||||
<td class="num" id="remain_amount">'.$remain_amount.'</td>
|
||||
</tr>
|
||||
|
||||
';
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
echo '<table>';
|
||||
echo '<tr>';
|
||||
echo td("Solde compte ");
|
||||
|
|
@ -211,8 +334,13 @@ echo '</tr>';
|
|||
|
||||
echo '</table>';
|
||||
|
||||
$receipt=new IFile('file_receipt');
|
||||
echo $receipt->input();
|
||||
echo '<p class="text-align:center">';
|
||||
echo HtmlInput::submit('save', 'Mettre à jour le n° de relevé bancaire');
|
||||
echo '</p>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
return;
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -808,66 +808,84 @@ class Database
|
|||
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Save a "piece justificative"
|
||||
/***
|
||||
* \brief Save a "piece justificative" , the name must be pj
|
||||
*
|
||||
* \param $seq jr_grpt_id
|
||||
* \return $oid of the lob file if success
|
||||
* null if a error occurs
|
||||
*
|
||||
*/
|
||||
|
||||
function save_upload_document($seq)
|
||||
function save_receipt($seq)
|
||||
{
|
||||
/* there is
|
||||
no file to
|
||||
upload */
|
||||
if ($_FILES["pj"]["error"]==UPLOAD_ERR_NO_FILE)
|
||||
$oid=$this->upload('pj');
|
||||
if ($oid==false)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Remove old document
|
||||
$ret=$this->exec_sql("select jr_pj from jrn where jr_grpt_id=$seq");
|
||||
if (pg_num_rows($ret)!=0)
|
||||
{
|
||||
$r=pg_fetch_array($ret, 0);
|
||||
$old_oid=$r['jr_pj'];
|
||||
if (strlen($old_oid)!=0)
|
||||
pg_lo_unlink($cn, $old_oid);
|
||||
}
|
||||
// Load new document
|
||||
$this->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_grpt_id=$4",
|
||||
array($oid,$_FILES['pj']['name'] ,$_FILES['pj']['type'],$seq));
|
||||
return $oid;
|
||||
}
|
||||
/***
|
||||
* \brief Save a document into the database , it just puts the file in the database
|
||||
* and returns the corresponding OID , the mimetype , size ... of the document
|
||||
* must be set in the calling function.
|
||||
*
|
||||
* \param name of the variable in $_FILES
|
||||
* \return $oid of the lob file if success
|
||||
* false if a error occurs or if there is no file to upload
|
||||
*
|
||||
*/
|
||||
|
||||
function upload($p_name)
|
||||
{
|
||||
/* there is no file to upload */
|
||||
if ($_FILES[$p_name]["error"]==UPLOAD_ERR_NO_FILE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_name=tempnam($_ENV['TMP'], 'pj');
|
||||
if ($_FILES["pj"]["error"]>0)
|
||||
$new_name=tempnam($_ENV['TMP'], $p_name);
|
||||
if ($_FILES[$p_name]["error"]>0)
|
||||
{
|
||||
print_r($_FILES);
|
||||
echo_error(__FILE__.":".__LINE__."Error: ".$_FILES["pj"]["error"]);
|
||||
echo_error(__FILE__.":".__LINE__."Error: ".$_FILES[$p_name]["error"]);
|
||||
return false;
|
||||
}
|
||||
if (strlen($_FILES['pj']['tmp_name'])!=0)
|
||||
if (strlen($_FILES[$p_name]['tmp_name'])!=0)
|
||||
{
|
||||
if (move_uploaded_file($_FILES['pj']['tmp_name'], $new_name))
|
||||
if (move_uploaded_file($_FILES[$p_name]['tmp_name'], $new_name))
|
||||
{
|
||||
// echo "Image saved";
|
||||
$oid=pg_lo_import($this->db, $new_name);
|
||||
if ($oid==false)
|
||||
{
|
||||
echo_error('postgres.php', __LINE__, "cannot upload document");
|
||||
echo_error(__FILE__, __LINE__, "cannot upload document");
|
||||
$this->rollback();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// Remove old document
|
||||
$ret=$this->exec_sql("select jr_pj from jrn where jr_grpt_id=$seq");
|
||||
if (pg_num_rows($ret)!=0)
|
||||
{
|
||||
$r=pg_fetch_array($ret, 0);
|
||||
$old_oid=$r['jr_pj'];
|
||||
if (strlen($old_oid)!=0)
|
||||
pg_lo_unlink($cn, $old_oid);
|
||||
}
|
||||
// Load new document
|
||||
$this->exec_sql("update jrn set jr_pj=$1 , jr_pj_name=$2,
|
||||
jr_pj_type=$3 where jr_grpt_id=$4",
|
||||
array($oid,$_FILES['pj']['name'] ,$_FILES['pj']['type'],$seq));
|
||||
return $oid;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<H1>Error</H1>";
|
||||
$this->rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**\brief wrapper for the function pg_NumRows
|
||||
|
|
|
|||
|
|
@ -378,10 +378,10 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Database::save_upload_document
|
||||
* @todo Implement testSave_upload_document().
|
||||
* @covers Database::save_receipt
|
||||
* @todo Implement testsave_receipt().
|
||||
*/
|
||||
public function testSave_upload_document()
|
||||
public function testsave_receipt()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue