[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 47/219: Task #0001462: CA - apostrophe non a
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 47/219: Task #0001462: CA - apostrophe non affichée Use of ManageTableSQL for improving adding , update and delete analytic accounting |
Date: |
Mon, 18 Dec 2017 13:22:36 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 868098e20f42f91ddb37d7cfa888b3000b33391a
Author: Dany De Bontridder <address@hidden>
Date: Wed Sep 13 00:06:43 2017 +0200
Task #0001462: CA - apostrophe non affichée
Use of ManageTableSQL for improving adding , update and delete
analytic accounting
---
html/ajax_misc.php | 4 +-
include/anc_pa.inc.php | 158 ++++++------------------
include/class/anc_account.class.php | 3 +-
include/class/anc_account_table.class.php | 93 ++++++++++++++
include/database/poste_analytique_sql.class.php | 70 +++++++++++
5 files changed, 206 insertions(+), 122 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 4172dc0..1f8bf74 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -181,7 +181,9 @@ $path = array(
// Save a event given in the short form
"action_save"=>"ajax_gestion",
/* display the lettering , callebd from acc_ledger : dsp_letter*/
- "dl"=>"ajax_display_letter"
+ "dl"=>"ajax_display_letter",
+ // Add , delete update anc accounting
+ "anc_accounting"=>"ajax_anc_accounting"
) ;
if (array_key_exists($op, $path)) {
diff --git a/include/anc_pa.inc.php b/include/anc_pa.inc.php
index 335a686..3cc09cd 100644
--- a/include/anc_pa.inc.php
+++ b/include/anc_pa.inc.php
@@ -28,7 +28,9 @@
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/class/anc_plan.class.php';
-require_once NOALYSS_INCLUDE.'/class/anc_account.class.php';
+require_once NOALYSS_INCLUDE.'/class/anc_account_table.class.php';
+require_once NOALYSS_INCLUDE.'/database/poste_analytique_sql.class.php';
+
$ret="";
$str_dossier=Dossier::get();
@@ -45,13 +47,14 @@ if ($sa=="add_pa")
$new=new Anc_Plan($cn);
if ($new->isAppend()==true)
{
- $ret.= '<div style="position:absolute;top:25%" class="inner_box">';
- $ret.=HtmlInput::title_box(_('Nouveau plan'), '', 'none');
+ $ret.= '<div style="position:absolute;top:25%" id="anc_div_add"
class="inner_box">';
+ $ret.=HtmlInput::title_box(_('Nouveau plan'), 'anc_div_add', 'hide');
$ret.= '<form method="post">';
$ret.=dossier::hidden();
$ret.= $new->form();
$ret.= HtmlInput::hidden("sa", "pa_write");
$ret.=HtmlInput::submit("submit", _("Enregistre"));
+ $ret.=HtmlInput::button_hide("anc_div_add");
$ret.= '</form>';
$ret.= '</div>';
}
@@ -98,85 +101,21 @@ if ($sa=="pa_update")
$ret.="</div>";
$sa="anc_menu";
}
-// show the form for add a poste
-if ($sa=='po_add')
-{
- $po=new Anc_Account($cn);
- $po->pa_id=$_REQUEST['pa_id'];
- $wSa=HtmlInput::hidden("sa", "po_write");
- $ret.='<div class="content">';
- $ret.=h2(_("Ajout d'un poste analytique"));
- $ret.='<form method="post">';
- $ret.=dossier::hidden();
- $ret.=$po->form();
- $ret.=$wSa;
- $ret.=HtmlInput::submit("add", _("Ajout"));
- $ret.="</form>";
- $ret.="</div>";
-}
-// record the poste
-if ($sa=="po_write")
-{
- // var_dump($_POST);
- $po=new Anc_Account($cn);
- $po->get_from_array($_POST);
- $po->add();
- $sa="pa_detail";
-}
+
/* delete pa */
if ($sa=="pa_delete")
{
- $delete=new Anc_Plan($cn, $_GET['pa_id']);
+ $delete=new Anc_Plan($cn, $pa_id);
$delete->delete();
$sa="anc_menu";
}
-/* po detail
- * ---> in ajax : montre detail d'un poste analytique
- *
- */
-if ($sa=="po_detail")
-{
- $ret.=h2(_('Modification'));
- $po=new Anc_Account($cn, $_GET['po_id']);
- $po->get_by_id();
- $ret.='<div class="content">';
- $ret.='<form method="post">';
- $ret.=dossier::hidden();
- $ret.=$po->form();
- $ret.=HtmlInput::hidden('sa', 'po_update');
- $ret.=HtmlInput::submit('Correction', 'Correction');
- $ret.=sprintf('<input type="button" class="smallbutton" value="Efface"
onClick="return confirm_box(\'anchor_del\',\' Voulez-vous vraiment effacer
cette activité\','
- .'function () {
window.location=\'do.php?ac='.$_REQUEST['ac'].'&sa=po_delete&po_id=%s&pa_id=%s&'.$str_dossier.'\'})
;"',
- $po->id, $_REQUEST['pa_id']
- );
-
- $ret.='</form>';
- $ret.='</div>';
- $sa="";
-}
-/**
- * mise à jour po
- */
-if ($sa=="po_update")
-{
- $po=new Anc_Account($cn);
- $po->get_from_array($_POST);
- $po->update();
- $sa="pa_detail";
-}
-/**
- * Efface po
- */
-if ($sa=="po_delete")
-{
- $po=new Anc_Account($cn, $_REQUEST['po_id']);
- $po->delete();
- $sa="pa_detail";
-}
// show the detail
if ($sa=="pa_detail")
{
+
+ $pa_id=$http->get("pa_id","numeric");
+
$new=new Anc_Plan($cn, $_GET['pa_id']);
$wSa=HtmlInput::hidden("sa", "pa_update");
@@ -194,53 +133,26 @@ if ($sa=="pa_detail")
'onclick="return
confirm_box(\'remove_analytic_plan\',\'Effacer ?\',function ()
{window.location=\'do.php?ac='.$_REQUEST['ac'].'&pa_id='.$_GET['pa_id'].'&sa=pa_delete&'.$str_dossier.'\';})"',
'smallbutton');
$ret.= '</form>';
- /**
- * Detail now
- */
+
+ //---------------------------------------------------------------------
+ // Detail now
+ // Use Manage_Table
+ //---------------------------------------------------------------------
$count=0;
- $new=new Anc_Plan($cn, $_REQUEST['pa_id']);
+ $new=new Anc_Plan($cn, $pa_id);
$new->get();
- $array=$new->get_poste_analytique(" order by po_name");
$ret.='<div class="content">';
- $ret.='<table class="table_large">';
- $ret.="<tr>";
- $ret.="<th>"._("Nom")." </td>";
- $ret.="<th>"._("Montant")." </td>";
- $ret.="<th>"._("Description")." </td>";
- $ret.="<th>"._("Groupe")."</th>";
- $ret.="<th>"._("Plan A")." </td>";
- $ret.="</tr>";
- $class="";
- foreach ($array as $obj)
- {
- $count++;
- if ($count%2==0)
- $class="even";
- else
- $class="odd";
-
- $ret.="<TR class=\"$class\">";
- $ret.="<TD class=\"vert_mtitle\">".
- '<a style="text-decoration:underline;"
href="?ac='.$_REQUEST['ac'].'&sa=po_detail&po_id='.$obj->id.'&pa_id='.$_REQUEST['pa_id'].'&'.
- $str_dossier.'">'.
- h($obj->name).
- '</a>';
- "</td>"
- ;
- $ret.="<TD align=\"right\">".$obj->amount."</td>";
- $ret.="<TD>".h($obj->description)."</td>";
- $ret.="<td>".$obj->ga_id."</td>";
- $ret.="<TD>".h($new->name)."</td>";
- $ret.="</tr>";
- }
- $ret.="</table>";
- // ---> montre form pour ajouter po
- $ret.=HtmlInput::button_anchor(_('Ajout'),
-
"?ac=".$_REQUEST['ac']."&sa=po_add&pa_id=".$_GET['pa_id']."&".$str_dossier,
- '', '', 'smallbutton');
- $href=http_build_query(array('ac'=>$_REQUEST['ac'],
'gDossier'=>$_REQUEST['gDossier']));
- $ret.= '<a style="display:inline" class="smallbutton"
href="do.php?'.$href.'">'._('Retour').'</a>';
+ $anc=new Poste_analytique_SQL($cn);
+ $anc->pa_id=$pa_id;
+ $accounting=new Anc_Account_Table($anc);
+ $accounting->set_callback("ajax_misc.php");
+ $accounting->add_json_param("op", "anc_accounting");
+ $accounting->add_json_param("pa_id", $pa_id);
+ ob_start();
+ $accounting->display_table(" where pa_id = $1 order by po_name
",array($pa_id));
+ $accounting->create_js_script();
+ $ret.=ob_get_clean();
$ret.= '</div>';
}
@@ -255,14 +167,16 @@ if ($sa=='anc_menu')
$list=$obj->get_list();
-
+ $ac=$http->request("ac");
if (empty($list))
{
+ $url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
+ "gDossier"=>Dossier::id()));
echo '<div class="content">';
echo '<TABLE>';
echo '<TR><TD class="vert_mtitle">';
- echo '<a
href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan
comptable").'</a>';
+ echo '<a href="?'.$url.'">'._("Ajout d'un plan comptable").'</a>';
echo '</TD></TR>';
echo '</TABLE>';
@@ -274,23 +188,27 @@ if ($sa=='anc_menu')
}
else
{
+ $url=http_build_query(array("sa"=>"add_pa","ac"=>$ac,
+ "gDossier"=>Dossier::id()));
echo '<div class="content">';
echo '<table class="vert_mtitle">';
if ($obj->isAppend()==true)
{
echo '<TR><TD class="first">';
- echo '<a
href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan
comptable").'</a>';
+ echo '<a href="?'.$url.'">'._("Ajout d'un plan comptable").'</a>';
echo '</TD></TR>';
}
foreach ($list as $line)
{
+
$url=http_build_query(array("sa"=>"pa_detail","ac"=>$ac,"pa_id"=>$line['id'],
+ "gDossier"=>Dossier::id()));
echo '<TR>';
echo '<TD>'.
- '<a
href="?ac='.$_REQUEST['ac'].'&sa=pa_detail&pa_id='.$line['id'].'&'.$str_dossier.'">'.
+ '<a href="?'.$url.'">'.
h($line['name']);
- echo $line['description']."</a>";
+ echo h($line['description'])."</a>";
echo "</td>";
echo "</TR>\n";
}
diff --git a/include/class/anc_account.class.php
b/include/class/anc_account.class.php
index 7327f49..a070cfb 100644
--- a/include/class/anc_account.class.php
+++ b/include/class/anc_account.class.php
@@ -239,7 +239,8 @@ class Anc_Account
$wName=new IText("po_name",$this->name);
$wAmount=new INum("po_amount",$this->amount);
$wDescription=new IText("po_description",$this->description);
- $aGroup_analytic=$this->db->make_array("select ga_id,ga_id from
groupe_analytique where pa_id=".$this->pa_id,1);
+ //@bug
+ $aGroup_analytic=$this->db->make_array("select ga_id,ga_id from
groupe_analytique where pa_id=$1",1,array($this->pa_id));
if ( count($aGroup_analytic) > 1 )
{
$wGa_id=new ISelect("ga_id");
diff --git a/include/class/anc_account_table.class.php
b/include/class/anc_account_table.class.php
new file mode 100644
index 0000000..97f9e67
--- /dev/null
+++ b/include/class/anc_account_table.class.php
@@ -0,0 +1,93 @@
+<?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 Add , delete and update Poste_Analytic
+ *
+ */
+/**
+ * @class
+ * @brief derived from Manage_Table_SQL ,
+ */
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+require_once NOALYSS_INCLUDE.'/database/poste_analytique_sql.class.php';
+
+class Anc_Account_Table extends Manage_Table_SQL
+{
+ function __construct(Data_SQL $p_table)
+ {
+ parent::__construct($p_table);
+ $cn=Dossier::connect();
+ $this->set_property_updatable("po_id", FALSE);
+ $this->set_property_updatable("pa_id", FALSE);
+ $this->set_property_visible("pa_id", FALSE);
+ $this->set_property_visible("po_id", FALSE);
+ $this->set_property_visible("po_amount", FALSE);
+ $this->set_col_label("po_name", _("Label"));
+ $this->set_col_label("po_description", _("Description"));
+ $this->set_col_label("ga_id", _("Groupe"));
+ $this->set_col_type("ga_id", "select");
+ $this->set_object_name("Oanc_accounting");
+ $this->set_col_sort(1);
+ $this->a_select["ga_id"]=$cn->make_array("select ga_id,ga_description
+ from groupe_analytique
+ where
+ pa_id=$1
+ order by 2",0,array($p_table->pa_id));
+
+ }
+ /**
+ * Check and change po_name values
+ * @return boolean
+ */
+ function check()
+ {
+ $cn=Dossier::connect();
+ $table=$this->get_table();
+ $is_error=0;
+ $table->po_amount=0;
+ // po_name must contains only valid letter (remove < > and ')
+ $table->po_name=str_replace("'", '', $table->po_name);
+ $table->po_name=str_replace("<", '', $table->po_name);
+ $table->po_name=str_replace(">", '', $table->po_name);
+
+ // po_name must be uniq in the Analytic Plan
+ if ( $cn->get_value("select count(*) from poste_analytique where
pa_id=$1 and po_name=$2",
+ array($table->pa_id,$table->po_name)) > 0 && $table->po_id==-1)
+ {
+ $is_error++;
+ $this->set_error("po_name", _("Le nom doit être unique dans un
plan analytique"));
+
+ }
+ // po_name cannot be empty
+ if (trim($table->po_name)=="") {
+ $is_error++;
+ $this->set_error("po_name", _("Le nom ne peut être vide"));
+ }
+ $table->ga_id=($table->ga_id=="")?null:$table->ga_id;
+ if ($is_error==0)return TRUE;
+ return FALSE;
+ }
+}
\ No newline at end of file
diff --git a/include/database/poste_analytique_sql.class.php
b/include/database/poste_analytique_sql.class.php
new file mode 100644
index 0000000..ba9ab30
--- /dev/null
+++ b/include/database/poste_analytique_sql.class.php
@@ -0,0 +1,70 @@
+<?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>
+
+/**
+ * class_poste_analytique_sql.php
+ *
+ * @file
+ * @brief abstract of the table public.poste_analytique
+ *
+ *
+ * @class
+ * @brief abstract of the table public.poste_analytique */
+class Poste_analytique_SQL extends Noalyss_SQL
+{
+
+ function __construct(Database $p_cn, $p_id=-1)
+ {
+ $this->table="public.poste_analytique";
+ $this->primary_key="po_id";
+ /*
+ * List of columns
+ */
+ $this->name=array(
+ "po_id"=>"po_id"
+ , "po_name"=>"po_name"
+ , "pa_id"=>"pa_id"
+ , "po_amount"=>"po_amount"
+ , "po_description"=>"po_description"
+ , "ga_id"=>"ga_id"
+ );
+ /*
+ * Type of columns
+ */
+ $this->type=array(
+ "po_id"=>"numeric"
+ , "po_name"=>"text"
+ , "pa_id"=>"numeric"
+ , "po_amount"=>"numeric"
+ , "po_description"=>"text"
+ , "ga_id"=>"text"
+ );
+
+
+ $this->default=array(
+ "po_id"=>"auto"
+ );
+
+ $this->date_format="DD.MM.YYYY";
+ parent::__construct($p_cn, $p_id);
+ }
+
+}
- [Noalyss-commit] [noalyss] 63/219: Analytic : change the name and description in Ajax, improve esthetic, (continued)
- [Noalyss-commit] [noalyss] 63/219: Analytic : change the name and description in Ajax, improve esthetic, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 116/219: Task #0001297: Perfectionnement menu COMPTA/ADV/OPEN, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 56/219: Task #1469 : Les esperluettes ne passent pas dans les libellés pour «opération identique»., Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 189/219: Task #1506 Fiche : max longueur du poste comptable = 40, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 195/219: Task #001381 : favori de filtre , ajout des favoris de filtre dans les recherches., Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 71/219: Task #0001475: Todo note : il manque le bouton "Fermer", Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 146/219: ANC : ANC_TABLE replace PGPLSQL procedure by Php functions : Anc_Table:create_temp_account Anc_Table:create_temp_card, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 102/219: task #0001386: Amélioration visuelle plan comptable - postes utilisés Ajout lien si poste comptable utilisé, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 32/219: Task #0001426: Distinction dans l'affichage des historiques des OD: libellé + fiche Ajout des qcodes pour l'historique par poste Ajout des postes comptables pour l'historique par Fiche Ajout des tiers Fait aussi pour les export PDF & CSV, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 149/219: HttpInput: protect against injection, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 47/219: Task #0001462: CA - apostrophe non affichée Use of ManageTableSQL for improving adding , update and delete analytic accounting,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 29/219: Task #0001443: opérations rapprochées : bug quand on utilise des tva avec autoliquidation Esthetique show the autoreversed VAT, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 204/219: Bug : when pressing on the template button, the input field to focus is not diplaid and the javascript gives an exception, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 206/219: typo, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 88/219: Task #0001481: Encodage Vente, Achat, Fin ou OD 1. S'il n'y a qu'une seule catégorie de fiche , il n'est plus nécessaire d'afficher le choix (puisqu'il n'y en a qu'un) 2. Avoir pour chaque ligne un bouton ajout fiche, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 212/219: Esthetic : show ledger : width of the box, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 179/219: Fix ID problem, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 167/219: Space, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 138/219: Javascript : small error, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 100/219: CSS input field with focus 0001302: FICHES: mise en évidence champs NOM/POSTE/CODE, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 26/219: task #1438 Remplacement de HtmlInput par Http_Input, Dany De Bontridder, 2017/12/18