[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 01/01: Task #1117 - Problème dans le PCMN po
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 01/01: Task #1117 - Problème dans le PCMN pour modification du poste 4891 Correction pour Bug #1117,1106 et 1094. Problème avec le Plan Comptable |
Date: |
Fri, 15 May 2015 11:39:51 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 1080acfa470a91376484b316918a71c923886fab
Author: Dany De Bontridder <address@hidden>
Date: Fri May 15 13:33:49 2015 +0200
Task #1117 - Problème dans le PCMN pour modification du poste 4891
Correction pour Bug #1117,1106 et 1094.
Problème avec le Plan Comptable
---
html/ajax_misc.php | 3 +
html/index.php | 12 ++-
html/js/accounting_item.js | 90 ++++++++++++-------
include/ajax_pcmn_update.php | 95 +++++++++++++++++++
include/param_pcmn.inc.php | 185 ++++++++++++++++----------------------
include/template/pcmn_update.php | 55 +++++++++++
6 files changed, 296 insertions(+), 144 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index dd10f61..b6eb0ea 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -90,6 +90,9 @@ if ( LOGINPUT)
}
switch ($op)
{
+ case 'pcmn_update':
+ require 'ajax_pcmn_update.php';
+ return;
case "remove_anc":
if ($g_user->check_module('ANCODS') == 0)
exit();
diff --git a/html/index.php b/html/index.php
index e78a49c..89a9dca 100644
--- a/html/index.php
+++ b/html/index.php
@@ -42,6 +42,10 @@
* <li>Dans le répertoire include: Les noms de fichiers sont *.php pour les
fichiers contenant des fonctions uniquement</li>
* <li>Dans le répertoire include: Les noms de fichier sont
* class_*.php pour les fichiers contenant des classes.</li>
+ * <li>Dans le répertoire include: Les noms de fichier ajax* correspondent aux
fichiers appelé par une fonction javascript en ajax,
+ * normalement le nom de fichier est basé sur le nom de la fonction javascript
+ * exemple pour la fonction javascript anc_key_choice le fichier correspondant
est
+ * ajax_anc_key_choice.php
* <li>Dans le répertoire include/template: les fichiers de
* présentation HTML </li>
* <li>Utiliser sql/upgrade.sql comme fichier temporaire pour modifier la base
de données, en général
@@ -90,6 +94,10 @@
* <li>In the folder include: filenames end by *.php if they contains only
function</li>
* <li>In the folder include: filenames starting with
* class_*.php if it is related to a class.</li>
+ * <li>In the folder include, files starting with ajax are executed by ajax
call, usually, the file name is
+ * based on the javascript function, example for the javascript function
anc_key_choice the corresponding file is
+ * ajax_anc_key_choice.php
+ *
* <li>In the folder include/template: files for the HTML presentation
* </li>
* <li>Use sql/upgrade.sql as temporary file to modify the database,this file
will be the base for a SQL patch
@@ -101,13 +109,13 @@
* \section advice Advices
* <p>
* Use this document, it is generated automatically by doxygen, check the
documentation your made, read it first this
- * documentation before making change
+ * documentation before making changes
* <ul>
* <li>Related contains all the \\todo</li>
* <li>Global -> all the functions</li>
* <li>check into mod1.html and account_repository.html for the database design
*</ul>
- * You need to know only this tags
+ * You need to know only these tags
* <ul>
* <li> \\file in the beginning of a file</li>
* <li> \\todo add a todo </li>
diff --git a/html/js/accounting_item.js b/html/js/accounting_item.js
index 22518f6..d27eac9 100644
--- a/html/js/accounting_item.js
+++ b/html/js/accounting_item.js
@@ -40,36 +40,58 @@ function set_jrn_parent(p_ctl,p_value)
}
}
/**
- * Display a box with accounting detail for update, delete or add
- * @param {type} p_value pcmn_val
- * @param {type} p_lib pcmn_lib
- * @param {type} p_parent pcmn_val_parent
- * @param {type} p_type pcmn_val_type
- * @param {type} p_dossier gDossier
- * @param {type} p_top position of the box
- * @param {type} p_action = new | update | delete
- * @returns {undefined}
+ address@hidden Display a box with accounting detail for update, delete or
add, update the
+ * table account_tbl_id
+ address@hidden p_dossier dossier id
+ address@hidden p_val value of the accounting, it is used to compute the row id
*/
-
-function PcmnUpdate(p_value,p_lib,p_parent,p_type,p_dossier,p_top,p_action)
+function pcmn_update(p_dossier, p_val)
{
- $('p_valu').value=p_value;
- $('p_oldu').value=p_value;
- $('p_libu').value=p_lib;
- $('p_parentu').value=p_parent;
- $('p_typeu').value=p_type;
- var i=0;
- for (i=0;i < $('p_typeu').options.length;i++) {
- if ($('p_typeu').options[i].value== p_type)
{$('p_typeu').options.selectedIndex= i; break; }
- }
- $('p_typeu').options.selectedIndex=p_type;
- $('acc_update').style.top=(posY+offsetY+p_top)+"px";
- $('acc_update').style.left="10%";
- $('acc_update').style.width="80%";
- $('acc_update_info').innerHTML="";
- $('p_action').value=p_action;
- $('delete_acc').checked=false;
- $('acc_update').show();
+ var query = {gDossier: p_dossier, value: p_val, op: 'pcmn_update'};
+ waiting_box();
+ var action = new Ajax.Request('ajax_misc.php',
+ {
+ method: 'get',
+ parameters: query,
+ onSuccess: function (req)
+ {
+ try
+ {
+ remove_waiting_box();
+ var answer = req.responseXML;
+ var a = answer.getElementsByTagName('ctl');
+ var html = answer.getElementsByTagName('code');
+ var status= answer.getElementsByTagName('status');
+
+ if (a.length == 0)
+ {
+ var rec = req.responseText;
+ alert('erreur :' + rec);
+ }
+
+ var name_ctl = getNodeText(a[0]);
+ var code_html = getNodeText(html[0]);
+ var result = getNodeText(status[0]);
+ $('acc_update').innerHTML=code_html;
+ $('acc_update').setStyle('top:'+calcy(150)+'px');
+ $('acc_update').show();
+ }
+ catch (e)
+ {
+ error_message(e.message);
+ }
+ try
+ {
+ code_html.evalScripts();
+ }
+ catch (e)
+ {
+ alert("Impossible executer script de la reponse\n" +
e.message);
+ }
+
+ }
+ }
+ );
}
/**
address@hidden show the popup for search an accounting item
@@ -277,10 +299,9 @@ function pausecomp(millis)
/**
* Update an accounting with the information in the form, called frmo
* param_pcmn.inc.php
- * @param {type} p_obj_id id of the form
* @returns false
*/
-function account_update(p_obj_id)
+function pcmn_save()
{
try {
waiting_box();
@@ -294,9 +315,10 @@ function account_update(p_obj_id)
var form=$('acc_update_frm_id');
var notfound="not found:";
var p_typeu=-1;
+ var acc_delete=0;
// get them
if ( form['gDossier']) { gDossier=form['gDossier'].value;}else {
notfound+='gDossier';}
- if ( form['p_action']) { action=form['p_action'].value;}else {
notfound+=', p_action ';}
+ if ( form['p_action']) { p_action=form['p_action'].value;}else {
notfound+=', p_action ';}
if ( form['p_oldu']) { p_oldu=form['p_oldu'].value;}else {
notfound+=', p_oldu';}
if ( form['p_valu']) { p_valu=form['p_valu'].value;}else {
notfound+=', p_valu';}
if ( form['p_libu']) { p_libu=form['p_libu'].value;}else {
notfound+=', p_libu ';}
@@ -311,7 +333,7 @@ function account_update(p_obj_id)
if ( notfound != "not found:") throw notfound;
- var queryString = "op=account_update" + "&gDossier=" + gDossier+
"&action=" + action + "&p_oldu=" +
p_oldu+"&p_valu="+p_valu+"&p_libu="+p_libu+"&p_parentu="+p_parentu+"&acc_delete="+acc_delete+"&p_typeu="+p_typeu;
+ var
queryString={op:'account_update',action:p_action,gDossier:gDossier,p_oldu:p_oldu,p_valu:p_valu,p_libu:p_libu,p_parentu:p_parentu,acc_delete:acc_delete,p_typeu:p_typeu};
var ajax_action = new Ajax.Request(
"ajax_misc.php",
{
@@ -321,9 +343,9 @@ function account_update(p_obj_id)
onSuccess: function(req, json) {
try
{
+ remove_waiting_box();
var name_ctl = 'acc_update_info';
var answer = req.responseXML;
- remove_waiting_box();
var html = answer.getElementsByTagName('code');
var ctl =
answer.getElementsByTagName('ctl')[0].textContent;
if (html.length == 0) {
@@ -334,7 +356,7 @@ function account_update(p_obj_id)
code_html = unescape_xml(code_html);
$(name_ctl).innerHTML = code_html;
- if ( ctl == 'ok') {
+ if ( ctl == 'ok') {
window.location.reload();
}
} catch (e)
diff --git a/include/ajax_pcmn_update.php b/include/ajax_pcmn_update.php
new file mode 100644
index 0000000..de4d80d
--- /dev/null
+++ b/include/ajax_pcmn_update.php
@@ -0,0 +1,95 @@
+<?php
+/*
+ * This file is part of NOALYSS.
+ *
+ * NOALYSS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * NOALYSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with NOALYSS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// Copyright 2015 Author Dany De Bontridder address@hidden
+
+// require_once '.php';
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+
+global $g_user, $cn, $g_parameter;
+
+// Security check if user can connect and update
+if ($g_user->check_module('CFGPCMN') == 0 )
+{
+ $html=h2(_('Action interdite'),' class="notice"');
+ $html = escape_xml($response);
+
+ header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl>pcmn_update</ctl>
+<code>$html</code>
+<status>NOTALLOWED</status>
+</data>
+EOF;
+ return;
+}
+
+ob_start();
+$pcmn_val=HtmlInput::default_value_get('value', "-1");
+
+// if empty
+if ( $pcmn_val != "-1" )
+{
+ // not set
+
+}
+$action='new';
+$val=new IText('p_valu');
+$parent=new IText('p_parentu');
+$lib=new IText('p_libu');
+$lib->css_size="100%";
+$type=new ISelect('p_typeu');
+$type->value=Acc_Account::$type;
+
+if ( $pcmn_val != "")
+{
+ $action='update';
+ /*
+ * Not empty, show the default value
+ */
+ $account = new Acc_Account($cn);
+ $account->set_parameter('value',$pcmn_val);
+ $account->load();
+
+ $val->value=$account->get_parameter('value');
+ $parent->value=$account->get_parameter('parent');
+ $lib->value=$account->get_parameter('libelle');
+ $type->selected=$account->get_parameter('type');
+
+}
+
+require 'template/pcmn_update.php';
+$response = ob_get_clean();
+$html = escape_xml($response);
+if ( headers_sent() ) {
+ echo $response;
+ echo $html;
+} else {
+ header('Content-type: text/xml; charset=UTF-8');
+ echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl></ctl>
+<code>$html</code>
+<status>ok</status>
+</data>
+EOF;
+ }
\ No newline at end of file
diff --git a/include/param_pcmn.inc.php b/include/param_pcmn.inc.php
index 453fc9f..1164b3d 100644
--- a/include/param_pcmn.inc.php
+++ b/include/param_pcmn.inc.php
@@ -37,54 +37,22 @@ $cn=new Database($gDossier);
include_once ("class_user.php");
include_once ("user_menu.php");
-
-echo '<div id="acc_update" class="inner_box"
style="display:none;position:absolute;text-align:left;z-index:1">';
-echo HtmlInput::title_box("Poste comptable", "acc_update", "hide");
-echo '<span id="acc_update_info" class="notice"></span>';
-echo '<form method="post" id="acc_update_frm_id"
onsubmit="account_update(\'acc_update_frm_id\');return false;">';
-$val=new IText('p_valu');
-$parent=new IText('p_parentu');
-$lib=new IText('p_libu');
-$lib->css_size="100%";
-$type=new ISelect('p_typeu');
-$type->value=Acc_Account::$type;
-echo '<table>';
-$r= td(_('Poste comptable')).td($val->input());
-echo tr($r);
-$r= td(_('Description')).td($lib->input());
-echo tr($r);
-$r= td(_('Parent')).td($parent->input());
-echo tr($r);
-$r= td(_('Type ')).td($type->input());
-echo tr($r);
-echo '</table>';
-echo HtmlInput::hidden('p_oldu','');
-echo HtmlInput::hidden('p_action','');
-echo dossier::hidden();
-$checkbox=new ICheckBox("delete_acc");
-echo _('Cocher pour effacer')." ".$checkbox->input();
-echo '<hr>';
-echo HtmlInput::submit('update',_('Sauve'));
-echo
HtmlInput::button('hide',_('Annuler'),'onClick="$(\'acc_update\').hide();return
true;"');
-echo '</form>';
-echo '</div>';
-
-
+echo '<div id="acc_update" class="inner_box"
style="display:none;position:absolute;text-align:left;z-index:1"></div>';
/* Store the p_start parameter */
-$g_start=HtmlInput::default_value_get('p_start',-1);
-echo '<div class="u_subtmenu">';
-
-echo '</div>';
+$g_start=HtmlInput::default_value_get('p_start',1);
+?>
-echo '<div class="content">';
-menu_acc_plan($g_start);
-echo '</div>';
-if ($g_start == -1) return;
-echo '<DIV CLASS="myfieldset" style="width:auto">';
+<div class="content">
+<?php
+ menu_acc_plan($g_start);
+?>
+</div>
+<DIV CLASS="myfieldset" style="width:auto">
+<?php
$Ret=$cn->exec_sql("select
pcm_val,pcm_lib,pcm_val_parent,pcm_type,array_to_string(array_agg(j_qcode) ,
',') as acode
from tmp_pcmn left join vw_poste_qcode on (j_poste=pcm_val) where
substr(pcm_val::text,1,1)='".$g_start."'".
" group by pcm_val,pcm_lib,pcm_val_parent, pcm_type order by
pcm_val::text");
@@ -92,10 +60,9 @@ $MaxRow=Database::num_row($Ret);
?>
<span style="display:inline;margin: 15px 15px 15px 15px">
-<input type="button" class="smallbutton"
onclick="PcmnUpdate('','','','',0,0,'new')" value="<?php echo _('Ajout poste
comptable'); ?>">
+<input type="button" id="pcmn_update_add_bt" class="smallbutton" value="<?php
echo _('Ajout poste comptable'); ?>">
</span>
<?php echo _('Filtre')." ".HtmlInput::filter_table("account_tbl_id",
"0,1,2,3,4", 1);?>
-<FORM METHOD="POST">
<?php
echo HtmlInput::hidden('p_action','pcmn');
//echo HtmlInput::hidden('sa','detail');
@@ -103,76 +70,78 @@ echo dossier::hidden();
$limite=MAX_QCODE;
?>
<TABLE id="account_tbl_id" class="result">
- <TR>
- <TH> Poste comptable </TH>
- <TH> Libellé </TH>
- <TH> Poste comptable Parent </TH>
- <TH> Type </TH>
- <TH> Fiche</TH>
- </TR>
+ <TR>
+ <TH> <?php echo _('Poste comptable') ?> </TH>
+ <TH> <?php echo _('Libellé') ?> </TH>
+ <TH> <?php echo _('Poste comptable Parent') ?> </TH>
+ <TH> <?php echo _('Type') ?> </TH>
+ <TH> <?php echo _('Fiche') ?></TH>
+ </TR>
- <?php
- $str_dossier=dossier::get();
-for ($i=0; $i <$MaxRow; $i++)
-{
+<?php
+$str_dossier=dossier::id();
+for ($i=0; $i <$MaxRow; $i++):
$A=Database::fetch_array($Ret,$i);
+ $class=( $i%2 == 0 )?"even":"odd";
- if ( $i%2 == 0 )
- {
- $td ='<TD class="odd">';
- $tr ='<TR class="odd">';
- }
- else
- {
- $td='<TD class="even">';
- $tr='<TR class="even">';
- }
- echo $tr;
- echo "$td";
- echo HtmlInput::history_account($A['pcm_val'], $A['pcm_val']);
- echo '</td>';
- echo "$td";
- printf ("<A style=\"text-decoration:underline\"
HREF=\"javascript:void(0)\"
onclick=\"PcmnUpdate('%s','%s','%s','%s',%d,0,'update')\">",
- str_replace("'","\'",$A['pcm_val']),
- str_replace("'","\'",$A['pcm_lib']),
- str_replace("'","\'",$A['pcm_val_parent']),
- str_replace("'","\'",$A['pcm_type']),
- dossier::id());
+?>
+ <tr id="row_<?php echo $A['pcm_val']?>" class="<?php echo $class;?>">
+ <td class="<?php echo $class;?>">
+ <?php
+ echo HtmlInput::history_account($A['pcm_val'], $A['pcm_val']);
+ ?>
+ </td>
+ <td class="<?php echo $class;?>">
+ <?php
+ printf ("<A style=\"text-decoration:underline\"
HREF=\"javascript:void(0)\" onclick=\"pcmn_update(%d,'%s')\">",
+ $str_dossier, $A['pcm_val']);
echo h($A['pcm_lib']);
-
- echo $td;
- echo $A['pcm_val_parent'];
- echo '</TD>';
- echo "</td>$td";
- echo $A['pcm_type'];
- echo "</TD>";
-
- echo $td;
- if ( strlen($A['acode']) >0 ) {
- if (strpos($A['acode'], ",") >0 ) {
- $det_qcode= explode(",", $A['acode']);
- echo '<ul
style="display:inline;paddding:0;margin:0px;padding-left:0px;list-style-type:none;padding-start-value:0px">';
-
$max=(count($det_qcode)>MAX_QCODE)?MAX_QCODE:count($det_qcode);
- for ($e=0;$e<$max;$e++) {
- echo '<li
style="padding-start-value:0;display:inline">'.HtmlInput::card_detail($det_qcode[$e],'','
style="display:inline"').'</li>';
- }
- echo '</ol>';
- if ($max < count($det_qcode)) {
- echo "...";
- }
- } else {
+ ?>
+ </td>
+ <td class="<?php echo $class;?>">
+ <?php echo $A['pcm_val_parent']; ?>
+ </TD>
+ <td class="<?php echo $class;?>">
+ <?php echo $A['pcm_type'];?>
+ </TD>
+ <td class="<?php echo $class;?>">
+ <?php
+ if ( strlen($A['acode']) >0 ) :
+ if (strpos($A['acode'], ",") >0 ) :
+ $det_qcode= explode(",", $A['acode']);
+ echo '<ul
style="display:inline;paddding:0;margin:0px;padding-left:0px;list-style-type:none;padding-start-value:0px">';
+ $max=(count($det_qcode)>MAX_QCODE)?MAX_QCODE:count($det_qcode);
+ for ($e=0;$e<$max;$e++) :
+ echo '<li
style="padding-start-value:0;margin:2px;display:inline">'.HtmlInput::card_detail($det_qcode[$e],'','
style="display:inline"').'</li>';
+ endfor;
+ echo '</ol>';
+ if ($max < count($det_qcode)) :
+ echo "...";
+ else :
echo HtmlInput::card_detail($A['acode']);
- }
- }
- echo '</td>';
-
- echo "</TR>";
-}
-echo "</TABLE>";
-echo "</FORM>";
+ endif;
+ endif;
+ endif;
+ ?>
+ </td>
+ </tr>
+<?php
+endfor;
?>
- <input type="button" class="smallbutton"
onclick="PcmnUpdate('','','','',0,-230,'new')" value="<?php echo _('Ajout poste
comptable'); ?>">
+</TABLE>
+
+ <input type="button" id="pcmn_update_add_bt2" class="smallbutton"
value="<?php echo _('Ajout poste comptable'); ?>">
+ </div>
+ <script>
+ $('pcmn_update_add_bt').onclick = function ()
+ {
+ pcmn_update(<?php echo Dossier::id()?>,'');
+ }
+ $('pcmn_update_add_bt2').onclick = function ()
+ {
+ pcmn_update(<?php echo Dossier::id()?>,'');
+ }
+</script>
<?php
-echo "</DIV>";
html_page_stop();
?>
diff --git a/include/template/pcmn_update.php b/include/template/pcmn_update.php
new file mode 100644
index 0000000..6a8ddb3
--- /dev/null
+++ b/include/template/pcmn_update.php
@@ -0,0 +1,55 @@
+<?php
+/*
+ * This file is part of PhpCompta.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+// Copyright (2014) Author Dany De Bontridder <address@hidden>
+
+if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief
+ * @param type $name Descriptionara
+ */
+echo HtmlInput::title_box("Poste comptable", "acc_update", "hide");
+?>
+<span id="acc_update_info" class="notice"></span>
+<form method="post" id="acc_update_frm_id" onsubmit="pcmn_save();return
false;">
+
+<table style="width:100%">
+<?php
+$r= td(_('Poste
comptable'),'style="width:20em;width:15rem;text-align:right"').td($val->input());
+echo tr($r);
+$r=
td(_('Description'),'style="width:auto;text-align:right"').td($lib->input());
+echo tr($r);
+$r= td(_('Parent'),'style="width:auto;text-align:right"').td($parent->input());
+echo tr($r);
+$r= td(_('Type'),'style="width:auto;text-align:right"').td($type->input());
+echo tr($r);
+?>
+</table>
+<?php
+echo HtmlInput::hidden('p_oldu',$pcmn_val);
+echo HtmlInput::hidden('p_action',$action);
+echo dossier::hidden();
+$checkbox=new ICheckBox("delete_acc");
+echo _('Cocher pour effacer')." ".$checkbox->input();
+echo '<hr>';
+echo HtmlInput::submit('update',_('Sauve'));
+echo
HtmlInput::button('hide',_('Annuler'),'onClick="$(\'acc_update\').hide();return
true;"');
+?>
+</form>
\ No newline at end of file