[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 65/219: CFGSEC : the ledgers are now updated
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 65/219: CFGSEC : the ledgers are now updated thanks an inplace class |
Date: |
Mon, 18 Dec 2017 13:22:39 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit b712539fe768829aeda4143040e45d20be498ca1
Author: Dany De Bontridder <address@hidden>
Date: Mon Oct 2 20:49:10 2017 +0200
CFGSEC : the ledgers are now updated thanks an inplace class
---
html/ajax_misc.php | 6 +
include/ajax/ajax_ledger_security.php | 173 ++++++++++++++++++++++++++++
include/class/acc_ledger.class.php | 2 +-
include/class/acc_ledger_purchase.class.php | 2 +-
include/class/acc_payment.class.php | 26 +++--
include/lib/html_input.class.php | 15 +++
include/lib/inplace_edit.class.php | 26 ++++-
include/lib/iselect.class.php | 20 +++-
include/param_sec.inc.php | 147 ++++++++++++-----------
scenario/inplace_edit.test.php | 23 +++-
10 files changed, 351 insertions(+), 89 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 82749d1..f3b4dd0 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -109,6 +109,12 @@ $path = array(
"account"=>"ajax_poste",
"card"=>"ajax_card",
"ledger"=>"ajax_ledger",
+ // Manage ledger access
+ "ledger_access"=>"ajax_ledger_security",
+ // Manage user profile
+ "profile"=>"ajax_ledger_security",
+ // Update in once all the ledgers
+ "ledger_access_all"=>"ajax_ledger_security",
"todo_list"=>"ajax_todo_list",
"history"=>"ajax_history",
"pcmn_update"=>"ajax_pcmn_update",
diff --git a/include/ajax/ajax_ledger_security.php
b/include/ajax/ajax_ledger_security.php
new file mode 100644
index 0000000..1423962
--- /dev/null
+++ b/include/ajax/ajax_ledger_security.php
@@ -0,0 +1,173 @@
+<?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');
+
+
+require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
+require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inum.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
+
+/**
+ * @file
+ * @brief Manage the security of a ledger , from CFGSEC module
+ *
+ */
+
+$n_dossier_id=Dossier::id();
+//-----------------------------------------------------------------------------
+// Manage the user's access to ledgers
+//-----------------------------------------------------------------------------
+if ($op=="ledger_access")
+{
+ $input=$http->request("input");
+ $action=$http->request("ieaction", "string", "display");
+ $user_id=$http->post("user_id", "numeric");
+ $jrn_def_id=$http->post("jrn_def_id", "numeric");
+ if ($action=="display")
+ {
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("jrn_def_id", $jrn_def_id);
+ $ie_input->add_json_param("op", "ledger_access");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ echo $ie_input->ajax_input();
+ return;
+ }
+ if ($action=="ok")
+ {
+ $value=$http->post("value");
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("jrn_def_id", $jrn_def_id);
+ $ie_input->add_json_param("op", "ledger_access");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ $ie_input->set_value($value);
+ $sec_User=new User($cn, $user_id);
+ $count=$cn->get_value('select count(*) from user_sec_jrn where
uj_login=$1 '.
+ ' and uj_jrn_id=$2', array($sec_User->login, $jrn_def_id));
+ if ($count==0)
+ {
+ $cn->exec_sql('insert into user_sec_jrn
(uj_login,uj_jrn_id,uj_priv)'.
+ ' values ($1,$2,$3)',
+ array($sec_User->login, $jrn_def_id, $value));
+ }
+ else
+ {
+ $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where
uj_login=$2 and uj_jrn_id=$3',
+ array($value, $sec_User->login, $jrn_def_id));
+ }
+ echo $ie_input->value();
+ return;
+ }
+ if ($action=="cancel")
+ {
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("jrn_def_id", $jrn_def_id);
+ $ie_input->add_json_param("op", "ledger_access");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ echo $ie_input->value();
+ return;
+ }
+}
+//-----------------------------------------------------------------------------
+// Set the user's profile
+//-----------------------------------------------------------------------------
+if ( $op == "profile")
+{
+ $input=$http->request("input");
+ $action=$http->request("ieaction", "string", "display");
+ $user_id=$http->post("user_id", "numeric");
+ $profile_id=$http->post("profile_id","numeric");
+ if ($action=="display")
+ {
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("profile_id", $profile_id);
+ $ie_input->add_json_param("op", "profile");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ echo $ie_input->ajax_input();
+ return;
+ }
+ if ($action=="ok")
+ {
+ $value=$http->post("value");
+ // save profile
+ $sec_User=new User($cn,$user_id);
+ $sec_User->save_profile($value);
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("op", "profile");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ $ie_input->set_value($value);
+
+ echo $ie_input->value();
+ return;
+ }
+ if ($action=="cancel")
+ {
+ $ie_input=Inplace_Edit::build($input);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("op", "profile");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("profile_id", $profile_id);
+ $ie_input->add_json_param("user_id", $user_id);
+ echo $ie_input->value();
+ return;
+ }
+}
+//------------------------------------------------------------------------------
+// Update in once all the ledger access for an user
+//------------------------------------------------------------------------------
+if ( $op == 'ledger_access_all') {
+ // Find the login
+ $user_id=$http->post("user_id","numeric");
+ $access=$http->post("access");
+ if ( $access != "W" && $access != "X" && $access !="R") die("Invalid
access");
+ $sec_User=new User($cn, $user_id);
+ // Insert all the existing ledgers to user_sec_jrn
+ $sql="insert into user_sec_jrn(
+ uj_jrn_id,
+ uj_login,
+ uj_priv
+ ) select jrn_def_id,$1,'X'
+ from
+ jrn_def
+ where
+ not exists(select 1
+ from
+ user_sec_jrn
+ where
+ uj_jrn_id = jrn_def_id
+ and uj_login = $1
+ )";
+ $cn->exec_sql($sql,array($sec_User->login));
+ $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where
uj_login=$2',array($access,$sec_User->login));
+ return;
+}
\ No newline at end of file
diff --git a/include/class/acc_ledger.class.php
b/include/class/acc_ledger.class.php
index 6a02399..bbb9dcf 100644
--- a/include/class/acc_ledger.class.php
+++ b/include/class/acc_ledger.class.php
@@ -3653,7 +3653,7 @@ class Acc_Ledger extends jrn_def_sql
{
$r = '';
$r.='<div id="payment"> ';
- $r.='<h2> ' . _('Payé par') . ' </h2>';
+ $r.='<h2> ' . _('Payement') . ' </h2>';
$mp = new Acc_Payment($this->db);
$mp->set_parameter('ledger_source', $this->id);
$r.=$mp->select($p_selected);
diff --git a/include/class/acc_ledger_purchase.class.php
b/include/class/acc_ledger_purchase.class.php
index 8edd3f6..438f817 100644
--- a/include/class/acc_ledger_purchase.class.php
+++ b/include/class/acc_ledger_purchase.class.php
@@ -874,7 +874,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger
/* insert into jrn */
$acc_pay->mt=$mt;
- $acc_pay->desc=(!isset($e_comm_paiement) ||
strlen(trim($e_comm_paiement)) == 0) ?$e_comm:$e_comm_paiement;
+ $acc_pay->desc=(!isset($e_comm_paiement) ||
strlen(trim($e_comm_paiement)) == 0) ?$e_comm:$e_comm_paiement;
$mp_jr_id=$acc_pay->insert_jrn();
$acjrn->grpt_id=$acseq;
$acjrn->update_internal_code($acinternal);
diff --git a/include/class/acc_payment.class.php
b/include/class/acc_payment.class.php
index 4c84981..b24b006 100644
--- a/include/class/acc_payment.class.php
+++ b/include/class/acc_payment.class.php
@@ -277,6 +277,8 @@ class Acc_Payment
}
/*!\brief show several lines with radio button to select the payment
*method we want to use, the $_POST['e_mp'] will be set
+ * \todo this class is used only for storage of the defined payment
method, not the payment itself,
+ * it must be moved to another class 'Operation_Payment'
*\param $p_selected if the id choose
*\return html string
*/
@@ -287,20 +289,24 @@ class Acc_Payment
$r.=HtmlInput::hidden('gDossier',dossier::id());
if ( empty($array)==false ) {
+ $date_pay=new IDate('mp_date');
+
+ $r.=sprintf(_("Date %s"),
+ $date_pay->input());
$acompte=new INum('acompte');
$acompte->value=0;
$r.=_(" Acompte à déduire");
$r.=$acompte->input();
- $r.='<p>';
- $e_comm_paiement=new IText('e_comm_paiement');
- $e_comm_paiement->table = 0;
- $e_comm_paiement->setReadOnly(false);
- $e_comm_paiement->size = 60;
- $e_comm_paiement->tabindex = 3;
- $r.=_(" Libellé du paiement");
- $r.=$e_comm_paiement->input();
- $r.='</p>';
- }
+ $r.='<p>';
+ $e_comm_paiement=new IText('e_comm_paiement');
+ $e_comm_paiement->table = 0;
+ $e_comm_paiement->setReadOnly(false);
+ $e_comm_paiement->size = 60;
+ $e_comm_paiement->tabindex = 3;
+ $r.=_(" Libellé du paiement");
+ $r.=$e_comm_paiement->input();
+ $r.='</p>';
+ }
$r.='<ol>';
$r.='<li ><input type="radio" name="e_mp" value="0"
checked>'._('Paiement encodé plus tard');
diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php
index 0a3e510..f005b6d 100755
--- a/include/lib/html_input.class.php
+++ b/include/lib/html_input.class.php
@@ -101,6 +101,21 @@ class HtmlInput
$this->$p_name=$p_value;
}
/**
+ * Set the value of input (IText, INum,...)
+ * @param type $p_string
+ */
+ function set_value($p_string)
+ {
+ $this->value=$p_string;
+ }
+ /**
+ * Return the value of input (IText, INum,...)
+ */
+ function get_value()
+ {
+ return $this->value;
+ }
+ /**
address@hidden you can add attribute to this in javascript
* this function is a wrapper and create a script (in js) to modify
* "this" (in javascript) with the value of obj->attribute from PHP
diff --git a/include/lib/inplace_edit.class.php
b/include/lib/inplace_edit.class.php
index 18414c5..522a599 100644
--- a/include/lib/inplace_edit.class.php
+++ b/include/lib/inplace_edit.class.php
@@ -38,12 +38,14 @@ class Inplace_Edit
{
- ///< HtmlInput object
+ /// HtmlInput object
private $input;
- ///< Json object to pass to JavaScript
+ /// Json object to pass to JavaScript
private $json;
- ///< Php file which answered the ajax
+ /// Php file which answered the ajax
private $callback;
+ /// Message to display if value is empty
+ private $message;
/**
* Create a Inplace_Edit, initialise JSON and fullfill the default json
value:
* input which is the HtmlInput object serialized
@@ -53,6 +55,7 @@ class Inplace_Edit
$this->input=$p_input;
$x["input"]=serialize($p_input);
$this->json=json_encode($x,
JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
+ $this->message=_("Faites un choix");
}
///@brief build a Inplace_Edit object from
/// a serialized string (ajax json parameter = input)
@@ -105,7 +108,9 @@ EOF;
*/
function value()
{
- echo $this->input->value,
+ $v=$this->input->get_value();
+ $v=(trim($v)=="")?$this->message:$v;
+ echo $v,
"
<script>
$('{$this->input->id}edit').removeClassName('inplace_edit_input');
@@ -124,7 +129,9 @@ EOF;
echo <<<EOF
<span class="inplace_edit" id="{$this->input->id}edit" >
EOF;
- echo $this->input->value;
+ $v=$this->input->get_value();
+ $v=(trim($v)=="")?$this->message:$v;
+ echo $v;
echo "</span>";
echo "
<script>
@@ -186,7 +193,14 @@ EOF;
*/
function set_value($p_value) {
$input=$this->get_input();
- $this->input->value= strip_tags($p_value);
+ $this->input->set_value(strip_tags($p_value));
$this->set_input($input);
}
+ /**
+ * Message to display if the value is empty
+ * @param string $p_str
+ */
+ function set_message($p_str) {
+ $this->message=$p_str;
+ }
}
\ No newline at end of file
diff --git a/include/lib/iselect.class.php b/include/lib/iselect.class.php
index dcbe6f4..9ba2544 100644
--- a/include/lib/iselect.class.php
+++ b/include/lib/iselect.class.php
@@ -68,7 +68,22 @@ class ISelect extends HtmlInput
}
}
- if ( $this->table == 1 ) $a='<td>'.$r.'</td>';
+ $r='<span class="input_text_ro">'.$r.'</span>';
+ if ( $this->table == 1 ) $a='<td>'.$r.'</td>';
+ return $r;
+ }
+ /*!\brief print in html the readonly value of the widget*/
+ public function get_value()
+ {
+ $r="";
+ for ( $i=0;$i<sizeof($this->value);$i++)
+ {
+ if ($this->selected==$this->value[$i]['value'] )
+ {
+ $r=h($this->value[$i]['label']);
+
+ }
+ }
return $r;
}
/**
@@ -93,6 +108,9 @@ class ISelect extends HtmlInput
$this->value[]=$a_ret;
}
}
+ function set_value($p_string) {
+ $this->selected=$p_string;
+ }
static public function test_me()
{
}
diff --git a/include/param_sec.inc.php b/include/param_sec.inc.php
index 2c5f12d..08b81c9 100644
--- a/include/param_sec.inc.php
+++ b/include/param_sec.inc.php
@@ -29,6 +29,9 @@ require_once NOALYSS_INCLUDE.'/class/dossier.class.php';
require_once NOALYSS_INCLUDE.'/class/user.class.php';
require_once NOALYSS_INCLUDE.'/lib/database.class.php';
require_once NOALYSS_INCLUDE.'/lib/sort_table.class.php';
+require_once NOALYSS_INCLUDE.'/lib/inplace_edit.class.php';
+
+$http=new HttpInput();
$gDossier=dossier::id();
$str_dossier=dossier::get();
@@ -50,9 +53,9 @@ if ( ! isset($_REQUEST['action']))
echo '<DIV class="content" >';
$header=new Sort_Table();
- $header->add('Login',$base_url,"order by use_login asc","order by
use_login desc",'la','ld');
- $header->add('Nom',$base_url,"order by use_name asc,use_first_name
asc","order by use_name desc,use_first_name desc",'na','nd');
- $header->add('Type d\'utilisateur',$base_url,"order by use_admin
asc,use_login asc","order by use_admin desc,use_login desc",'ta','td');
+ $header->add(_('Login'),$base_url,"order by use_login asc","order by
use_login desc",'la','ld');
+ $header->add(_('Nom'),$base_url,"order by use_name asc,use_first_name
asc","order by use_name desc,use_first_name desc",'na','nd');
+ $header->add(_("Type d'utilisateur"),$base_url,"order by use_admin
asc,use_login asc","order by use_admin desc,use_login desc",'ta','td');
$order=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'la';
@@ -78,8 +81,8 @@ if ( ! isset($_REQUEST['action']))
echo "<tr>";
echo '<th>'.$header->get_header(0).'</th>';
echo '<th>'.$header->get_header(1).'</th>';
- echo th('prénom');
- echo th('profil');
+ echo th(_('prénom'));
+ echo th(_('profil'));
echo '<th>'.$header->get_header(2).'</th>';
for ($i = 0;$i < $MaxUser;$i++)
{
@@ -113,7 +116,7 @@ $action="";
if ( isset ($_GET["action"] ))
{
- $action=$_GET["action"];
+ $action=$http->get("action");
}
//----------------------------------------------------------------------
@@ -124,36 +127,15 @@ if ( isset($_POST['ok']))
try
{
$cn->start();
- $sec_User=new User($cn,$_POST['user_id']);
-
- // save profile
- $sec_User->save_profile($_POST['profile']);
-
- /* Save first the ledger */
- $a=$cn->get_array('select jrn_def_id from jrn_def');
-
- foreach ($a as $key)
- {
- $id=$key['jrn_def_id'];
- $priv=sprintf("jrn_act%d",$id);
- $count=$cn->get_value('select count(*) from user_sec_jrn where
uj_login=$1 '.
- ' and
uj_jrn_id=$2',array($sec_User->login,$id));
- if ( $count == 0 )
- {
- $cn->exec_sql('insert into user_sec_jrn
(uj_login,uj_jrn_id,uj_priv)'.
- ' values ($1,$2,$3)',
- array($sec_User->login,$id,$_POST[$priv]));
+ $user_id=$http->post('user_id',"numeric");
+ $sec_User=new User($cn,$user_id);
- }
- else
- {
- $cn->exec_sql('update user_sec_jrn set uj_priv=$1 where
uj_login=$2 and uj_jrn_id=$3',
- array($_POST[$priv],$sec_User->login,$id));
- }
- }
+
/* now save all the actions */
$a=$cn->get_array('select ac_id from action');
-
+ /*
+ * @todo must be replaced by ajax
+ */
foreach ($a as $key)
{
$id=$key['ac_id'];
@@ -199,10 +181,11 @@ if ( isset($_POST['ok']))
if ( $action == "view" )
{
$l_Db=sprintf("dossier%d",$gDossier);
- $return= HtmlInput::button_anchor('Retour à la
liste','?&ac='.$_REQUEST['ac'].'&'.dossier::get(),'retour');
+ $return= HtmlInput::button_anchor(_('Retour à la
liste'),'?&ac='.$_REQUEST['ac'].'&'.dossier::get(),_('retour'),"",'smallbutton');
$repo=new Database();
- $User=new User($repo,$_GET['user_id']);
+ $user_id=$http->get('user_id',"numeric");
+ $User=new User($repo,$user_id);
$admin=0;
$access=$User->get_folder_access($gDossier);
@@ -210,19 +193,19 @@ if ( $action == "view" )
if ($access=='R')
{
- $str=_(' Utilisateur normal');
+ $str=_('Utilisateur normal');
}
if ( $User->admin==1 )
{
- $str=' Administrateur';
+ $str=_('Administrateur');
$admin=1;
}
-
+ $str=" ".$str;
echo '<h2>'.h($User->first_name).' '.h($User->name).'
'.hi($User->login)."($str)</h2>";
- if ( $_GET['user_id'] == 1 )
+ if ( $user_id == 1 )
{
echo '<h2 class="notice"> '.
_("Cet utilisateur est administrateur, il a tous les droits").
@@ -255,58 +238,65 @@ if ( $action == "view" )
$Res=$cn->exec_sql("select jrn_def_id,jrn_def_name from jrn_def ".
" order by jrn_def_name");
- $sec_User=new User($cn,$_GET['user_id']);
+ $sec_User=new User($cn,$user_id);
+ $n_dossier_id=Dossier::id();
echo '<form method="post">';
$sHref=sprintf ('export.php?act=PDF:sec&user_id=%s&'.$str_dossier ,
- $_GET ['user_id']
+ $user_id
);
echo dossier::hidden();
echo HtmlInput::hidden('action','sec');
- echo HtmlInput::hidden('user_id',$_GET['user_id']);
- $i_profile=new ISelect ('profile');
- $i_profile->value=$cn->make_array("select p_id,p_name from profile
- order by p_name");
-
- $i_profile->selected=$sec_User->get_profile();
-
- echo "<p>";
- echo _("Profil")." ".$i_profile->input();
- echo "</p>";
- echo '<Fieldset><legend>Journaux </legend>';
+ echo HtmlInput::hidden('user_id',$user_id);
+ $i_profile=new ISelect ('profile');
+ $i_profile->id=uniqid("profile");
+ $i_profile->value=$cn->make_array("select p_id,p_name from profile
+ order by p_name");
+
+ $i_profile->selected=$sec_User->get_profile();
+ $ie_profile=new Inplace_Edit($i_profile);
+
+ $ie_profile->set_callback("ajax_misc.php");
+ $ie_profile->add_json_param("op", "profile");
+ $ie_profile->add_json_param("gDossier", $n_dossier_id);
+ $ie_profile->add_json_param("user_id", $user_id);
+ $ie_profile->add_json_param("profile_id", $i_profile->selected);
+
+ echo "<p>";
+ echo _("Profil")." ".$ie_profile->input();
+ echo "</p>";
+ echo '<Fieldset><legend>'._('Journaux').'</legend>';
echo HtmlInput::button("grant_all", _("Accès à tout"), " onclick=\"
grant_ledgers ('W') \"");
echo HtmlInput::button("grant_readonly", _("Uniquement Lecture"), "
onclick=\" grant_ledgers ('R') \"");
echo HtmlInput::button("revoke_all", _("Aucun accès"), " onclick=\"
grant_ledgers ('X') \"");
echo '<table>';
$MaxJrn=Database::num_row($Res);
- $jrn_priv=new ISelect();
+ $jrn_priv=new ISelect("iledger");
$array=array(
array ('value'=>'R','label'=>_('Uniquement lecture')),
array ('value'=>'W','label'=>_('Lecture et écriture')),
array ('value'=>'X','label'=>_('Aucun accès'))
);
-
for ( $i =0 ; $i < $MaxJrn; $i++ )
{
/* set the widget */
$l_line=Database::fetch_array($Res,$i);
-
+ $jrn_priv->value=$array;
+ $jrn_priv->id="ledas".uniqid();
+ $ie_input=new Inplace_Edit($jrn_priv);
+ $ie_input->set_callback("ajax_misc.php");
+ $ie_input->add_json_param("jrn_def_id", $l_line['jrn_def_id']);
+ $ie_input->add_json_param("op", "ledger_access");
+ $ie_input->add_json_param("gDossier", $n_dossier_id);
+ $ie_input->add_json_param("user_id", $user_id);
+
$ie_input->set_value($sec_User->get_ledger_access($l_line['jrn_def_id']));
echo '<TR> ';
if ( $i == 0 ) echo '<TD class="num"> <B> Journal </B> </TD>';
else echo "<TD></TD>";
echo "<TD class=\"num\"> $l_line[jrn_def_name] </TD>";
-
- $jrn_priv->name='jrn_act'.$l_line['jrn_def_id'];
- $jrn_priv->value=$array;
- if ($admin != 1)
-
$jrn_priv->selected=$sec_User->get_ledger_access($l_line['jrn_def_id']);
- else
- $jrn_priv->selected='W';
-
-
echo '<td>';
- echo $jrn_priv->input();
+ echo $ie_input->input();
echo '</td>';
echo '</tr>';
}
@@ -329,16 +319,35 @@ if ( $action == "view" )
?>
<script>
function grant_ledgers(p_access) {
- var a_select=document.getElementsByTagName('select');
+ waiting_box();
+ var a_select=document.getElementsByTagName('span');
var i=0;
var str_id="";
for (i = 0;i < a_select.length;i++) {
str_id = new String( a_select[i].id);
- if ( str_id.search(/jrn_act/) > -1 ) {
- a_select[i].value=p_access;
- }
+ if ( str_id.search(/ledas/) > -1 ) {
+ if ( p_access==="W") {
+ a_select[i].innerHTML="<?php echo _("Lecture et écriture");?>";
+ } else if (p_access === "R") {
+ a_select[i].innerHTML="<?php echo _("Uniquement lecture");?>";
+ } else if (p_access === "X") {
+ a_select[i].innerHTML="<?php echo _("Aucun accès");?>";
+ }
+
}
}
+
+ new Ajax.Request("ajax_misc.php",{method:"post",
+ parameters:{
+ op:"ledger_access_all",
+ gDossier:<?php echo $n_dossier_id?>,
+ method:"get",
+ user_id:<?php echo $user_id;?>,
+ access:p_access
+ }
+ });
+ remove_waiting_box();
+ }
function grant_action(p_value) {
var a_select=document.getElementsByTagName('select');
var i=0;
diff --git a/scenario/inplace_edit.test.php b/scenario/inplace_edit.test.php
index c9ffd98..c3d3a83 100644
--- a/scenario/inplace_edit.test.php
+++ b/scenario/inplace_edit.test.php
@@ -40,9 +40,30 @@ if (!isset($_REQUEST["TestAjaxFile"])) {
$ajax_hello->set_callback("ajax_test.php");
$ajax_hello->add_json_param("TestAjaxFile", __FILE__) ;
$ajax_hello->add_json_param("gDossier", Dossier::id());
- echo "#".$ajax_hello->input()."#";
+ echo "TEXT #".$ajax_hello->input()."#";
+ $select = new ISelect ("ajax_select");
+ $select->id=uniqid("sel");
+ $select->value=[
+ ["value"=>1,"label"=>"ONE"],
+ ["value"=>2,"label"=>"TWO"],
+ ["value"=>3,"label"=>"THREE"],
+ ];
+ $select->selected="2";
+ $ajax_select = new Inplace_Edit($select);
+ $ajax_select->set_callback("ajax_test.php");
+ $ajax_select->add_json_param("TestAjaxFile", __FILE__) ;
+ $ajax_select->add_json_param("gDossier", Dossier::id());
+ echo "SELECT #".$ajax_select->input()."#";
+ $date=new IDate("today");
+ $date->value=date("d.m.Y");
+ $date->id=uniqid("date");
+ $ajax_date = new Inplace_Edit($date);
+ $ajax_date->set_callback("ajax_test.php");
+ $ajax_date->add_json_param("TestAjaxFile", __FILE__) ;
+ $ajax_date->add_json_param("gDossier", Dossier::id());
+ echo "DATE #".$ajax_date->input()."#";
} else {
/*************************************************
* Ajax answer
- [Noalyss-commit] [noalyss] branch master updated (1d55507 -> 689dfc2), Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 51/219: task #0001463: Calculatrice - 4 décimales, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 41/219: SQL : protection injection, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 23/219: improve doc, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 48/219: Rewriting for PLANANC ajax add, delete and update analytic accounting, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 84/219: Improve appearance, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 65/219: CFGSEC : the ledgers are now updated thanks an inplace class,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 105/219: CSS : change menu, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 06/219: Fix bug and esthetic : the var. dep can be empty, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 09/219: profil : CFGPRO , correct, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 72/219: Warning : use new icon, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 36/219: Task #0001411: Faire des boutons du menu des... boutons. uniquement classic & light, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 66/219: CFGSEC : action and ledger are set thanks ajax Inplace_Switch : new class for ajax with a swith button, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 96/219: esthetic style-r692 : size icon, arrow ..., Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 04/219: Translation, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 01/219: new coding convention , Change File name : class_ becomes file.class.php, Dany De Bontridder, 2017/12/18
- [Noalyss-commit] [noalyss] 37/219: Task #0001411: Faire des boutons du menu des... boutons Ajout nouveau style-r692, Dany De Bontridder, 2017/12/18