CCARD : rewrite
This commit is contained in:
parent
b5aa321d93
commit
14cc18d9a9
9 changed files with 433 additions and 116 deletions
|
|
@ -350,6 +350,8 @@ $path = array(
|
|||
"check_vatnumber"=>"ajax_check_vatnumber",
|
||||
// Tax Detail
|
||||
"tax_detail"=>"ajax_tax_detail"
|
||||
// card category definition : from CCARD
|
||||
,"category_card_definition"=>"ajax_category_card_definition"
|
||||
) ;
|
||||
|
||||
if (array_key_exists($op, $path)) {
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ span.even {
|
|||
display:block;
|
||||
}
|
||||
/* highlight table row */
|
||||
div.odd,tr.odd {
|
||||
div.odd,tr.odd,li.odd {
|
||||
background-color: #DCE7F5;
|
||||
/*! opacity: 50%; */
|
||||
}
|
||||
|
|
@ -1788,9 +1788,9 @@ td.workday ol {
|
|||
}
|
||||
input.inum {
|
||||
text-align:right;
|
||||
border:1px solid #0000FF;
|
||||
border:1px solid #4b4b91;
|
||||
margin:2px;
|
||||
border-radius: 2px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
div.box {
|
||||
background-color:#e4e7ed;
|
||||
|
|
@ -3458,4 +3458,8 @@ li.li-active {
|
|||
padding: 0.5rem;
|
||||
color:navy !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.hoverclass-drag {
|
||||
background-color: white;
|
||||
}
|
||||
253
html/js/card.js
253
html/js/card.js
|
|
@ -89,7 +89,7 @@ function search_card(obj)
|
|||
var amount_from_type=0;
|
||||
if ( obj.amount_from_type) {
|
||||
amount_from_type=obj.amount_from_type;
|
||||
|
||||
|
||||
}
|
||||
if ( jrn==undefined)
|
||||
{
|
||||
|
|
@ -117,10 +117,10 @@ function search_card(obj)
|
|||
if ( $('search_card') ) {
|
||||
removeDiv('search_card');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
waiting_box();
|
||||
|
||||
|
||||
|
||||
var action=new Ajax.Request ( 'ajax_misc.php',
|
||||
{
|
||||
|
|
@ -236,7 +236,7 @@ function action_concerned_list(p_obj) {
|
|||
/**
|
||||
* Display form for searching cards to add to action-follow-up
|
||||
*@see ajax_add_concerned_card.php
|
||||
*@param {object} obj form object
|
||||
*@param {object} obj form object
|
||||
*@param obj.elements.ag_id id of the action (elements)
|
||||
*@param obj.elements.gDossier folder id
|
||||
*@param obj.elements.query
|
||||
|
|
@ -251,16 +251,16 @@ function action_concerned_search_card(obj)
|
|||
var search_in=-1;
|
||||
var inactive_card=0;
|
||||
var search_cat=-1;
|
||||
|
||||
|
||||
if (obj.dossier) {
|
||||
dossier = obj.dossier; /* From the button */
|
||||
}
|
||||
}
|
||||
if (obj.ag_id) {
|
||||
ag_id=obj.ag_id;
|
||||
}
|
||||
/* from the form */
|
||||
if (obj.elements) {
|
||||
if (obj.elements['gDossier'])
|
||||
if (obj.elements['gDossier'])
|
||||
{
|
||||
dossier = obj.elements['gDossier'].value;
|
||||
}
|
||||
|
|
@ -400,12 +400,12 @@ function search_get_card(obj)
|
|||
{
|
||||
queryString+="&ctl="+obj.ctl;
|
||||
}
|
||||
if ( obj.elements['accvis'] )
|
||||
if ( obj.elements['accvis'] )
|
||||
{
|
||||
queryString+="&accvis="+$F('accvis');
|
||||
} else {
|
||||
queryString+="&accvis=0";
|
||||
}
|
||||
}
|
||||
if ( obj.elements['amount_from_type']) {
|
||||
queryString+="&amount_from_type="+obj.elements['amount_from_type'].value;
|
||||
}
|
||||
|
|
@ -418,7 +418,7 @@ function search_get_card(obj)
|
|||
|
||||
queryString=encodeURI(queryString);
|
||||
$('asearch').innerHTML=loading();
|
||||
|
||||
|
||||
var action=new Ajax.Request ( 'ajax_misc.php',
|
||||
{
|
||||
method:'get',
|
||||
|
|
@ -436,7 +436,7 @@ function result_card_search(req)
|
|||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
remove_waiting_box();
|
||||
if ( req.responseText == 'NOCONX') { reconnect();return;}
|
||||
var answer=req.responseXML;
|
||||
|
|
@ -452,7 +452,7 @@ function result_card_search(req)
|
|||
var nodeXml=html[0];
|
||||
var code_html=getNodeText(nodeXml);
|
||||
code_html=unescape_xml(code_html);
|
||||
|
||||
|
||||
var sx=0;
|
||||
if ( window.scrollY)
|
||||
{
|
||||
|
|
@ -465,9 +465,9 @@ function result_card_search(req)
|
|||
|
||||
var div_style="top:"+sx+"px;min-height:80%;height:auto";
|
||||
add_div({id:'search_card',cssclass:'inner_box',html:"",style:div_style,drag:false,effect:'blinddown'});
|
||||
|
||||
|
||||
$('search_card').innerHTML=code_html;
|
||||
|
||||
|
||||
if ($('query')) { $('query').focus();}
|
||||
}
|
||||
catch (e)
|
||||
|
|
@ -715,7 +715,7 @@ function select_card_type(obj)
|
|||
waiting_box();
|
||||
var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':"",'drag':false};
|
||||
|
||||
|
||||
|
||||
|
||||
var queryString='gDossier='+dossier;
|
||||
queryString+='&ctl='+content;
|
||||
|
|
@ -754,10 +754,10 @@ function select_card_type(obj)
|
|||
method:'get',
|
||||
parameters:queryString,
|
||||
onFailure:errorFid,
|
||||
onSuccess:function(req) {
|
||||
onSuccess:function(req) {
|
||||
if (req.responseText=='NOCONX') { reconnect(); return;}
|
||||
add_div(popup);
|
||||
// Get all the category,
|
||||
// Get all the category,
|
||||
var answer=req.responseXML.getElementsByTagName("fiche_cat_item");
|
||||
if (answer.length == 0) {
|
||||
removeDiv(content);
|
||||
|
|
@ -806,7 +806,7 @@ function dis_blank_card(obj)
|
|||
var str_style="top:"+nTop+"px;right:"+nLeft+"px;height:auto;width:45rem;";
|
||||
|
||||
var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':false};
|
||||
|
||||
|
||||
add_div(popup);
|
||||
|
||||
if ( obj.gDossier.value != undefined ) {
|
||||
|
|
@ -831,8 +831,8 @@ function dis_blank_card(obj)
|
|||
parameters:queryString,
|
||||
onFailure:errorFid,
|
||||
onSuccess: function (req,json) {
|
||||
|
||||
|
||||
|
||||
|
||||
successFill_ipopcard(req,json);
|
||||
}
|
||||
}
|
||||
|
|
@ -848,7 +848,7 @@ function form_blank_card(obj)
|
|||
var str_style="top:"+nTop+"px;left:"+nLeft+"px;width:60em;height:auto";
|
||||
|
||||
var popup={'id': content,'cssclass':'inner_box','style':str_style,'html':loading(),'drag':true};
|
||||
if ( $(content)) {removeDiv(content);}
|
||||
if ( $(content)) {removeDiv(content);}
|
||||
add_div(popup);
|
||||
|
||||
|
||||
|
|
@ -913,12 +913,12 @@ function save_card(obj)
|
|||
if ( after_savetag.length !=0 ) {
|
||||
after_save=getNodeText(after_savetag[0]);
|
||||
}
|
||||
// if status == OK and after_save == 0
|
||||
// if status == OK and after_save == 0
|
||||
// then update the box
|
||||
if ( status_value == 'OK' && after_save == 0) {
|
||||
fill_box(req,json);
|
||||
}
|
||||
|
||||
|
||||
// if status == OK and after_save == 1
|
||||
// then add a row to the table
|
||||
if ( status_value == 'OK' && after_save == 1) {
|
||||
|
|
@ -934,10 +934,10 @@ function save_card(obj)
|
|||
row.addClassName("odd");
|
||||
} else {
|
||||
row.addClassName("even");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
remove_waiting_box();
|
||||
if ( elt.length != 0) {
|
||||
var eltid=getNodeText(elt[0]);
|
||||
|
|
@ -949,15 +949,15 @@ function save_card(obj)
|
|||
}
|
||||
}
|
||||
if (status_value == "OK") {
|
||||
Effect.SlideUp(content, { duration: 1.0 });
|
||||
Effect.SlideUp(content, { duration: 1.0 });
|
||||
}
|
||||
if ( status_value == 'NOK') {
|
||||
var xml_message=req.responseXML.getElementsByTagName("code");
|
||||
var message=getNodeText(xml_message[0]);
|
||||
smoke.alert(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -1126,7 +1126,7 @@ function action_save_concerned(p_form_id) {
|
|||
removeDiv('search_card');
|
||||
$('concerned_card_td').innerHTML = code_html;
|
||||
} catch (e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1158,9 +1158,9 @@ function action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
|
|||
code_html = unescape_xml(code_html);
|
||||
$('concerned_card_td').innerHTML = code_html;
|
||||
removeDiv('search_card');
|
||||
|
||||
|
||||
$(namectl).remove();
|
||||
|
||||
|
||||
} catch (e) {
|
||||
if ( console) { console.log('Erreur ') + e.message;}
|
||||
alert_box('action_remove_concerned '+e.message);
|
||||
|
|
@ -1172,7 +1172,7 @@ function action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
|
|||
/**
|
||||
* Remove a card after checking it is not used
|
||||
* @param obj {json} = gDossier,op,op2:rm_card,ctl,f_id
|
||||
*/
|
||||
*/
|
||||
function delete_card(obj) {
|
||||
smoke.confirm("Confirmez ? ", function (e) {
|
||||
if (e) {
|
||||
|
|
@ -1195,7 +1195,7 @@ function delete_card(obj) {
|
|||
var code_html = getNodeText(nodeXml);
|
||||
code_html = unescape_xml(code_html);
|
||||
if ( code_html == "OK") {
|
||||
Effect.Fade(obj['ctl'], { duration: 1.5 });
|
||||
Effect.Fade(obj['ctl'], { duration: 1.5 });
|
||||
} else {
|
||||
smoke.alert(code_html);
|
||||
}
|
||||
|
|
@ -1227,16 +1227,16 @@ function modify_card(p_fiche_id)
|
|||
var popup = {'id': content, 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': false};
|
||||
|
||||
add_div(popup);
|
||||
|
||||
|
||||
/* dossier id */
|
||||
if ( ! document.getElementById("card_gdossier")) {
|
||||
|
||||
|
||||
console.error("card_gdossier error");
|
||||
throw ("card_gdossier not set");
|
||||
}
|
||||
var dossier = $('card_gdossier').value;
|
||||
|
||||
|
||||
|
||||
var action = new Ajax.Request('ajax_misc.php',
|
||||
{
|
||||
method: 'get',
|
||||
|
|
@ -1258,7 +1258,7 @@ function delete_card_id(p_fiche_id)
|
|||
{
|
||||
var row="row_card"+p_fiche_id;
|
||||
if ( ! document.getElementById("card_gdossier")) {
|
||||
|
||||
|
||||
console.error("card_gdossier error");
|
||||
throw ("card_gdossier not set");
|
||||
}
|
||||
|
|
@ -1285,29 +1285,29 @@ function delete_card_id(p_fiche_id)
|
|||
var nodeXml = html[0];
|
||||
var code_html = getNodeText(nodeXml);
|
||||
code_html = unescape_xml(code_html);
|
||||
|
||||
|
||||
if ((code_html) == "OK") {
|
||||
Effect.Fade(row, {duration: 0.1});
|
||||
table_card.tBodies[0].removeChild($(row));
|
||||
alternate_row_color("fiche_tb_id");
|
||||
} else {
|
||||
smoke.alert(code_html);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
} else{
|
||||
} else{
|
||||
$(row).removeClassName("background-selected");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* update a card in ajax , and update a row
|
||||
*
|
||||
*
|
||||
*/
|
||||
function card_update_row(obj)
|
||||
{
|
||||
|
|
@ -1335,16 +1335,16 @@ function card_update_row(obj)
|
|||
var name_ctl = "row_card" + obj.f_id.value;
|
||||
var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
|
||||
code_html = unescape_xml(code_html);
|
||||
|
||||
|
||||
if ( document.getElementById(name_ctl)) {
|
||||
// update the row
|
||||
$(name_ctl).innerHTML = code_html;
|
||||
new Effect.Highlight(name_ctl ,{startcolor: '#FAD4D4',endcolor: '#F78082' });
|
||||
|
||||
|
||||
}
|
||||
$(a[0].firstChild.nodeValue).remove();
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (e) {
|
||||
alert_box(e.message);
|
||||
if (console) {
|
||||
|
|
@ -1361,8 +1361,8 @@ function card_update_row(obj)
|
|||
}
|
||||
alert_box(content[53] + "\n" + e.message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -1392,7 +1392,7 @@ function linked_card_option(p_action_person_id,p_dossier) {
|
|||
remove_waiting_box();
|
||||
add_div({ "id":"d_linked_card_option",cssclass:"inner_box",style:"position:fixed;top:30%;min-width:20rem;width:auto;",drag:0});
|
||||
$("d_linked_card_option").update(req.responseText);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
@ -1400,8 +1400,8 @@ function linked_card_option(p_action_person_id,p_dossier) {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Save option for the contact
|
||||
* @param {object} obj form
|
||||
* Save option for the contact
|
||||
* @param {object} obj form
|
||||
* @see card_multiple_display_option.php
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
|
@ -1420,3 +1420,148 @@ function save_linked_card_option(obj)
|
|||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* Manage adding, removing and ordering attributs of a card template (FICHE_DEF), used in the module CCARD
|
||||
* @param dossier_id {int} Folder
|
||||
* @param fiche_def_id {int} SQL : FICHE_DEF.FD_ID
|
||||
*/
|
||||
var CategoryCardDefinition = function (dossier_id, fiche_def_id) {
|
||||
this.dossier_id = dossier_id;
|
||||
this.fiche_def_id = fiche_def_id;
|
||||
this.available_list = 'avail_attribut_id';
|
||||
this.existing_list = 'attribut_card';
|
||||
this.op = 'category_card_definition';
|
||||
}
|
||||
/**
|
||||
* save the order + new attributes, remove old ones
|
||||
*/
|
||||
CategoryCardDefinition.prototype.save = function () {
|
||||
|
||||
try {
|
||||
var aAttribut=Sortable.serialize(this.existing_list);
|
||||
var queryString = {
|
||||
gDossier: this.dossier_id,
|
||||
fiche_def_id: this.fiche_def_id,
|
||||
op: this.op,
|
||||
op2: 'save',
|
||||
attribut:aAttribut
|
||||
};
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php",
|
||||
{
|
||||
method: 'POST',
|
||||
parameters: queryString,
|
||||
onFailure: ajax_misc_failure,
|
||||
onSuccess: function (req) {
|
||||
if (req.responseText == 'NOCONX') {
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
if ( req.responseText == 'OK') {
|
||||
smoke.signal('Sauvé',function(e){},{duration:500});
|
||||
}
|
||||
// if successfull add id on existing_list and remove from available_list
|
||||
console.debug(here);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
alert_box("CategoryCardDefinition.save" + e.message);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* add an attribut from the DOM Element avail_attribut_id , do add an element in attribut_card and remove from avail_attribut_id
|
||||
* @param attribut_id {int} attr_def.ad_id , ad_id of attribute
|
||||
*/
|
||||
CategoryCardDefinition.prototype.add_attribut = function (attribut_id) {
|
||||
var here = this;
|
||||
console.debug(`add ${attribut_id}`);
|
||||
try {
|
||||
|
||||
var queryString = {
|
||||
gDossier: this.dossier_id,
|
||||
fiche_def_id: this.fiche_def_id,
|
||||
op: this.op,
|
||||
op2: 'add',
|
||||
ad_id: attribut_id
|
||||
};
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php",
|
||||
{
|
||||
method: 'GET',
|
||||
parameters: queryString,
|
||||
onFailure: ajax_misc_failure,
|
||||
onSuccess: function (req) {
|
||||
if (req.responseText == 'NOCONX') {
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// if successfull add id on existing_list and remove from available_list
|
||||
console.debug(here);
|
||||
// remove from available_list
|
||||
$('avail_attr_' + attribut_id).remove();
|
||||
alternate_row_color_list(here.available_list);
|
||||
var parser = new DOMParser();
|
||||
var element = parser.parseFromString(req.responseText, 'text/html');
|
||||
$(here.existing_list).appendChild(element.body.firstChild);
|
||||
new Effect.Highlight('existing_attr_' + attribut_id, {
|
||||
startcolor: '#FAD4D4',
|
||||
endcolor: '#F78082'
|
||||
});
|
||||
Sortable.create('attribut_card', {tag: 'li'});
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
alert_box("CategoryCardDefinition.add_attribut" + e.message);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* remove an attribut from the DOM Element attribut_card , do add an element in avail_attribut_id and remove from attribut_card
|
||||
* @param attribut_id {int} attr_def.ad_id , ad_id of attribute
|
||||
*/
|
||||
CategoryCardDefinition.prototype.remove_attribut = function (attribut_id) {
|
||||
console.debug(`remove ${attribut_id}`);
|
||||
var here = this;
|
||||
try {
|
||||
|
||||
var queryString = {
|
||||
gDossier: this.dossier_id,
|
||||
fiche_def_id: this.fiche_def_id,
|
||||
op: this.op,
|
||||
op2: 'remove',
|
||||
ad_id: attribut_id
|
||||
};
|
||||
var action = new Ajax.Request(
|
||||
"ajax_misc.php",
|
||||
{
|
||||
method: 'GET',
|
||||
parameters: queryString,
|
||||
onFailure: ajax_misc_failure,
|
||||
onSuccess: function (req) {
|
||||
if (req.responseText == 'NOCONX') {
|
||||
reconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// if successfull add id on existing_list and remove from available_list
|
||||
console.debug(here);
|
||||
// remove from available_list
|
||||
$('existing_attr_' + attribut_id).remove();
|
||||
var parser = new DOMParser();
|
||||
var element = parser.parseFromString(req.responseText, 'text/html');
|
||||
$(here.available_list).appendChild(element.body.firstChild);
|
||||
|
||||
alternate_row_color_list(here.available_list);
|
||||
Sortable.create('attribut_card', {tag: 'li', hoverclass: inner_box});
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
alert_box("CategoryCardDefinition.remove_attribut" + e.message);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
77
include/ajax/ajax_category_card_definition.php
Normal file
77
include/ajax/ajax_category_card_definition.php
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 7/08/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief ajax from CCARD : add , remove or sort attributes from CCARD
|
||||
*/
|
||||
if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
|
||||
global $g_user;
|
||||
|
||||
if ($g_user->check_module('CCARD') == 0) return;
|
||||
$http = new HttpInput();
|
||||
try {
|
||||
$fiche_def = $http->request('fiche_def_id', 'number');
|
||||
$op2 = $http->request("op2");
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
global $cn;
|
||||
|
||||
if ($op2 == 'add') {
|
||||
$ad_id=$http->get("ad_id","number");
|
||||
$row = $cn->get_row('select ad_id , ad_text from attr_def where ad_id=$1',[$ad_id]);
|
||||
Fiche_Def::print_existing_attribut($row['ad_id'], $row['ad_text']);
|
||||
|
||||
} elseif ($op2 == 'remove') {
|
||||
$ad_id=$http->get("ad_id","number");
|
||||
$row = $cn->get_row('select ad_id , ad_text from attr_def where ad_id=$1',[$ad_id]);
|
||||
Fiche_Def::print_available_attribut($row['ad_id'], $row['ad_text'],'');
|
||||
} elseif ($op2 == 'save') {
|
||||
|
||||
$str_Attribut=$http->post("attribut");
|
||||
parse_str($str_Attribut, $row);
|
||||
$aAttribut=$row['attribut_card'];
|
||||
$nb_attribut=count($aAttribut);
|
||||
try {
|
||||
$cn->start();
|
||||
$cn->exec_sql("create temporary table xxattribut (x_order int, x_adid int, x_fdid int)");
|
||||
$order = 10;
|
||||
for( $i = 0;$i < $nb_attribut;$i++) {
|
||||
$o=$order*($i+1);
|
||||
$cn->exec_sql("insert into xxattribut values ($1,$2,$3)",[$o,$aAttribut[$i],$fiche_def]);
|
||||
}
|
||||
$cn->exec_sql("delete from jnt_fic_attr where fd_id=$1 and ad_id not in (select x_adid from xxattribut)",[$fiche_def]);
|
||||
$cn->exec_sql("insert into jnt_fic_attr(ad_id,fd_id,jnt_order)
|
||||
select x_adid,x_fdid,x_order
|
||||
from xxattribut
|
||||
on conflict do nothing ");
|
||||
$cn->exec_sql('update jnt_fic_attr set jnt_order = x_order from xxattribut where ad_id=x_adid and fd_id=x_fdid');
|
||||
$cn->commit();
|
||||
echo 'OK';
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
$cn->rollback();
|
||||
}
|
||||
|
||||
} else {
|
||||
die("[$op2] action inconnue");
|
||||
}
|
||||
|
|
@ -879,5 +879,26 @@ $order
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief display existing attribut
|
||||
* @param $attribut_id int SQL attr_def.ad_id
|
||||
* @param $attribut_text SQL attr_def.ad_text
|
||||
* @return void
|
||||
*/
|
||||
public static function print_existing_attribut($attribut_id,$attribut_text)
|
||||
{
|
||||
include NOALYSS_TEMPLATE.'/fiche_def-print_existing_attribut.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief display available attribut
|
||||
* @param $attribut_id int SQL attr_def.ad_id
|
||||
* @param $attribut_text SQL attr_def.ad_text
|
||||
* @return void
|
||||
*/
|
||||
public static function print_available_attribut($attribut_id,$attribut_text,$class)
|
||||
{
|
||||
include NOALYSS_TEMPLATE.'/fiche_def-print_available_attribut.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class INum extends IText
|
|||
parent::__construct($name, $value, $id);
|
||||
|
||||
$this->size=9;
|
||||
$this->style='class="inum"';
|
||||
$this->style='class="inum input_text"';
|
||||
$this->javascript='onchange="format_number(this,2);"';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,86 +41,69 @@ $available_attribut = $cn->get_array('
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>Attributs de la classe</h3>
|
||||
<div id="attribut_card">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($existing_attribut
|
||||
|
||||
as $item):
|
||||
$class = ($i % 2 == 0) ? 'even' : 'odd';
|
||||
$i++;
|
||||
?>
|
||||
|
||||
<div id="attr_<?=$item['jnt_id']?>" style="cursor: move;" class="<?= $class ?>" order="<?= $item['jnt_order'] ?>">
|
||||
|
||||
|
||||
<ul id="attribut_card" class="list-unstyled" style="cursor: move;">
|
||||
<?php
|
||||
echo $item['ad_text'];
|
||||
?>
|
||||
<div style="float:right">
|
||||
<?=\Icon_Action::trash("0","")?>
|
||||
</div>
|
||||
</div>
|
||||
$i = 0;
|
||||
foreach ($existing_attribut as $item):
|
||||
|
||||
Fiche_Def::print_existing_attribut($item['ad_id'], $item['ad_text']);
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class=" col-2">
|
||||
<h4> Ranger les attributs</h4>
|
||||
<p>
|
||||
Supprimer un attribut n'est pas réversible: les données de ces attributs
|
||||
Déplacer les attributs de la fiche en cliquant et déplacer sans relacher le bouton de la souris.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Supprimer un attribut n'est pas réversible:() les données de ces attributs
|
||||
seront définitivement perdus.
|
||||
</p>
|
||||
<!-- <input type="submit" class="button" value="Sauver les attributs">-->
|
||||
<p>
|
||||
Ajouter des attributs depuis les attributs disponibles en cliquant sur la flèche.
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" class="button" onclick="categoryCardDefinition.save();return false" value="Sauve">
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col border-dark">
|
||||
<h3>Attributs disponibles</h3>
|
||||
<?php
|
||||
echo HtmlInput::filter_table("avail_attribut_id", '0', '0');
|
||||
?>
|
||||
<table id="avail_attribut_id" style="width: 90%">
|
||||
<div class="col border-dark">
|
||||
<h3>Attributs disponibles</h3>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($available_attribut as $item):
|
||||
$class = ($i % 2 == 0) ? 'even' : 'odd';
|
||||
$i++;
|
||||
echo HtmlInput::filter_list("avail_attribut_id", '0', '0');
|
||||
?>
|
||||
<tr class="<?= $class ?>">
|
||||
<td>
|
||||
<?php
|
||||
// ajout de l'attribut donc cette ligne disparait, et apparait de l'autre cote + maj db
|
||||
$js_add=sprintf("f")
|
||||
?>
|
||||
|
||||
<span class="icon" onclick="<?=$js_add?>">⇦</span>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
|
||||
<?php
|
||||
echo $item['ad_text'];
|
||||
?>
|
||||
</td>
|
||||
<ul id="avail_attribut_id" style="width: 90%" class="list-unstyled">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($available_attribut as $item):
|
||||
$class = ($i % 2 == 0) ? 'even' : 'odd';
|
||||
$i++;
|
||||
Fiche_Def::print_available_attribut($item['ad_id'], $item['ad_text'], $class);
|
||||
?>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
</table>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
Sortable.create('attribut_card', {tag: 'li',hoverclass:'hoverclass-drag'});
|
||||
})();
|
||||
|
||||
Sortable.create('attribut_card',{tag:'div',onChange:function(e) {console.debug(e)},onUpdate:function(e) { console.debug(e)}});
|
||||
|
||||
})();
|
||||
</script>
|
||||
var categoryCardDefinition=new CategoryCardDefinition(<?=Dossier::id()?>,<?=$this->id?>);
|
||||
</script>
|
||||
|
|
|
|||
43
include/template/fiche_def-print_available_attribut.php
Normal file
43
include/template/fiche_def-print_available_attribut.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 7/08/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief available attribut for card category
|
||||
*/
|
||||
|
||||
$js_add = sprintf("categoryCardDefinition.add_attribut('%s')",$attribut_id);
|
||||
?>
|
||||
<li id="avail_attr_<?= $attribut_id ?>" class="<?= $class ?>">
|
||||
<span>
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<span class="icon" onclick="<?= $js_add ?>">🠈</span>
|
||||
</span>
|
||||
|
||||
|
||||
<span class="search-content">
|
||||
|
||||
<?php
|
||||
echo $attribut_text;
|
||||
?>
|
||||
</span>
|
||||
</li>
|
||||
42
include/template/fiche_def-print_existing_attribut.php
Normal file
42
include/template/fiche_def-print_existing_attribut.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* NOALYSS 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.
|
||||
*
|
||||
* NOALYSS 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 NOALYSS; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright Author Dany De Bontridder danydb@aevalys.eu 7/08/24
|
||||
/*!
|
||||
* \file
|
||||
* \brief display existing attribut
|
||||
*/
|
||||
|
||||
$js_remove = sprintf("categoryCardDefinition.remove_attribut('%s')", $attribut_id);
|
||||
|
||||
?>
|
||||
<li class="hoverclass-drag" style="border:1px solid navy;margin:1px;padding:5px;"
|
||||
id="existing_attr_<?= $attribut_id ?>">
|
||||
|
||||
<span>
|
||||
|
||||
<?php
|
||||
echo $attribut_text;
|
||||
?>
|
||||
</span>
|
||||
<div style="float:right">
|
||||
<?php if ($attribut_id != 1 && $attribut_id != 23) : ?>
|
||||
<?= \Icon_Action::trash(uniqid(), $js_remove) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</li>
|
||||
Loading…
Add table
Add a link
Reference in a new issue