diff --git a/include/ajax/ajax_save_card_option.php b/include/ajax/ajax_save_card_option.php new file mode 100644 index 000000000..6a6b36c8e --- /dev/null +++ b/include/ajax/ajax_save_card_option.php @@ -0,0 +1,60 @@ + + +if (!defined('ALLOWED')) + die('Appel direct ne sont pas permis'); + +/** + * @file + * @brief save option of card into action_person_option + */ + +try { + $ap_value=$http->post("ap_value","array",[]); + $ap_id=$http->post("ap_id","array",[]); + $cor_id=$http->post("cor_id","array",[]); + $fiche_id=$http->post("f_id"); + $ag_id=$http->post("ag_id"); + $action_person_id=$http->post("action_person_id"); +} catch (Exception $ex) { + record_log("ASCO01".$ex->getMessage().$ex->getTraceAsString()); + return; +} + +/// If cannot write we stop it +if ( ! $g_user->can_write_action($ag_id)) { + record_log("ASCO02 Security "); +} + +$nb=count($ap_value); +// nothing to save +if ($nb == 0) return; + +for ($i=0;$i<$nb; $i++) { + if ( $ap_id[$i] == -1 ) { + $cn->exec_sql("INSERT INTO public.action_person_option (ap_value, contact_option_ref_id, action_person_id) + VALUES($1, $2, $3) ", + [$ap_value[$i],$cor_id[$i],$action_person_id]); + } else { + $cn->exec_sql("UPDATE public.action_person_option SET ap_value=$1 WHERE ap_id=$2)", + [$ap_value[$i],$action_person_id]); + } +} \ No newline at end of file