[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 101/219: Réécriture de CFGPCMN pour utiliser
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 101/219: Réécriture de CFGPCMN pour utiliser ManageTable |
Date: |
Mon, 18 Dec 2017 13:22:45 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 73c99f6c6e67672206c095d1541299069573997e
Author: Dany De Bontridder <address@hidden>
Date: Mon Oct 23 20:09:37 2017 +0200
Réécriture de CFGPCMN pour utiliser ManageTable
---
html/ajax_misc.php | 4 +-
html/js/managetable.js | 2 +-
include/ajax/ajax_accounting.php | 69 +++++++++++++++++++
include/class/acc_plan_mtable.class.php | 10 +++
include/database/acc_plan_sql.class.php | 13 +++-
include/lib/manage_table_sql.class.php | 7 +-
include/lib/noalyss_sql.class.php | 3 +-
include/param_pcmn.inc.php | 117 ++++++--------------------------
8 files changed, 124 insertions(+), 101 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index beea218..704d58c 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -195,7 +195,9 @@ $path = array(
// Add , delete update anc accounting
"anc_accounting"=>"ajax_anc_accounting",
// Update name and description
- "anc_updatedescription"=>"ajax_anc_plan"
+ "anc_updatedescription"=>"ajax_anc_plan",
+ // Update, insert or delete accounting frmo CFGPCMN
+ "accounting"=>"ajax_accounting"
) ;
if (array_key_exists($op, $path)) {
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 7a88bb6..a7d8b9c 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -267,7 +267,7 @@ var ManageTable = function (p_table_name)
$(x).remove();
alternate_row_color("tb"+answer['ctl']);
}else {
- smoke.alert("Effacement impossible");
+ smoke.alert(answer['html']);
}
}
});
diff --git a/include/ajax/ajax_accounting.php b/include/ajax/ajax_accounting.php
new file mode 100644
index 0000000..932a2f5
--- /dev/null
+++ b/include/ajax/ajax_accounting.php
@@ -0,0 +1,69 @@
+<?php
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * 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 (2016) Author Dany De Bontridder <address@hidden>
+
+if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief
+ */
+$http=new HttpInput();
+try {
+ $table=$http->request('table');
+ $action=$http->request('action');
+ $p_id=$http->request('p_id', "numeric");
+ $ctl_id=$http->request('ctl');
+
+} catch(Exception $e) {
+ echo $e->getMessage();
+ return;
+}
+if ( $g_user->check_module("CFGPCMN") == 0) die();
+
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+require_once NOALYSS_INCLUDE."/class/acc_plan_mtable.class.php";
+
+$obj=new Acc_Plan_SQL($cn);
+$obj->set_limit_fiche_qcode(5);
+$obj->set_pk_value($p_id);
+$obj->load();
+$manage_table=new Acc_Plan_MTable($obj);
+$manage_table->add_json_param("op","accounting");
+$manage_table->set_object_name($ctl_id);
+$manage_table->set_callback("ajax_misc.php");
+if ($action=="input")
+{
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $manage_table->ajax_input()->saveXML();
+ return;
+}
+elseif ($action == "save")
+{
+ $xml=$manage_table->ajax_save();
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $xml->saveXML();
+}
+elseif ($action == "delete")
+{
+ $xml=$manage_table->ajax_delete();
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $xml->saveXML();
+}
\ No newline at end of file
diff --git a/include/class/acc_plan_mtable.class.php
b/include/class/acc_plan_mtable.class.php
index ef1af27..23377fa 100644
--- a/include/class/acc_plan_mtable.class.php
+++ b/include/class/acc_plan_mtable.class.php
@@ -55,6 +55,7 @@ class Acc_Plan_MTable extends Manage_Table_SQL
["label"=>_("Produit inversé"),"value"=>"PROINV"],
["label"=>_("Contexte"),"value"=>"CON"]
]);
+
$this->a_order=["pcm_val","pcm_lib","parent_accounting","pcm_type","fiche_qcode"];
}
/**
* Display a row
@@ -112,9 +113,18 @@ class Acc_Plan_MTable extends Manage_Table_SQL
if ( trim($this->table->parent_accounting) == "") {
$this->set_error("parent_accounting", _("Poste comptable dépendant
ne peut pas être vide"));
}
+ /**
+ * Check that the parent accounting does exist
+ */
+ $exist_parent=$cn->get_value("select count(*) from tmp_pcmn where
pcm_val = $1 ",
+ array($this->table->parent_accounting));
+ if ($exist_parent == 0) {
+ $this->set_error("parent_accounting", _("Compte parent n'existe
pas"));
+ }
if ( count($this->aerror) > 0 ) return false;
return true;
}
+
}
diff --git a/include/database/acc_plan_sql.class.php
b/include/database/acc_plan_sql.class.php
index 40d93b0..ddf8dc5 100644
--- a/include/database/acc_plan_sql.class.php
+++ b/include/database/acc_plan_sql.class.php
@@ -83,6 +83,14 @@ class Acc_Plan_SQL extends Data_SQL
public function delete()
{
$obj=new Tmp_Pcmn_SQL($this->cn,$this->id);
+ if ( $this->cn->get_value("select count(*) from jrnx where
j_poste=$1",[$obj->pcm_val]) > 0)
+ {
+ throw new Exception(_("Impossible d'effacer : ce poste est
utilisé"));
+ }
+ if ( $this->cn->get_value("select count(*) from tmp_pcmn where
pcm_val_parent=$1",[$obj->pcm_val]) > 0)
+ {
+ throw new Exception(_("Impossible d'effacer : ce poste est
utilisé"));
+ }
return $obj->delete();
}
@@ -103,7 +111,10 @@ class Acc_Plan_SQL extends Data_SQL
$obj->insert();
$this->id=$obj->id;
}
-
+ public function get_pk_value()
+ {
+ return $this->id;
+ }
public function load()
{
$pk=$this->primary_key;
diff --git a/include/lib/manage_table_sql.class.php
b/include/lib/manage_table_sql.class.php
index 4ba1142..15a787f 100644
--- a/include/lib/manage_table_sql.class.php
+++ b/include/lib/manage_table_sql.class.php
@@ -579,12 +579,15 @@ function check()
}
$nb_order=count($this->a_order);
$virg=""; $result="";
+ // filter only on visible column
+ $visible=0;
for ($e=0; $e<$nb_order; $e++)
{
if ($this->get_property_visible($this->a_order[$e])==TRUE)
{
- $result.=$virg."$e";
+ $result.=$virg."$visible";
$virg=",";
+ $visible++;
}
}
echo _('Cherche')." ".HtmlInput::filter_table("tb".$this->object_name,
$result, 1);
@@ -1001,7 +1004,7 @@ function check()
$s1=$xml->createElement("status", "NOK");
$s2=$xml->createElement("ctl",
$this->object_name."_".$this->table->get_pk_value());
- $s3=$xml->createElement("html", $ex->getTraceAsString());
+ $s3=$xml->createElement("html", $ex->getMessage());
$s4=$xml->createElement("ctl", $this->object_name);
$root=$xml->createElement("data");
diff --git a/include/lib/noalyss_sql.class.php
b/include/lib/noalyss_sql.class.php
index 043d659..9f2e8ca 100644
--- a/include/lib/noalyss_sql.class.php
+++ b/include/lib/noalyss_sql.class.php
@@ -201,7 +201,8 @@ abstract class Noalyss_SQL extends Data_SQL
}
$sql.=") values (".$par.") returning ".$this->primary_key;
$pk=$this->primary_key;
- $this->$pk=$this->cn->get_value($sql, $array);
+ $returning=$this->cn->get_value($sql, $array);
+ $this->$pk=$returning;
}
public function delete()
diff --git a/include/param_pcmn.inc.php b/include/param_pcmn.inc.php
index d967f5c..1c233e9 100644
--- a/include/param_pcmn.inc.php
+++ b/include/param_pcmn.inc.php
@@ -41,7 +41,7 @@ echo '<div id="acc_update" class="inner_box"
style="display:none;position:absolu
/* Store the p_start parameter */
-$g_start=$http->get('p_start',"string",1);
+$g_start=$http->get('p_start',"numeric",1);
?>
<a id="top"></a>
@@ -53,110 +53,37 @@ $g_start=$http->get('p_start',"string",1);
<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)=$1
- group by pcm_val,pcm_lib,pcm_val_parent, pcm_type order by
pcm_val::text",array($g_start));
-$MaxRow=Database::num_row($Ret);
-
-?>
-<span style="display:inline;margin: 15px 15px 15px 15px">
-<input type="button" id="pcmn_update_add_bt" class="smallbutton" value="<?php
echo _('Ajout poste comptable'); ?>">
-</span>
-<?php echo _('Cherche')." ".HtmlInput::filter_table("account_tbl_id",
"0,1,2,3,4", 1);?>
- <?php
- echo HtmlInput::hidden('p_action','pcmn');
-//echo HtmlInput::hidden('sa','detail');
-echo dossier::hidden();
-$limite=MAX_QCODE;
-?>
-<TABLE id="account_tbl_id" class="result">
- <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>
+require_once NOALYSS_INCLUDE."/class/acc_plan_mtable.class.php";
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+/**
+ * @file
+ * @brief Test the Acc_Plan_MTable
+ */
+$obj=new Acc_Plan_SQL($cn);
+/**
+ * Test $obj
+ */
-<?php
-$str_dossier=dossier::id();
-for ($i=0; $i <$MaxRow; $i++):
- $A=Database::fetch_array($Ret,$i);
- $class=( $i%2 == 0 )?"even":"odd";
+$mtable=new Acc_Plan_MTable($obj);
+$mtable->add_json_param("op", "accounting");
+$obj->set_limit_fiche_qcode(5);
+$mtable->set_callback("ajax_misc.php");
+$mtable->create_js_script();
-?>
- <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']);
- ?>
- </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;
- if ($max < count($det_qcode)) :
- echo "...";
- endif;
- echo '</ol>';
- else :
- echo HtmlInput::card_detail($A['acode']);
- endif;
-
- endif;
- ?>
- </td>
- </tr>
-<?php
-endfor;
-?>
-</TABLE>
- <?php
- /* it will override the classic onscroll (see scripts.js)
- * @see scripts.js
- */
+echo $mtable->display_table(" where pcm_val::text like '{$g_start}%' order by
pcm_val::text ");
+/* it will override the classic onscroll (see scripts.js)
+ * @see scripts.js
+*/
?>
<div id="go_up" class="inner_box"
style="padding:0px;left:auto;width:250px;height:
100px;display:none;position:fixed;top:5px;right:20px">
- <?php echo HtmlInput::title_box(_('Navigation'), 'go_up', "hide");?>
+ <?php echo HtmlInput::title_box(_('Navigation'), 'go_up', "none");?>
<div style="margin:3%;padding:3%">
<a class="button" href="#top" ><?php echo "⇧";?></a>
- <input type="button" id="pcmn_update_add_bt3" class="smallbutton"
value="<?php echo _('Ajout poste comptable'); ?>">
+ <input type="button" id="pcmn_update_add_bt3" value="<?php echo
_('Ajout poste comptable'); ?>">
</div>
</div>
- <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()?>,'');
- }
- $('pcmn_update_add_bt3').onclick = function ()
- {
- pcmn_update(<?php echo Dossier::id()?>,'');
- }
window.onscroll=function () {
if ( document.viewport.getScrollOffsets().top> 0) {
if ($('go_up').visible() == false) {
- [Noalyss-commit] [noalyss] 37/219: Task #0001411: Faire des boutons du menu des... boutons Ajout nouveau style-r692, (continued)
- [Noalyss-commit] [noalyss] 37/219: Task #0001411: Faire des boutons du menu des... boutons Ajout nouveau style-r692, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 57/219: New : inplace_edit permit the developer to create easily a "inplace" edit field, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 93/219: Change background title inner_box, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 118/219: Task #0001297: Perfectionnement menu COMPTA/ADV/OPEN Improve operation message, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 74/219: Security : SQL use directly $_SESSION, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 103/219: Réécriture de CFGPCMN pour utiliser ManageTable Ajout bouton ajout dans menu, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 120/219: Task #0001328: Problème affichage totaux achat, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 119/219: Task #0001297: Perfectionnement menu COMPTA/ADV/OPEN Improve operation message, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 80/219: Bug : export_document the parameters id, ag_id and value are optionnal, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 45/219: Improve SQL class generation, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 101/219: Réécriture de CFGPCMN pour utiliser ManageTable,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 17/219: Add test for Manage_Table_SQL, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 127/219: Task #0001484: CA : opération diverses , possibilité d'ajouter une fiche Add card to misc operation ANC, - implemented also in Printing : balance , History , General Ledger..., Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 144/219: ANC : Bouton "recherche" sont des loupes, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 25/219: Ajout des ASBL, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 53/219: typo, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 28/219: Task #0001447: Solde des opérations rapprochées Take in account the VAT autopurged, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 15/219: Infobulle : info : esthetic, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 38/219: task #0001411: Faire des boutons du menu des... boutons, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 95/219: Recording operation : when adding a row , the css class was not copied, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 02/219: Improve redirect, Dany De Bontridder, 2017/12/18