diff --git a/include/ajax_get_profile.php b/include/ajax_get_profile.php
index 1b7577f5f..468dd02df 100644
--- a/include/ajax_get_profile.php
+++ b/include/ajax_get_profile.php
@@ -82,6 +82,9 @@ Effacer ce profil';
echo $add_one;
echo "
Action gestion accessible
";
$profile_menu->available_profile($p_id);
+ echo "Dépôt de stock accessible
";
+ $profile_menu->available_repository($p_id);
+
}
?>
diff --git a/include/class_profile_menu.php b/include/class_profile_menu.php
index 06463e387..4b3baffb1 100644
--- a/include/class_profile_menu.php
+++ b/include/class_profile_menu.php
@@ -208,6 +208,10 @@ class Profile_Menu
$gDossier = Dossier::id();
$this->sub_menu($ret, $p_id);
}
+ /**
+ * Show the available profile for the profile $p_id, it concerns only the action of management (action-gestion)
+ * @param $p_id is the profile p_id
+ */
function available_profile($p_id)
{
$array=$this->cn->get_array("
@@ -228,7 +232,30 @@ class Profile_Menu
);
require_once 'template/user_sec_profile.php';
}
+ /**
+ * Show the available repository for the profile $p_id
+ * @param $p_id is the profile p_id
+ */
+ function available_repository($p_id)
+ {
+ $array=$this->cn->get_array("
+ select p.r_id,p.r_name,s.ur_id,s.ur_right
+ from stock_repository as p
+ join user_sec_repository as s on (s.r_id=p.r_id)
+ where s.p_id=$1
+ union
+ select p2.r_id, p2.r_name,null,'X'
+ from stock_repository as p2
+ where
+ p2.r_id not in (select r_id from user_sec_repository where p_id = $1) order by r_name;
+ ",array($p_id));
+ $aright_value=array(
+ array('value'=>'R','label'=>_('Lecture')),
+ array('value'=>'W','label'=>_('Ecriture')),
+ array('value'=>'X','label'=>_('Aucun accès'))
+ );
+ require_once 'template/user_sec_repository.php';
+ }
}
-
//end class
?>
\ No newline at end of file
diff --git a/include/class_stock_sql.php b/include/class_stock_sql.php
new file mode 100644
index 000000000..95e44e254
--- /dev/null
+++ b/include/class_stock_sql.php
@@ -0,0 +1,64 @@
+table = "public.stock_repository";
+ $this->primary_key = "r_id";
+
+ $this->name=array(
+ "id"=>"r_id",
+ "name"=>"r_name",
+ "adress"=>"r_adress",
+ "city"=>"r_city",
+ "country"=>"r_country",
+ "phone"=>"r_phone"
+ );
+
+ $this->type = array(
+ "r_id"=>"numeric",
+ "r_name"=>"text",
+ "r_adress"=>"text",
+ "r_city"=>"text",
+ "r_country"=>"text",
+ "r_phone"=>"text"
+
+ );
+
+ $this->default = array(
+ "r_id" => "auto",
+ );
+ global $cn;
+
+ parent::__construct($cn,$p_id);
+ }
+}
+?>
diff --git a/include/profile.inc.php b/include/profile.inc.php
index 8bca1dafe..f01b739ce 100644
--- a/include/profile.inc.php
+++ b/include/profile.inc.php
@@ -58,6 +58,41 @@ if (isset($_POST['change_profile']))
}
}
//**********************************************
+// Save avail. profiles
+//**********************************************
+if (isset($_POST['change_stock']))
+{
+ extract($_POST);
+ try
+ {
+ for ($e = 0; $e < count($right); $e++)
+ {
+ if ($right[$e] == 'X' && $ur_id[$e]=='')
+ continue;
+ if ($right[$e] == 'X' && $ur_id[$e]!='')
+ {
+ $cn->exec_sql("delete from user_sec_repository where p_id=$1 and r_id=$2", array($p_id, $ar_id[$e]));
+ continue;
+ }
+ if ($ur_id[$e] == "")
+ {
+ $cn->exec_sql("insert into user_sec_repository (p_id,r_id,ur_right) values($1,$2,$3)", array($p_id, $ar_id[$e], $right[$e]));
+ continue;
+ }
+ if ($ur_id[$e] != '')
+ {
+ $cn->exec_sql("update user_sec_repository set ur_right=$3 where p_id=$1 and r_id=$2 ", array($p_id, $ar_id[$e], $right[$e]));
+ continue;
+ }
+ }
+ }
+ catch (Exception $exc)
+ {
+ echo $exc->getTraceAsString();
+ throw $exc;
+ }
+}
+//**********************************************
// Save_name
// *********************************************
diff --git a/include/template/user_sec_repository.php b/include/template/user_sec_repository.php
new file mode 100644
index 000000000..8da5d5279
--- /dev/null
+++ b/include/template/user_sec_repository.php
@@ -0,0 +1,53 @@
+
+