$html
EOF;
diff --git a/include/ajax/ajax_add_concerned_card.php b/include/ajax/ajax_add_concerned_card.php
index 4322b13a5..90f3281b4 100644
--- a/include/ajax/ajax_add_concerned_card.php
+++ b/include/ajax/ajax_add_concerned_card.php
@@ -29,6 +29,7 @@ if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
require_once NOALYSS_INCLUDE.'/lib/http_input.class.php';
+require_once NOALYSS_INCLUDE.'/class/card_multiple.class.php';
$http=new HttpInput();
ob_start();
@@ -42,49 +43,86 @@ catch (Exception $exc)
error_log($exc->getTraceAsString());
return;
}
+/*
+ * security Who can do it ?
+ */
+if ( ! $g_user->can_write_action($ag_id) ) {
+ record_log(__FILE__."security : access refused");
+ return;
+}
require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
$r=HtmlInput::title_box(_("Détail fiche"), 'search_card');
-
-$r.='';
+
+
$query=$http->get("query", "string","");
$sql_array['query']=$query;
$sql_array['typecard']='all';
-$fiche=new Fiche($cn);
+$fiche=new Card_Multiple($cn);
/* Build the SQL and show result */
$sql=$fiche->build_sql($sql_array);
+$count_card=$fiche->count_sql($sql_array);
+//--------------------------------------------------------------------------------------------------------------------
+// Result
+//--------------------------------------------------------------------------------------------------------------------
/* We limit the search to MAX_SEARCH_CARD records */
-$sql=$sql.' order by vw_name limit '.MAX_SEARCH_CARD;
$a=$cn->get_array($sql);
+$r.='';
+
+
$response=ob_get_contents();
ob_end_clean();
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index 74a3d5b8f..e493da288 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -518,9 +518,11 @@ case 'fs':
require_once NOALYSS_INCLUDE.'/ajax/ajax_add_concerned_card.php';
return;
break;
- case 'action_save_concerned':
+// add several card to an action follow⁻up
+ case 'link_concerned_card':
require NOALYSS_INCLUDE.'/ajax/ajax_action_save_concerned.php';
return;
+// remove card from an action follow⁻up
case 'action_remove_concerned':
require NOALYSS_INCLUDE.'/ajax/ajax_action_remove_concerned.php';
return;
@@ -744,6 +746,23 @@ case 'upr':
}
}
break;
+ //---------------------------------------------------------------------------------------------------------------
+ // Display option of a contact in an action-followup
+ //---------------------------------------------------------------------------------------------------------------
+ case 'display_card_option':
+
+ require_once NOALYSS_INCLUDE.'/ajax/ajax_display_card_option.php';
+ return;
+ break;
+
+ //---------------------------------------------------------------------------------------------------------------
+ // Save option of a contact in an action-followup
+ //---------------------------------------------------------------------------------------------------------------
+ case 'save_card_option':
+ require_once NOALYSS_INCLUDE.'/ajax/ajax_save_card_option.php';
+ return;
+
+ break;
} // switch
$xml=escape_xml($html);
diff --git a/include/ajax/ajax_display_card_option.php b/include/ajax/ajax_display_card_option.php
new file mode 100644
index 000000000..464c2b574
--- /dev/null
+++ b/include/ajax/ajax_display_card_option.php
@@ -0,0 +1,44 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief display the options of a card
+ */
+require_once NOALYSS_INCLUDE."/class/card_multiple.class.php";
+
+$card_multiple=new Card_Multiple();
+try
+{
+ $ap_id=$http->get("ap_id");
+}
+catch (Exception $exc)
+{
+ echo $exc->getMessage();
+ record_log($exc->getMessage().$exc->getTraceAsString());
+}
+
+echo HtmlInput::title_box(_("Options contact"), "d_linked_card_option","close","","y");
+// display existing option
+$card_multiple->display_option($ap_id);
diff --git a/include/class/card_multiple.class.php b/include/class/card_multiple.class.php
new file mode 100644
index 000000000..2296d8046
--- /dev/null
+++ b/include/class/card_multiple.class.php
@@ -0,0 +1,102 @@
+
+
+/**
+ * @file
+ * @brief in follow-up , add multiple cards to an event, an action
+ */
+class Card_Multiple
+{
+
+ function __construct()
+ {
+
+ }
+
+ function build_sql($sql_array)
+ {
+ $cn=Dossier::connect();
+ $query=sql_string($sql_array['query']);
+
+ $string_sql="select *
+ from vw_fiche_attr
+ where
+ vw_name ilike '%$query%'
+ or quick_code ilike '%$query%'
+ order by vw_name
+ limit
+ ".MAX_CARD_SEARCH;
+ return $string_sql;
+ }
+
+ function count_sql($sql_array)
+ {
+ $cn=Dossier::connect();
+ $query=sql_string($sql_array['query']);
+
+ $string_sql="select count(*)
+ from vw_fiche_attr
+ where
+ vw_name ilike '%$query%'
+ or quick_code ilike '%$query%'";
+
+
+ return $cn->get_value($string_sql); ;
+ }
+ /**
+ *
+ * @global type $g_user
+ * @param type $ap_id
+ * @return type
+ */
+ function display_option($p_action_person_id)
+ {
+ global $g_user;
+ $cn=Dossier::connect();
+ // retrieve card id (fiche.f_id) and the ag_id (action_gestion.ag_id)
+ $tmp=$cn->get_row("select f_id,ag_id from action_person where ap_id=$1 ", [$p_action_person_id]);
+ if ($tmp==NULL)
+ {
+ record_log("CMDO.01nothing found ".var_export($_REQUEST, true));
+ return;
+ }
+ $fiche_id=$tmp['f_id'];
+ $ag_id=$tmp['ag_id'];
+ if ( ! $g_user->can_read_action($ag_id)) {
+ throw new Exception (_("CMCDO01"."Security"));
+ }
+ $sql="select
+ cor.cor_id,
+ cor.cor_label,
+ cor.cor_type,
+ coalesce (apo.ap_id,-1) as ap_id,
+ ap_value,
+ cor_value_select
+from
+contact_option_ref cor
+left join action_person_option apo on (cor.cor_id=apo.contact_option_ref_id)
+where action_person_id is null or action_person_id=$1";
+ $a_option=$cn->get_array($sql,[$p_action_person_id]);
+ require NOALYSS_TEMPLATE."/card_multiple_display_option.php";
+
+ }
+
+}
diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php
index 6734dd238..11b5f3ca6 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -1493,7 +1493,7 @@ class Follow_Up
$c=count($a_tag);
for ($e=0; $e<$c; $e++)
{
- echo '';
+ echo '';
echo $a_tag[$e]['t_tag'];
if ($g_user->can_write_action($this->ag_id)==true)
{
@@ -1670,14 +1670,16 @@ class Follow_Up
$a_linked=$this->db->get_array('select ap_id,f_id from action_person where ag_id=$1', array($this->ag_id));
if (count($a_linked)==0)
return "";
+ $dossier_id=Dossier::id();
for ($i=0; $i