window.globalAltDown=false;
window.CPA_cancelAlertButton=false;
window.preventClickReload_GD_gridLov2Combo=false;
Ext.onReady(function () {
Ext.override(Ext.ux.form.LovCombo, {
beforeBlur: Ext.emptyFn
});
var genKeypressListenerGlobal = new window.keypress.Listener();
genKeypressListenerGlobal.register_combo({
"keys" : "alt",
"on_keydown" : function() {
window.globalAltDown=true;
},
"on_keyup" : function(args) {
window.globalAltDown=false;
}
});
genKeypressListenerGlobal.simple_combo("esc", function() {
if(frichtee_getTotalOpenedWindows()==1) {
if(typeof(Ext.getCmp(frichtee_getLastItemOpenedWindows())) !== 'undefined') {
closeNav();
}
}
});
$j('#overlayDiv').click(function() {
if(frichtee_getTotalOpenedWindows()==1) {
if(typeof(Ext.getCmp(frichtee_getLastItemOpenedWindows())) !== 'undefined') {
closeNav();
}
}
});
});
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
function toObject(arr) {
var rv = {};
for (var i = 0; i < arr.length; ++i)
if (arr[i] !== undefined) rv[i] = arr[i];
return rv;
}
// when implementing the function remember to set the mode of the cobmbobox to local (and the autoload to true if the combobox is not load in a other way)
// this function return true if the queried value is in the store (only work when called by filterBy()) this fonction ignore the accent
// function used in tab_rechercheContact_moteur.php on the combobox formulaire_rechercherContactMesure_sexe
function customInStringFn(record, value) {
var recherche = this.query.toLowerCase();
var thisCombo = this.combo;
actualComboValue = Ext.getCmp(this.combo.id).getValue();
if(actualComboValue != '' && typeof(this.combo.separator) !== 'undefined') {
tabValues = actualComboValue.split(this.combo.separator);
comboStore = Ext.getCmp(this.combo.id).getStore();
let tabActualRawValues = new Array();
$j.each(tabValues, function(index,value) {
$j.each(thisCombo.store.snapshot.items,function(indexRecordCacheDatas, valueRecordCacheDatas) {
if(parseInt(valueRecordCacheDatas.data.id) == value) {
tabActualRawValues.push(thisCombo.store.snapshot.items[indexRecordCacheDatas].data[thisCombo.displayField]);
}
});
});
recherche = recherche.split(tabActualRawValues.join(thisCombo.separator+' ')).pop();
}
var recValue = record.get(thisCombo.displayField).toLowerCase();
//this is the accent that are replaced if you want to had one you need to add on this table and on the replace
var accentMap = {
'ъ':'-', 'Ъ':'-', 'ь':'-',
'â':'a', 'ǎ':'a', 'ą':'a', 'á':'a', 'ă':'a', 'ã':'a', 'å':'a', 'à':'a', 'א':'a', 'ǻ':'a', 'ā':'a', 'ä':'ae', 'æ':'ae', 'ǽ':'ae',
'ב':'b', 'Б':'b', 'þ':'b',
'ĉ':'c', 'ć':'c', 'ç':'c', 'ц':'c', 'צ':'c', 'ċ':'c', 'č':'c', 'ч':'ch',
'ד':'d', 'ď':'d', 'đ':'d', 'д':'d', 'ð':'d',
'є':'e', 'ע':'e', 'ę':'e', 'ĕ':'e', 'ē':'e', 'ė':'e', 'ě':'e','ê':'e', 'ə':'e', 'è':'e', 'ë':'e', 'é':'e',
'ƒ':'f', 'Ф':'f',
'ġ':'g', 'Г':'g', 'ĝ':'g', 'ğ':'g', 'ג':'g', 'Ґ':'g', 'ґ':'g', 'ģ':'g',
'ח':'h', 'ħ':'h', 'Ħ':'h', 'ĥ':'h', 'ה':'h',
'î':'i', 'ï':'i', 'í':'i', 'ì':'i', 'į':'i', 'ĭ':'i', 'ĩ':'i', 'ǐ':'i', 'и':'i', 'ї':'i', 'ī':'i', 'ij':'ij',
'й':'j', 'ĵ':'j', 'я':'ja', 'э':'je', 'ё':'jo', 'ю':'ju',
'ĸ':'k', 'כ':'k', 'к':'k', 'ķ':'k', 'ך':'k',
'ŀ':'l', 'ł':'l', 'ļ':'l', 'ĺ':'l', 'л':'l', 'ľ':'l', 'ל':'l',
'מ':'m', 'ם':'m', 'м':'m',
'ñ':'n', 'н':'n', 'ŋ':'n', 'נ':'n', 'ń':'n', 'ņ':'n', 'ʼn':'n', 'ň':'n',
'ő':'o', 'õ':'o', 'ô':'o', 'ŏ':'o', 'ō':'o', 'ø':'o', 'ǿ':'o', 'ǒ':'o', 'ò':'o', 'ơ':'o', 'ó':'o', 'œ':'oe', 'ö':'oe',
'פ':'p', 'ף':'p', 'п':'p',
'ק':'q',
'ŕ':'r', 'ř':'r', 'ŗ':'r', 'ר':'r',
'ș':'s', 'š':'s', 'ś':'s', 'ş':'s', 'ŝ':'s', 'щ':'sch', 'ш':'sh', 'ß':'ss',
'т':'t', 'ŧ':'t', 'ת':'t', 'ť':'t', 'ţ':'t', 'ț':'t', '™':'tm',
'ū':'u', 'ũ':'u', 'ư':'u', 'ų':'u', 'ŭ':'u', 'ů':'u', 'ű':'u', 'ǔ':'u', 'ù':'u', 'ú':'u', 'û':'u', 'ǚ':'u', 'ǜ':'u', 'ǖ':'u', 'ǘ':'u', 'ü':'ue',
'в':'v',
'ש':'w', 'ŵ':'w',
'ы':'y', 'ŷ':'y', 'ý':'y', 'ÿ':'y','Ы':'y',
'ž':'z', 'з':'z', 'ź':'z', 'ז':'z', 'ż':'z', 'ж':'zh',
};
tabRecherche = recherche.split(' ');
if(recherche == '') {
return true;
} else {
let rechercheElementOK = 0;
$j.each(tabRecherche, function(index,value) {
value = value.replace(/[ъЪьâǎąáăãåàאǻāäæǽבБþĉćçцצċčчדďđдðєעęĕēėěêəèëéƒФġГĝğגҐґģחħĦĥהîïíìįĭĩǐиїīijйĵяэёюĸכкķךŀłļĺлľלמםñнŋנńņʼnňőõôŏōøǿǒòơóœöפףпקŕřŗרșšśşŝщшßтŧתťţț™ūũưųŭůűǔùúûǚǜǖǘüвשŵыŷýÿЫžзźזżж]/g, function(match) {return accentMap[match];});
recValue = recValue.replace(/[ъЪьâǎąáăãåàאǻāäæǽבБþĉćçцצċčчדďđдðєעęĕēėěêəèëéƒФġГĝğגҐґģחħĦĥהîïíìįĭĩǐиїīijйĵяэёюĸכкķךŀłļĺлľלמםñнŋנńņʼnňőõôŏōøǿǒòơóœöפףпקŕřŗרșšśşŝщшßтŧתťţț™ūũưųŭůűǔùúûǚǜǖǘüвשŵыŷýÿЫžзźזżж]/g, function(match) {return accentMap[match];});
if (recValue.includes(value) || value.includes(recValue)) {
++rechercheElementOK;
}
});
if(rechercheElementOK==tabRecherche.length) {
return true;
}
}
}
Ext.override(Ext.data.GroupingStore, {
sort : function(fieldName, dir) {
if (this.remoteSort) {
return Ext.data.GroupingStore.superclass.sort.call(this, fieldName, dir);
}
var sorters = [];
//cater for any existing valid arguments to this.sort, massage them into an array of sorter objects
if (Ext.isArray(arguments[0])) {
sorters = arguments[0];
} else if (fieldName == undefined) {
//we preserve the existing sortInfo here because this.sort is called after
//clearGrouping and there may be existing sorting
sorters = this.sortInfo ? [this.sortInfo] : [];
} else {
//TODO: this is lifted straight from Ext.data.Store's singleSort function. It should instead be
//refactored into a common method if possible
var field = this.fields.get(fieldName);
if (!field) return false;
var name = field.name,
sortInfo = this.sortInfo || null,
sortToggle = this.sortToggle ? this.sortToggle[name] : null;
if (!dir) {
if (sortInfo && sortInfo.field == name) { // toggle sort dir
dir = (this.sortToggle[name] || 'ASC').toggle('ASC', 'DESC');
} else {
dir = field.sortDir;
}
}
this.sortToggle[name] = dir;
this.sortInfo = {field: name, direction: dir};
sorters = [this.sortInfo];
}
//add the grouping sorter object as the first multisort sorter
if (this.groupField) {
var groupDir = this.groupDir;
//Allow sorting groups
if (this.groupField === this.sortInfo.field)
groupDir = this.sortInfo.direction;
//We need to set the grouping direction according to the last sort that occured on
//the grouping field so that we don't break grouping while sorting on other fields.
//!Note: We avoid doing this during the first sort of a grouping action, otherwise
//it's overwriting the default grouping order.
else if (!Ext.isArray(arguments[0]))
groupDir = this.multiSortInfo.sorters[0].direction;
sorters.unshift({direction: groupDir, field: this.groupField});
}
return this.multiSort.call(this, sorters, dir);
}
});
Ext.ns('Ext.ux2.form'); // set up Ext.ux.form namespace
Ext.ux.form.myNumberField = Ext.extend(Ext.form.NumberField, {
initEvents : function(){
var allowed = this.baseChars + '';
if (this.allowDecimals) {
allowed += this.decimalSeparator;
allowed += "."; // << add comma
}
if (this.allowNegative) {
allowed += '-';
}
this.maskRe = new RegExp('[' + Ext.escapeRe(allowed) + ']');
Ext.form.NumberField.superclass.initEvents.call(this);
},
setValue : function(v){
v = Ext.isNumber(v) ? v : parseFloat(String(v).replace(',', "."));
return Ext.ux.form.myNumberField.superclass.setValue.call(this, v);
},
validateValue : function(value){
if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){
return false;
}
if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
return true;
}
value = parseFloat(String(value).replace(",", "."));
return Ext.ux.form.myNumberField.superclass.validateValue.call(this, value);
},
parseValue : function(value){
value = parseFloat(String(value).replace(",", "."));
return Ext.ux.form.myNumberField.superclass.parseValue.call(this, value);
}
});
Ext.reg('mynumberfield', Ext.ux.form.myNumberField);
function dblClick_elementsFicheEditorGrid_contrat(idElement, idGroupeElement, activeTab, boolInput_droits_readOnly, tabVars, dataStoreToReload) {
var store_elements_fiches = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_elements_fiches.php'
}),
reader: new Ext.data.JsonReader({}, [ 'id', 'intitule']),
remoteSort: false,
autoLoad:false
});
if(tabVars['post_estBudget']=='' && (tabVars['config_PERIODE_CONTRAT']=='true' || parseInt(tabVars['config_PERIODE_CONTRAT'])==1)) {
var afficherComboPeriodes = true;
} else {
var afficherComboPeriodes = false;
}
var formPanel_modifierElementFiche = new Ext.form.FormPanel({
frame: true,
bodyStyle:'padding:5px',
autoHeight:true,
standardSubmit: false,
method: 'POST',
title:'Informations générales',
baseCls: 'x-plain',
items: [
new Ext.form.FieldSet({
labelWidth:150,
collapsible: false,
title: 'Informations générales',
autoHeight: true,
items: [
new Ext.form.ComboBox({
hiddenName: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_groupeElement',
id: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_groupeElementId',
width:350,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_groupementsElements.php?idModule='+tabVars['arrayTypeModule_id']
}),
remoteSort: true,
autoLoad: false,
fields : [{type:'int', name:'id'},'intitule']
}),
triggerAction:'all',
valueField:'id',
minChars:1,
fieldLabel: 'Groupe d\'élément',
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'remote',
forceSelection:false,
listeners : {
select: function() {
var store = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getStore();
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').setValue('');
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId').setValue('');
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_totalId').setValue('');
store.load({ params: { groupeElement: this.getValue() }});
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').enable();
}
}
}),
new Ext.form.ComboBox({
hiddenName: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_element',
id: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId',
width:350,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_elements_fiches.php'
}),
remoteSort: true,
autoLoad: false,
fields : [ {type:'int', name:'id'}, {type:'int', name:'idTypeBudget'}, 'intitule']
}),
triggerAction:'all',
valueField:'id',
minChars:1,
disabled:false,
fieldLabel: 'Elément',
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'local',
forceSelection:false,
listeners:{
select:function(thisCustom, record) {
if(record.data.idTypeBudget>0) {
var store = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId').setValue(record.data.idTypeBudget);
}});
}
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/ajouter_element_fiche_contrat_calculerTotal.php',
params:{
idElement:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getValue(),
idElementEnregistre: idElement,
valeur:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId').getValue(),
idFiche:tabVars['arrayFiche_id'],
idProduction:tabVars['arrayFiche_idProduction'],
idRole:tabVars['arrayFiche_idRole'],
idContact:tabVars['arrayContact_id']
},
success: function(result, request) {
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_totalId').setValue(result.responseText);
}
});
}
}
}),
new Ext.form.ComboBox({
hideOnSelect:false,
id:'formulaireEditerStatutEcheance_statutId',
hiddenName: 'formulaireEditerStatutEcheance_statut',
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_statutEcheances.php',
}),
remoteSort: true,
autoLoad: false,
fields : ['id','intitule']
}),
triggerAction:'all',
valueField:'id',
fieldLabel:'Statut',
width:350,
listWidth:350,
forceSelection:false,
emptyText:'Choix...',
minChars:2,
queryParam:'term',
displayField:'intitule',
mode:'remote',
listeners:{
render:function() {
$j('#formulaireEditerStatutEcheance_statutId').parent().parent().parent().css('display', 'none');
},
}
}),
{
xtype:'mynumberfield',
fieldLabel: 'Valeur',
name: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeur',
id:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId',
decimalPrecision:5,
width:350,
listeners:{
blur:function() {
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/ajouter_element_fiche_contrat_calculerTotal.php',
params:{
idElement:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getValue(),
idElementEnregistre: idElement,
valeur:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId').getValue(),
idFiche:tabVars['arrayFiche_id'],
idProduction:tabVars['arrayFiche_idProduction'],
idRole:tabVars['arrayFiche_idRole'],
idContact:tabVars['arrayContact_id']
},
success: function(result, request) {
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_totalId').setValue(result.responseText);
}
});
}
}
},{
xtype:'numberfield',
id:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_totalId',
readOnly:true,
decimalPrecision:5,
fieldLabel: 'Total',
width:350
},{
xtype:'textfield',
fieldLabel: 'Note',
name: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_note',
id:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_noteId',
width:350
},
new Ext.form.ComboBox({
hiddenName: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat',
id: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContratId',
width:350,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_periodesContrat.php?idContrat='+tabVars['post_idFiche']
}),
remoteSort: true,
autoLoad: false,
fields : [{type:'int', name:'id'},'intitule']
}),
triggerAction:'all',
valueField:'id',
minChars:1,
fieldLabel: 'Période',
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'remote',
forceSelection:false,
}),
{
xtype:'datefieldplus',
fieldLabel: 'Date',
format:'d-m-Y',
submitFormat:'Y-m-d',
name: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat_estDate',
id:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat_estDateId',
width:150,
listeners:{
render:function() {
if(afficherComboPeriodes) {
$j('#formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat_estDateId').parent().parent().parent().css('display','none');
$j('#formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContratId').parent().parent().parent().css('display','block');
} else {
$j('#formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat_estDateId').parent().parent().parent().css('display','block');
$j('#formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContratId').parent().parent().parent().css('display','none');
}
}
}
},
]
}),
new Ext.form.FieldSet({
collapsible: false,
title: 'Budget',
labelWidth:150,
autoHeight: true,
items: [
new Ext.form.ComboBox({
hiddenName:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetItem',
id:'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetItemId',
width:500,
listWidth: 500,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_budgetItem.php?idProd='+tabVars['arrayFiche_idProduction'],
}),
baseParams:{
idTypeFiche:tabVars['arrayFiche_idTypeFiche'],
extraId:tabVars['budgetItemFiche'],
checkDroits23:1
},
remoteSort: true,
autoLoad: true,
fields : [{type:'int', name:'id'},'code_budget']
}),
triggerAction:'all',
valueField:'id',
emptyText:'Choix...',
queryParam:'term',
minChars: 2,
tpl: '{code_budget}
',
displayField:'code_budget',
fieldLabel:'Poste budgétaire',
mode:'remote',
}),
new Ext.form.ComboBox({
hiddenName: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetType',
id: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId',
width:350,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_budgetItemType.php'
}),
remoteSort: true,
autoLoad: true,
fields : [{type:'int', name:'id'},'intitule'],
}),
triggerAction:'all',
valueField:'id',
minChars:1,
fieldLabel: 'Type d\'imputation',
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'remote',
forceSelection:false,
})
]
}),
],
buttons: [{
text: 'Valider les modifications',
id:'btnSubmit_dblClick_elementsFicheEditorGrid_contratId',
disabled:boolInput_droits_readOnly,
handler: function(){
var messageErreur=''
/*
if(Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_typesProductionId').getValue()=='') {
var messageErreur = messageErreur + 'Le type n\'est pas renseigné
';
}
*/
if(messageErreur!='') {
$j.gritter.add({title: 'Erreur',text: messageErreur,image: '_img/notification/ko.png',sticky: false, time: '1000'});
} else {
if(!afficherComboPeriodes) {
var periodeContrat_estDate = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContrat_estDateId').getValueSubmitFormat()
} else {
var periodeContrat_estDate = '';
}
Ext.getCmp('btnSubmit_dblClick_elementsFicheEditorGrid_contratId').enableLoader();
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/editer_element_ficheContrat.php',
params:{
idElementEnregistre: idElement,
idModule:tabVars['arrayTypeModule_id'],
idBudgetItem:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetItemId').getValue(),
idBudgetType:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId').getValue(),
valeur:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId').getValue(),
note:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_noteId').getValue(),
groupement:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_groupeElementId').getValue(),
element:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getValue(),
periodeContrat:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_periodeContratId').getValue(),
statut:Ext.getCmp('formulaireEditerStatutEcheance_statutId').getValue(),
periodeContrat_estDate:periodeContrat_estDate
},
success: function() {
// dataStoreToReload.reload();
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_window').close();
}
});
}
},
iconCls:'save'
}],
listeners:{
show:function() {
//cls:'classifElement_module classifElement_module_',
if(typeof(Ext.getCmp('classifElement_module_'+tabVars['arrayTypeModule_id']+'Id')) !== 'undefined') {
Ext.getCmp('classifElement_module_'+tabVars['arrayTypeModule_id']+'Id').show();
}
}
}
});
formPanel_modifierElementFiche.getForm().load({
url: '_datasMysql/form_detailsFiche_elementEnregistre.php',
params: {
idElementEnregistre: idElement,
idModule:tabVars['arrayTypeModule_id']
},
success:function(form, action) {
var reponse = Ext.decode(action.response.responseText);
if(reponse.data.estEnfant==1) {
window.elementEnregistreEstEnfant=true;
} else {
window.elementEnregistreEstEnfant=false;
}
// Gestion des store des classif de type combobox
var storeBudgetType = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId').getStore();
storeBudgetType.load({
callback:function() {
ComboSetterCustom(Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetTypeId'),parseInt(reponse.data.idTypeBudget),false);
}
});
var storeStatutElement = Ext.getCmp('formulaireEditerStatutEcheance_statutId').getStore();
storeStatutElement.load({
callback:function() {
Ext.getCmp('formulaireEditerStatutEcheance_statutId').setValue(reponse.data.statut);
}
});
var storeBudgetItem = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetItemId').getStore();
storeBudgetItem.load({
callback:function() {
ComboSetterCustom(Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_budgetItemId'),parseInt(reponse.data.idBudgetItem),false);
}
});
var store = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_groupeElementId').getStore();
store.load({
callback:function() {
ComboSetterCustom(Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_groupeElementId'),parseInt(reponse.data.idGroupement),false);
var store2 = Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getStore();
store2.baseParams.groupeElement=reponse.data.idGroupement;
store2.load({
callback:function() {
ComboSetterCustom(Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId'),parseInt(reponse.data.idElement),false);
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/ajouter_element_fiche_contrat_calculerTotal.php',
params:{
idElement:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_elementId').getValue(),
idElementEnregistre: idElement,
valeur:Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_valeurId').getValue(),
idFiche:tabVars['arrayFiche_id'],
idProduction:tabVars['arrayFiche_idProduction'],
idRole:tabVars['arrayFiche_idRole'],
idContact:tabVars['arrayContact_id']
},
success: function(result, request) {
Ext.getCmp('formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_totalId').setValue(result.responseText);
}
});
}
});
}
});
var comboBudgetItem = new Ext.form.ComboBox({
hiddenName:'comboBudgetItemEditorGrid',
id:'comboBudgetItemEditorGridId',
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_budgetItem.php?idProd='+tabVars['arrayFiche_idProduction'],
}),
baseParams:{
idTypeFiche:tabVars['arrayFiche_idTypeFiche'],
extraId:tabVars['budgetItemFiche'],
checkDroits23:1
},
remoteSort: true,
autoLoad: false,
fields : [{type:'int', name:'id'},'code_budget']
}),
triggerAction:'all',
valueField:'id',
emptyText:'Choix...',
queryParam:'term',
displayField:'code_budget',
mode:'remote'
});
function formPanelGridComboBudgetItem_majDivDroite(idEcheance) {
$j('#formPanelGridComboBudgetItem_innerDroiteDiv').empty().append('
');
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/formPanelLoupeComboBudgetItem_innerDroiteDiv.php',
params: {
},
success: function (result,request) {
if(result.responseText!='') {
$j('#formPanelGridComboBudgetItem_innerDroiteDiv').empty().append(result.responseText);
var nbResultats = $j('#formPanelGridComboBudgetItem_innerDroiteDiv').find('div');
$j('#formPanelGridComboBudgetItem_innerDroiteFieldSetTitre').empty().append(nbResultats.length+' résultat(s) (cliquez pour sélectionner)');
$j('.formPanelLoupeComboBudgetItem_elementDiv').click(function() {
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/affecterBudgetItemEcheanceElementContrat.php',
params: {
id: idEcheance,
idBudgetItem:parseInt($j(this).attr('rel'))
},
success: function() {
gridEcheances_DS.reload();
Ext.getCmp('window_GridBudgetItemId').close();
$j.gritter.add({title: 'Confirmation',text: 'Modification effectuée',image: '_img/notification/ok.png',sticky: false, time: '1000'});
}
});
/*
var store = Ext.getCmp(''+idCombo+'').getStore();
store.baseParams.extraId=parseInt($j(this).attr('rel'));
var thisCustom = $j(this);
store.load({
callback:function() {
if(ComboSetterCustom(Ext.getCmp(''+idCombo+''),parseInt(thisCustom.attr('rel')),false)<0) {
$j.gritter.add({title: 'Erreur',text: 'Ce poste budgétaire n\'existe pas',image: '_img/notification/ko.png',sticky: false, time: '2000'});
} else {
Ext.getCmp('window_GridBudgetItemId').close();
}
}
});
*/
});
} else {
$j('#formPanelGridComboBudgetItem_innerDroiteDiv').empty().append('Aucun résultat trouvé');
$j('#formPanelGridComboBudgetItem_innerDroiteFieldSetTitre').empty().append('Résultats de la recherche');
}
}
});
}
var gridEcheances_DS = new Ext.data.Store({
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/grid_echeances_elementContrat.php',
method: 'POST'
}),
baseParams:{idProduction:tabVars['arrayFiche_idProduction'], idRole:tabVars['arrayFiche_idRole'], idContact:tabVars['arrayContact_id'], idFiche:tabVars['post_idFiche'], idElement:idElement, sort: 'ordre', dir: 'ASC'},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'date', type: 'string', mapping: 'date'},
{name: 'note', type: 'string', mapping: 'note'},
{name: 'montant', type: 'string', mapping: 'montant'},
{name: 'estSysteme', type: 'int', mapping: 'estSysteme'},
{name: 'pourcentage', type: 'string', mapping: 'pourcentage'},
{name: 'analytique', type: 'string', mapping: 'analytique'},
{name: 'budgetItem', type: 'string', mapping: 'budgetItem'},
{name: 'fonction', type: 'string', mapping: 'fonction'}
]),sortInfo:{field: 'id', direction: "ASC"},
listeners:{
load:function() {
setTimeout(function(){
$j('.gridBudgetItemLoupe').click(function() {
var idEcheance = $j(this).attr('rel');
var formPanelGridComboBudgetItem = new Ext.FormPanel({
bodyStyle: 'padding: 5px',
standardSubmit: false,
layout:'table',
layoutConfig: {
columns: 2,
tableAttrs: {
style: {
width: '100%',
cellspacing:'5',
}
},
},
method: 'POST',
items: [
new Ext.form.FieldSet({
collapsible: false,
collapsed:false,
checkboxToggle:false,
title: 'Centres budgétaires',
autoHeight: true,
items: [
]
}),
{
cellCls:'tdValignTop',
bodyStyle:'border:none; width:300px; margin-left:10px',
items:[
new Ext.form.FieldSet({
collapsible: false,
collapsed:false,
checkboxToggle:false,
title: 'Résultats de la recherche',
autoHeight: true,
items: [
{
xtype:'displayfield',
value:'
Utilisez les filtres ci-contre pour rechercher un poste budgétaire
',
hideLabel:true
}
]
})
]
}
]
});
window_GridBudgetItem = new Ext.Window({
title: 'Rechercher un poste budgétaire',
closable:true,
draggable:true,
modal:true,
width: 700,
resizable:false,
height: 450,
plain:true,
layout: 'fit',
id: 'window_GridBudgetItemId',
items: formPanelGridComboBudgetItem,
listeners:{
show:function() {
//Ext.getCmp(idCombo).getStore().load();
}
},
tbar:[
{
text:'RAZ',
iconCls:'erase',
handler:function() {
$j('#formPanelGridComboBudgetItem_innerDroiteDiv').empty().append('Utilisez les filtres ci-contre pour rechercher un poste budgétaire');
$j('#formPanelGridComboBudgetItem_innerDroiteFieldSetTitre').empty().append('Résultats de la recherche');
}
}
]
}).show();
});
}, 500);
}
}
});
gridEcheances_CM = new Ext.grid.ColumnModel(
[{
header: 'Date',
sortable: true,
editor:new Ext.form.DateField({
allowBlank: false,
format:'d-m-Y',
}),
dataIndex: 'date',
width: 100,
},
{
header: 'Montant',
sortable: true,
editor:new Ext.form.NumberField({
allowBlank: false,
allowDecimals:true,
}),
dataIndex: 'montant',
width: 80,
},{
header: '%',
sortable: false,
dataIndex: 'pourcentage',
editor:new Ext.form.NumberField({
allowBlank: false,
allowDecimals:true,
}),
width: 60
},{
header: 'Analytique',
sortable: false,
editor:comboBudgetItem,
dataIndex: 'analytique',
width: 230
},
{
header: ' ',
sortable: false,
dataIndex: 'loupe',
width: 30,
renderer:function(value, metaData, record, rowIndex, colIndex, store) {
return '
';
}
},{
header: 'Note',
sortable: false,
editor:new Ext.form.TextField({
allowBlank: true,
}),
dataIndex: 'note',
width: 190
}
]
);
var gridEcheances = new Ext.grid.EditorGridPanel({
store: gridEcheances_DS,
id:'gridEcheancesId',
title:'Echéancier',
stateful: false,
clicksToEdit:2,
height:300,
autoScroll:true,
collapsible:false,
collapsed:false,
stripeRows: true,
enableColLock:false,
enableHdMenu:false,
loadMask: 'Chargement des données…',
cm: gridEcheances_CM,
view: new Ext.grid.GridView({
getRowClass : function(row, index){
var cls = '';
var data = row.data;
if(data.estSysteme==1) {
var cls = 'ligne_rouge';
}
return cls;
}
}),
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
tbar:[
{
text:'Ajouter',
iconCls:'add',
disabled:window.elementEnregistreEstEnfant,
handler:function() {
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/ajouter_echeance_elementContrat.php',
params:{
idFiche:tabVars['post_idFiche'],
idElement:idElement
},
success: function(data) {
gridEcheances_DS.reload();
}
});
}
},
{
text:'Supprimer',
iconCls:'delete',
disabled:window.elementEnregistreEstEnfant,
handler:function() {
var selectionselementFicheAsupprimer = gridEcheances.selModel.getSelections();
var elementFicheAsupprimerTAB = [];
for(i = 0; i< gridEcheances.selModel.getCount(); i++){
elementFicheAsupprimerTAB.push(selectionselementFicheAsupprimer[i].json.id);
}
var elementFicheAsupprimer = Ext.encode(elementFicheAsupprimerTAB);
/*
if((gridEcheances.getStore().getCount()-elementFicheAsupprimerTAB.length)==0) {
$j.gritter.add({title: 'Erreur',text: 'Vous ne pouvez pas supprimer la dernière échéance',image: '_img/notification/ko.png',sticky: false, time: '1000'});
} else {
*/
Ext.MessageBox.show({
title:'Demande de confirmation',
msg: 'Etes-vous sûr(e) ?',
buttons: Ext.MessageBox.YESNO,
fn: function(btn, text) {
if(btn=='yes') {
var selectionselementFicheAsupprimer = gridEcheances.selModel.getSelections();
var elementFicheAsupprimerTAB = [];
for(i = 0; i< gridEcheances.selModel.getCount(); i++){
elementFicheAsupprimerTAB.push(selectionselementFicheAsupprimer[i].json.id);
}
var elementFicheAsupprimer = Ext.encode(elementFicheAsupprimerTAB);
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/supprimer_echeance_element_fiche.php',
params: {
ids: elementFicheAsupprimer,
},
success: function (result,request) {
gridEcheances_DS.reload();
$j.gritter.add({title: 'Confirmation',text: 'Suppression(s) effectuée(s)',image: '_img/notification/ok.png',sticky: false, time: '1000'});
}
});
}
},
icon: Ext.MessageBox.QUESTION
});
//}
}
},
{
text:'Affecter le solde',
iconCls:'deferrais',
disabled:window.elementEnregistreEstEnfant,
handler:function() {
var selectionElement_affecterSolde = gridEcheances.selModel.getSelections();
if(gridEcheances.selModel.getCount()!=1) {
$j.gritter.add({title: 'Erreur',text: 'Merci de sélectionner une et une seule ligne ',image: '_img/notification/ko.png',sticky: false, time: '1000'});
} else {
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/affecterSoldeEcheanceElementContrat.php',
params: {
idEcheance:selectionElement_affecterSolde[0].json.id,
idFiche:tabVars['arrayFiche_id'],
idProduction:tabVars['arrayFiche_idProduction'],
idElementEnregistre:idElement,
idRole:tabVars['arrayFiche_idRole'],
idContact:tabVars['arrayContact_id']
}, success: function() {
gridEcheances_DS.reload();
$j.gritter.add({title: 'Confirmation',text: 'Modification effectuée',image: '_img/notification/ok.png',sticky: false, time: '1000'});
}
});
}
//selectionElement_affecterSolde[i].json.id
}
}
],
listeners:{
beforeedit:function() {
return !window.elementEnregistreEstEnfant;
},
afteredit:function(oGrid_event) {
var date = new Date(oGrid_event.record.data.date);
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/editerInlineEcheanceElementContrat.php',
params: {
id: oGrid_event.record.data.id,
montant: oGrid_event.record.data.montant,
note: oGrid_event.record.data.note,
idBudgetItem: oGrid_event.record.data.analytique,
field:oGrid_event.field,
date: date.format('Y-m-d'),
pourcentage: oGrid_event.record.data.pourcentage,
idFiche:tabVars['arrayFiche_id'],
idProduction:tabVars['arrayFiche_idProduction'],
idRole:tabVars['arrayFiche_idRole'],
idContact:tabVars['arrayContact_id']
}, success: function() {
gridEcheances_DS.reload();
$j.gritter.add({title: 'Confirmation',text: 'Modification effectuée',image: '_img/notification/ok.png',sticky: false, time: '1000'});
}
});
}
}
});
// gridEcheances_DS.load();
var tabs_modifierElementFiche = new Ext.TabPanel({
activeTab:activeTab,
autoHeight:true,
items:[
formPanel_modifierElementFiche
],
listeners: {
tabchange:function() {
gridEcheances_DS.load();
}
}
});
if(parseInt(tabVars['arrayTypeFiche_estBudget'])==1 && parseInt(tabVars['arrayTypeContrat_idCategorieContrat'])!=2) {
tabs_modifierElementFiche.add(gridEcheances);
}
var window_modifierElementFiche = new Ext.Window({
title: 'Modifier un élément',
closable:true,
draggable:true,
modal:true,
width: 720,
resizable:false,
autoHeight: true,
plain:true,
layout: 'auto',
listeners:{
close:function() {
if(dataStoreToReload.baseParams.id=='fichesContratEcheancesDataStoreId') {
dataStoreToReload.reload({params:{resetDueDates:1,resetDueDates_idFiche:tabVars['post_idFiche'],resetDueDates_idElement:idElement}});
} else {
dataStoreToReload.reload();
}
}
},
id: 'formPanelgridFichestFieldSetListingEditorGrid_modifierFieldSet_window',
items: tabs_modifierElementFiche
});
window_modifierElementFiche.show();
}
});
}
Array.prototype.unset = function(value) {
if(this.indexOf(value) != -1) { // Make sure the value exists
this.splice(this.indexOf(value), 1);
}
}
function HTMLentitiesdecode (texte) {
//texte = texte.replace(/#/g,'#'); // 160 A0
//texte = texte.replace(/\n/g,'\n'); // 160 A0
//texte = texte.replace(/\r/g,'\r'); // 160 A0
texte = texte.replace(/&/g,'&'); // 38 26
texte = texte.replace(/"/g,'"'); // 34 22
texte = texte.replace(/</g,'<'); // 60 3C
texte = texte.replace(/>/g,'>'); // 62 3E
texte = texte.replace(/¢/g,'\242');
texte = texte.replace(/£/g,'\243');
texte = texte.replace(/€/g,'\€');
texte = texte.replace(/¥/g,'\245');
texte = texte.replace(/°/g,'\260');
//texte = texte.replace(/\274/g,'¼');
texte = texte.replace(/Œ/g,'\274');
//texte = texte.replace(/\275/g,'½');
texte = texte.replace(/œ/g,'\275');
//texte = texte.replace(/\276/g,'¾');
texte = texte.replace(/Ÿ/g,'\276');
texte = texte.replace(/¡/g,'\241');
texte = texte.replace(/«/g,'\253');
texte = texte.replace(/»/g,'\273');
texte = texte.replace(/¿/g,'\277');
texte = texte.replace(/À/g,'\300');
texte = texte.replace(/Á/g,'\301');
texte = texte.replace(/Â/g,'\302');
texte = texte.replace(/Ã/g,'\303');
texte = texte.replace(/Ä/g,'\304');
texte = texte.replace(/Å/g,'\305');
texte = texte.replace(/Æ/g,'\306');
texte = texte.replace(/Ç/g,'\307');
texte = texte.replace(/È/g,'\310');
texte = texte.replace(/É/g,'\311');
texte = texte.replace(/Ê/g,'\312');
texte = texte.replace(/Ë/g,'\313');
texte = texte.replace(/Ì/g,'\314');
texte = texte.replace(/Í/g,'\315');
texte = texte.replace(/Î/g,'\316');
texte = texte.replace(/Ï/g,'\317');
texte = texte.replace(/Ð/g,'\320');
texte = texte.replace(/Ñ/g,'\321');
texte = texte.replace(/Ò/g,'\322');
texte = texte.replace(/Ó/g,'\323');
texte = texte.replace(/Ô/g,'\324');
texte = texte.replace(/Õ/g,'\325');
texte = texte.replace(/Ö/g,'\326');
texte = texte.replace(/Ø/g,'\330');
texte = texte.replace(/Ù/g,'\331');
texte = texte.replace(/Ú/g,'\332');
texte = texte.replace(/Û/g,'\333');
texte = texte.replace(/Ü/g,'\334');
texte = texte.replace(/Ý/g,'\335');
texte = texte.replace(/Þ/g,'\336');
texte = texte.replace(/ß/g,'\337');
texte = texte.replace(/à/g,'\340');
texte = texte.replace(/á/g,'\341');
texte = texte.replace(/â/g,'\342');
texte = texte.replace(/ã/g,'\343');
texte = texte.replace(/ä/g,'\344');
texte = texte.replace(/å/g,'\345');
texte = texte.replace(/æ/g,'\346');
texte = texte.replace(/ç/g,'\347');
texte = texte.replace(/è/g,'\350');
texte = texte.replace(/é/g,'\351');
texte = texte.replace(/ê/g,'\352');
texte = texte.replace(/ë/g,'\353');
texte = texte.replace(/ì/g,'\354');
texte = texte.replace(/í/g,'\355');
texte = texte.replace(/î/g,'\356');
texte = texte.replace(/ï/g,'\357');
texte = texte.replace(/ð/g,'\360');
texte = texte.replace(/ñ/g,'\361');
texte = texte.replace(/ò/g,'\362');
texte = texte.replace(/ó/g,'\363');
texte = texte.replace(/ô/g,'\364');
texte = texte.replace(/õ/g,'\365');
texte = texte.replace(/ö/g,'\366');
texte = texte.replace(/ø/g,'\370');
texte = texte.replace(/ù/g,'\371');
texte = texte.replace(/ú/g,'\372');
texte = texte.replace(/û/g,'\373');
texte = texte.replace(/ü/g,'\374');
texte = texte.replace(/ý/g,'\375');
texte = texte.replace(/þ/g,'\376');
texte = texte.replace(/ÿ/g,'\377');
return texte;
}
Array.prototype.findValue = function(name, value){
var array = $j.map(this, function(v,i){
var haystack = v[name];
var needle = new RegExp(value);
// check for string in haystack
// return the matched item if true, or null otherwise
return needle.test(haystack) ? v : null;
});
return this;
}
function windowLaunchInterface(rel) {
Ext.MessageBox.show({
title:window.SUPPRIMERCONFIRMATION_TITRE,
msg: window.SUPPRIMERCONFIRMATION_MESSAGE,
buttons: Ext.MessageBox.YESNO,
fn: function(btn, text) {
if(btn=='yes') {
$j.gritter.add({title: 'Confirmation',text: 'Interface lançée ou exécutée',image: '_img/notification/ok.png',sticky: false, time: '4000'});
Ext.Ajax.request({
waitMsg: 'Patientez',
url: rel,
success: function (result,request) {
window.bgTaskToken=makeid();
//executeQuery_checkBgTask(false, window.bgTaskToken);
$j('#asyncProgressBarWrapper').css('display','block');
executeQuery_checkBgTask(true, window.bgTaskToken);
}
});
}
},
icon: Ext.MessageBox.QUESTION
});
}
function window_myDiese_editer(idMyDiese,idContact,store) {
var formPanelAccesMyDieseEditer = new Ext.FormPanel({
bodyStyle: 'padding: 15px;border:none',
defaultType: 'textfield',
id:'formPanelAccesMyDieseEditerId',
labelWidth:200,
method: 'POST',
items: [
new Ext.form.FieldSet({
collapsible: false,
title: 'Informations générales',
autoHeight: true,
items: [
{
xtype:'datefieldplus',
name:'formPanelAccesMyDieseEditer_debut',
id:'formPanelAccesMyDieseEditer_debutId',
fieldLabel:'Date de début',
format:'d-m-Y',
submitFormat:'Y-m-d',
width:200,
listeners:{
select:function(thisCustom) {
var dateCustom = thisCustom.activeDate;
Ext.getCmp('formPanelAccesMyDieseEditer_finId').setMinValue(dateCustom);
}
}
},{
xtype:'datefieldplus',
name:'formPanelAccesMyDieseEditer_fin',
id:'formPanelAccesMyDieseEditer_finId',
fieldLabel:'Date de fin',
format:'d-m-Y',
submitFormat:'Y-m-d',
width:200,
listeners:{
select:function(thisCustom) {
var dateCustom = thisCustom.activeDate;
Ext.getCmp('formPanelAccesMyDieseEditer_debutId').setMaxValue(dateCustom);
}
}
},
new Ext.form.ComboBox({
hiddenName: 'formPanelAccesMyDieseEditer_emailConnexion',
id: 'formPanelAccesMyDieseEditer_emailConnexionId',
width:400,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_emailsContact.php?idContact='+idContact
}),
remoteSort: true,
autoLoad: false,
fields : ['id','valeur']
}),
triggerAction:'all',
fieldLabel:'Email',
valueField:'valeur',
minChars:1,
emptyText:'Sélectionnez ou tapez un email',
queryParam:'term',
displayField:'valeur',
mode:'remote',
forceSelectionCustom:false
})
]
}),
new Ext.form.FieldSet({
collapsible: false,
title: 'Paramètres',
// autoHeight: true,
items: [
new Ext.TabPanel({
activeTab: 0,
plain: true,
deferredRender: false,
height:500,
items: [{
title: 'Actions et vues',
items: [
new Ext.Panel ({
layout: 'form',
padding: 5,
items: [
new Ext.form.FieldSet({
collapsible: false,
title: 'GTA',
autoHeight: true,
items: [
new Ext.form.ComboBox({
hiddenName: 'formPanelAccesMyDieseEditer_profil',
id: 'formPanelAccesMyDieseEditer_profilId',
width:400,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_profils_mydiese.php'
}),
remoteSort: false,
autoLoad: true,
fields : ['id','intitule']
}),
triggerAction:'all',
fieldLabel:'Profil GTA',
valueField:'id',
minChars:1,
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'remote',
forceSelection:false
}),
new Ext.ux.form.LovCombo({
hiddenName: 'formPanelAccesMyDieseEditer_docs',
id: 'formPanelAccesMyDieseEditer_docsId',
width:400,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/stores_templatesMydiese.php'
}),
remoteSort: true,
autoLoad: true,
fields : ['id','intitule']
}),
triggerAction:'all',
fieldLabel:'Document(s)',
valueField:'id',
separator:';',
minChars:1,
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'local',
forceSelection:false
}),
new Ext.ux.form.LovCombo({
hiddenName: 'formPanelAccesMyDieseEditer_typesAbsences',
id: 'formPanelAccesMyDieseEditer_typesAbsencesId',
width:400,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_typeAbsences.php'
}),
remoteSort: false,
autoLoad: false,
fields : ['id','intitule']
}),
triggerAction:'all',
fieldLabel:'Types absence/présence',
valueField:'id',
minChars:1,
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'local',
forceSelection:false
}),
new Ext.form.ComboBox({
hiddenName: 'formPanelAccesMyDieseEditer_valideur',
id: 'formPanelAccesMyDieseEditer_valideurId',
width:400,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_groupesUtilisateurs_utilisateurs.php'
}),
remoteSort: false,
autoLoad: true,
fields : ['id','intitule']
}),
triggerAction:'all',
fieldLabel:'Valideur',
valueField:'id',
minChars:1,
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'remote',
forceSelection:false
}),
{
xtype:'checkbox',
id:'formPanelAccesMyDieseEditer_LimitPlanningPublieId',
name:'formPanelAccesMyDieseEditer_LimitPlanningPublie',
fieldLabel:'Planning publié seulement',
style: {
marginBottom: '6px',
marginTop: '6px',
}
},{
xtype:'checkbox',
id:'formPanelAccesMyDieseEditer_nePasAfficherHeuresId',
name:'formPanelAccesMyDieseEditer_nePasAfficherHeures',
fieldLabel:'Ne pas afficher les heures',
style: {
marginBottom: '6px',
marginTop: '6px',
}
}
]}),
new Ext.form.FieldSet({
collapsible: false,
title: 'Menus',
autoHeight: true,
items: [
{
xtype:'checkbox',
id:'formPanelAccesMyDieseEditer_afficherProductionId',
name:'formPanelAccesMyDieseEditer_afficherProduction',
fieldLabel:'Accès projet',
style: {
marginBottom: '6px',
marginTop: '6px',
}
},{
xtype:'checkbox',
id:'formPanelAccesMyDieseEditer_afficherContactId',
name:'formPanelAccesMyDieseEditer_afficherContact',
fieldLabel:'Accès contact',
style: {
marginBottom: '6px',
marginTop: '6px',
}
}, ]})
]
})
]
},{
title: 'Droits',
items: [
new Ext.Panel ({
layout: 'form',
padding: 5,
height:210,
items: [
new Ext.ux.form.LovCombo({
hiddenName: 'formPanelAccesMyDieseEditer_groupeDroit',
id: 'formPanelAccesMyDieseEditer_groupeDroitId',
width:400,
hideLabel:true,
hideCheckAll:true,
hideOnSelect:false,
store:new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_groupesUtilisateurs.php'
}),
remoteSort: false,
autoLoad: false,
fields : ['id','intitule'],
listeners: {
load:function(e) {
idGroupes = Ext.getCmp('formPanelAccesMyDieseEditer_groupeDroitId').getValue();
idGroupes = idGroupes.split(',');
idGroupes.forEach(function(element) {
$j("#checkbox_formPanelAccesMyDieseEditer_groupeDroitId_"+element).trigger( "click" );
})
}
}
}),
triggerAction:'all',
fieldLabel:"[droit]",
valueField:'id',
minChars:1,
emptyText:'Choix...',
queryParam:'term',
displayField:'intitule',
mode:'local',
forceSelection:false,
listeners:{
afterrender:function(e) {
comboMultiCustomList('formPanelAccesMyDieseEditer_groupeDroitId',198,false);
},
}
}),
]
})
]
}]
})
]
})
],
buttons: [{
text: 'Annuler',
handler: function() {
editerAccesMyDiese_window.close();
},
iconCls:'delete'
},{
text: 'Sauvegarder les modifications',
disabled:'true',
handler: function(thisCustom) {
var messageErreur='';
if(Ext.getCmp('formPanelAccesMyDieseEditer_debutId').getValue()=='') {
var messageErreur = messageErreur + 'Le champ début est obligatoire.
';
}
if(Ext.getCmp('formPanelAccesMyDieseEditer_finId').getValue()=='') {
var messageErreur = messageErreur + 'Le champ fin est obligatoire.
';
}
if(Ext.getCmp('formPanelAccesMyDieseEditer_emailConnexionId').getValue()=='') {
var messageErreur = messageErreur + 'Le champ email de connexion est obligatoire.
';
}
if(messageErreur!='') {
$j.gritter.add({title: 'Erreur',text: messageErreur,image: '_img/notification/ko.png',sticky: false, time: '1000'});
} else {
thisCustom.enableLoader();
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/accesMyDiese_checkDoublonPeriode.php',
params: {
email: Ext.getCmp('formPanelAccesMyDieseEditer_emailConnexionId').getValue(),
idContact:idContact,
debut:Ext.getCmp('formPanelAccesMyDieseEditer_debutId').getValueSubmitFormat(),
fin:Ext.getCmp('formPanelAccesMyDieseEditer_finId').getValueSubmitFormat(),
},
success: function (result,request) {
if(result.responseText=='ko') {
$j.gritter.add({title: 'Erreur',text: 'Un accès avec cet email existe déjà.',image: '_img/notification/ko.png',sticky: false, time: '2000'});
thisCustom.disableLoader();
} else if(result.responseText=='ko2') {
$j.gritter.add({title: 'Erreur',text: 'Vous avez atteint le maximum de comptes myDiese autorisés. Merci de contacter votre administrateur.',image: '_img/notification/ko.png',sticky: false, time: '2000'});
thisCustom.disableLoader();
} else {
formPanelAccesMyDieseEditer.getForm().submit({
clientValidation: true,
url: '_ajax/editerAccesMyDiese.php',
params:{
id:idMyDiese,
idContact:idContact,
dateDebut:Ext.getCmp('formPanelAccesMyDieseEditer_debutId').getValueSubmitFormat(),
dateFin:Ext.getCmp('formPanelAccesMyDieseEditer_finId').getValueSubmitFormat(),
},
success: function(form, action) {
$j.gritter.add({title: 'Confirmation',text: 'Ajout effectué',image: '_img/notification/ok.png',sticky: false, time: '2000'});
store.reload();
editerAccesMyDiese_window.close();
}
});
}
}
});
}
},
iconCls:'save',
id:'btnEditerMyDiese'
}]
});
editerAccesMyDiese_window = new Ext.Window({
title: 'Editer cet accès',
closable:true,
draggable:true,
modal:true,
width: 750,
resizable:false,
height: 870,
plain:true,
id: 'editerAccesMyDiese_windowId',
items: formPanelAccesMyDieseEditer
}).show();
formPanelAccesMyDieseEditer.getForm().load({
url: '_datasMysql/form_editerAccesMyDiese.php',
params: {
id: idMyDiese
},
success:function(form,action) {
// inception de callback des stores du compte MyDiese
// --profils
var store = Ext.getCmp('formPanelAccesMyDieseEditer_profilId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelAccesMyDieseEditer_profilId').setValue(action.result.data.idProfil);
// --docs
var store = Ext.getCmp('formPanelAccesMyDieseEditer_docsId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelAccesMyDieseEditer_docsId').setValue(action.result.data.templates);
// --absences
var store = Ext.getCmp('formPanelAccesMyDieseEditer_typesAbsencesId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelAccesMyDieseEditer_typesAbsencesId').setValue(action.result.data.typesAbsences);
// --valideur
var store = Ext.getCmp('formPanelAccesMyDieseEditer_valideurId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelAccesMyDieseEditer_valideurId').setValue(action.result.data.idUserValideur);
// -- groupes de droit
var store = Ext.getCmp('formPanelAccesMyDieseEditer_groupeDroitId').getStore();
store.load({callback:function() {
Ext.getCmp('formPanelAccesMyDieseEditer_groupeDroitId').setValue(action.result.data.groupeDroit);
Ext.getCmp('formPanelAccesMyDieseEditer_groupeDroitId').getStore().reload();
// --On rend accessible le bouton de sauvegarde du compte une fois que tout est bien loadé
Ext.getCmp('btnEditerMyDiese').setDisabled(false);
}});
}});
}});
}});
}});
}
});
}
function nl2br (str, is_xhtml) {
if (typeof str === 'undefined' || str === null) {
return '';
}
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
function isValidDate(dateString) {
var regEx = /^\d{4}-\d{2}-\d{2}$/;
if(!dateString.match(regEx)) return false; // Invalid format
var d = new Date(dateString);
var dNum = d.getTime();
if(!dNum && dNum !== 0) return false; // NaN value, Invalid date
return d.toISOString().slice(0,10) === dateString;
}
function validateHhMm(value) {
if(value=='24:00') {
return false;
}
var isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(value);
return isValid;
}
function isBic(value) {
var bic = value.replace( / /g, "" );
if(bic=='') {
return true;
}
if(/([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?/i.test( bic.toUpperCase() ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( bic.toUpperCase() )) {
return true;
} else {
return false;
}
}
/**
* IBAN is the international bank account number.
* It has a country - specific format, that is checked here too
*
* Validation is case-insensitive. Please make sure to normalize input yourself.
*/
function validIban(value) {
if(value=='') {
return true;
}
return IBAN.isValid(value);
// Remove spaces and to upper case
var iban = value.replace( / /g, "" ).toUpperCase(),
ibancheckdigits = "",
leadingZeroes = true,
cRest = "",
cOperator = "",
countrycode, ibancheck, charAt, cChar, bbanpattern, bbancountrypatterns, ibanregexp, i, p;
if(iban=='') {
return true;
}
// Check for IBAN code length.
// It contains:
// country code ISO 3166-1 - two letters,
// two check digits,
// Basic Bank Account Number (BBAN) - up to 30 chars
var minimalIBANlength = 5;
if ( iban.length < minimalIBANlength ) {
return false;
}
// Check the country code and find the country specific format
countrycode = iban.substring( 0, 2 );
bbancountrypatterns = {
"AL": "\\d{8}[\\dA-Z]{16}",
"AD": "\\d{8}[\\dA-Z]{12}",
"AT": "\\d{16}",
"AZ": "[\\dA-Z]{4}\\d{20}",
"BE": "\\d{12}",
"BH": "[A-Z]{4}[\\dA-Z]{14}",
"BA": "\\d{16}",
"BR": "\\d{23}[A-Z][\\dA-Z]",
"BG": "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
"CR": "\\d{17}",
"HR": "\\d{17}",
"CY": "\\d{8}[\\dA-Z]{16}",
"CZ": "\\d{20}",
"DK": "\\d{14}",
"DO": "[A-Z]{4}\\d{20}",
"EE": "\\d{16}",
"FO": "\\d{14}",
"FI": "\\d{14}",
"FR": "\\d{10}[\\dA-Z]{11}\\d{2}",
"GE": "[\\dA-Z]{2}\\d{16}",
"DE": "\\d{18}",
"GI": "[A-Z]{4}[\\dA-Z]{15}",
"GR": "\\d{7}[\\dA-Z]{16}",
"GL": "\\d{14}",
"GT": "[\\dA-Z]{4}[\\dA-Z]{20}",
"HU": "\\d{24}",
"IS": "\\d{22}",
"IE": "[\\dA-Z]{4}\\d{14}",
"IL": "\\d{19}",
"IT": "[A-Z]\\d{10}[\\dA-Z]{12}",
"KZ": "\\d{3}[\\dA-Z]{13}",
"KW": "[A-Z]{4}[\\dA-Z]{22}",
"LV": "[A-Z]{4}[\\dA-Z]{13}",
"LB": "\\d{4}[\\dA-Z]{20}",
"LI": "\\d{5}[\\dA-Z]{12}",
"LT": "\\d{16}",
"LU": "\\d{3}[\\dA-Z]{13}",
"MK": "\\d{3}[\\dA-Z]{10}\\d{2}",
"MT": "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
"MR": "\\d{23}",
"MU": "[A-Z]{4}\\d{19}[A-Z]{3}",
"MC": "\\d{10}[\\dA-Z]{11}\\d{2}",
"MD": "[\\dA-Z]{2}\\d{18}",
"ME": "\\d{18}",
"NL": "[A-Z]{4}\\d{10}",
"NO": "\\d{11}",
"PK": "[\\dA-Z]{4}\\d{16}",
"PS": "[\\dA-Z]{4}\\d{21}",
"PL": "\\d{24}",
"PT": "\\d{21}",
"RO": "[A-Z]{4}[\\dA-Z]{16}",
"SM": "[A-Z]\\d{10}[\\dA-Z]{12}",
"SA": "\\d{2}[\\dA-Z]{18}",
"RS": "\\d{18}",
"SK": "\\d{20}",
"SI": "\\d{15}",
"ES": "\\d{20}",
"SE": "\\d{20}",
"CH": "\\d{5}[\\dA-Z]{12}",
"TN": "\\d{20}",
"TR": "\\d{5}[\\dA-Z]{17}",
"AE": "\\d{3}\\d{16}",
"GB": "[A-Z]{4}\\d{14}",
"VG": "[\\dA-Z]{4}\\d{16}"
};
bbanpattern = bbancountrypatterns[ countrycode ];
// As new countries will start using IBAN in the
// future, we only check if the countrycode is known.
// This prevents false negatives, while almost all
// false positives introduced by this, will be caught
// by the checksum validation below anyway.
// Strict checking should return FALSE for unknown
// countries.
if ( typeof bbanpattern !== "undefined" ) {
ibanregexp = new RegExp( "^[A-Z]{2}\\d{2}" + bbanpattern + "$", "" );
if ( !( ibanregexp.test( iban ) ) ) {
return false; // Invalid country specific format
}
}
// Now check the checksum, first convert to digits
ibancheck = iban.substring( 4, iban.length ) + iban.substring( 0, 4 );
for ( i = 0; i < ibancheck.length; i++ ) {
charAt = ibancheck.charAt( i );
if ( charAt !== "0" ) {
leadingZeroes = false;
}
if ( !leadingZeroes ) {
ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf( charAt );
}
}
// Calculate the result of: ibancheckdigits % 97
for ( p = 0; p < ibancheckdigits.length; p++ ) {
cChar = ibancheckdigits.charAt( p );
cOperator = "" + cRest + "" + cChar;
cRest = cOperator % 97;
}
return cRest === 1;
}
var tabBrowserID = sessionStorage.tabBrowserID && sessionStorage.closedLastTab !== '2' ? sessionStorage.tabBrowserID : sessionStorage.tabBrowserID = Math.random();
sessionStorage.closedLastTab = '2';
$j(window).on('unload beforeunload', function() {
sessionStorage.closedLastTab = '1';
});
function extJsColumnWidth(panel,width) { // permet de changer facilement la taille des colonnes dans extjs
panel.items.each(function(item){
item.columnWidth = width;
});
}
function displayNbResultsGrid(idGrid,nb) {
$j('.nbresultsH5').remove();
$j('#'+idGrid).prev().children().css('float','left');
$j('#'+idGrid).prev().children().removeClass('col-lg-12').addClass('p-l-0 col-lg-10 col-sm-6 col-6');
$j('#'+idGrid).prev().append(''+nb+' résultat(s)
');
}
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
}
function gererSmartGroupsGenerateurPlanning(idComboSM, colonnesLien) {
var expander = new Ext.grid.RowExpander({
tpl: new Ext.XTemplate(
'',
'
',
'du : {dateDebut}
',
'au : {dateFin}
',
'',
'
',
'du : ' + window.CALENDRIER_TODAYTEXT + ' -7 ' + window.MOT_JOURS + '
',
'au : ' + window.CALENDRIER_TODAYTEXT + ' +30 ' + window.MOT_JOURS + '
',
'' + window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_MESSAGE_AUTOPERIOD + '
',
'',
'
',
'' + window.CALENDRIERS_GENERATEURPLANNING_CHAMP9 + ' : {template}
',
'',
'
'
)
});
colonnesLien = true;
store_gererModelesMailing = new Ext.data.Store({
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/grid_gererSmartGroupsGenerateurPlanning.php',
method: 'POST',
}),
baseParams: {
sort: 'id',
dir: 'DESC'
}, // this parameter is passed for any HTTP request
reader: new Ext.data.JsonReader(
{
root: 'results',
totalProperty: 'total',
id: 'id'
},
[
{ name: 'id', type: 'int', mapping: 'id' },
{ name: 'droit', type: 'int', mapping: 'droit' },
{ name: 'gestion', type: 'int', mapping: 'gestion' },
{ name: 'intitule', type: 'string', mapping: 'intitule' },
{ name: 'getLink', type: 'string', mapping: 'getLink' },
{ name: 'getIcs', type: 'string', mapping: 'getIcs' },
{ name: 'dateC', type: 'string', mapping: 'dateC' },
{ name: 'creator', type: 'string', mapping: 'creator' },
{ name: 'getShare', type: 'string', mapping: 'getShare' },
{ name: 'dateDebut', type: 'string', mapping: 'dateDebut' },
{ name: 'dateFin', type: 'string', mapping: 'dateFin' },
{ name: 'template', type: 'string', mapping: 'template' },
{ name: 'idTemplate', type: 'int', mapping: 'idTemplate' },
{ name: 'dispoPdf', type: 'int', mapping: 'dispoPdf' },
{ name: 'dispoHtml', type: 'int', mapping: 'dispoHtml' },
{ name: 'icsOK', type: 'int', mapping: 'icsOK' },
{ name: 'linkOK', type: 'int', mapping: 'linkOK' },
{ name: 'nbPartage', type: 'int', mapping: 'nbPartage' }
]
),
listeners: {
load: function (thisCustom2) {
setTimeout(function () {
$j('.calendrierSM_getLink').click(function () {
var thisCustom = $j(this);
var idtemplateSM = thisCustom2.data.map[thisCustom.attr('rel')].data.id;
var store = Ext.getCmp('grid_gererModelesMailingId').getStore();
var templateinfo = store.data.map[idtemplateSM];
windowCalendrierSM_getLink = new Ext.Window({
title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL3_WINDOWTITRE,
closable: true,
draggable: true,
modal: true,
width: 520,
resizable: false,
height: 180,
plain: true,
layout: 'fit',
id: 'windowCalendrierSM_getLinkId',
items: new Ext.form.FormPanel({
frame: true,
bodyStyle: 'padding:5px',
standardSubmit: false,
method: 'POST',
baseCls: 'x-plain',
labelWidth: 110,
labelAlign: 'top',
items: [
{
xtype: 'textfield',
width: 490,
id: 'windowCalendrierSM_getLink_fieldId',
emptyText: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL3_FIELDEMPTYTEXT,
fieldLabel: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL3_FIELDLABEL
}
]
}),
tbar: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL3_BUTTONPARAMS,
iconCls: 'parametres',
menu: {
items: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_PDF,
iconCls: 'pdf',
id: 'panelDocumentsCalendrierDroite_button_pdfTop',
menu: {
items: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_PDF_A4L,
iconCls: 'paysage',
handler: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getLink.php',
params: {
idSM: thisCustom.attr('rel'),
format: 'A4L'
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getLink_fieldId').setValue(result.responseText);
}
});
}
},
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_PDF_A4P,
iconCls: 'portrait',
handler: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getLink.php',
params: {
idSM: thisCustom.attr('rel'),
format: 'A4P'
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getLink_fieldId').setValue(result.responseText);
}
});
}
},
{ xtype: 'menuseparator' },
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_PDF_A3L,
iconCls: 'paysage',
handler: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getLink.php',
params: {
idSM: thisCustom.attr('rel'),
format: 'A3L'
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getLink_fieldId').setValue(result.responseText);
}
});
}
},
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_PDF_A3P,
iconCls: 'portrait',
handler: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getLink.php',
params: {
idSM: thisCustom.attr('rel'),
format: 'A3P'
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getLink_fieldId').setValue(result.responseText);
}
});
}
},
]
}
},
{
text: window.CALENDRIERS_GENERATEURPLANNING_BBAR_SUBMIT_HTML,
iconCls: 'download',
id: 'panelDocumentsCalendrierDroite_button_htmlTop',
handler: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getLink.php',
params: {
idSM: thisCustom.attr('rel'),
format: 'HTML'
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getLink_fieldId').setValue(result.responseText);
}
});
}
}
]
}
}
],
listeners: {
render: function () {
Ext.getCmp('panelDocumentsCalendrierDroite_button_pdfTop').disable();
Ext.getCmp('panelDocumentsCalendrierDroite_button_htmlTop').disable();
if (parseInt(templateinfo.data.dispoPdf) == 1) {
Ext.getCmp('panelDocumentsCalendrierDroite_button_pdfTop').enable();
}
if (parseInt(templateinfo.data.dispoHtml) == 1) {
Ext.getCmp('panelDocumentsCalendrierDroite_button_htmlTop').enable();
}
}
}
}).show();
});
$j('.calendrierSM_getIcs').click(function () {
var thisCustom = $j(this);
windowCalendrierSM_getIcs = new Ext.Window({
title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL4_WINDOWTITRE,
closable: true,
draggable: true,
modal: true,
width: 520,
resizable: false,
height: 180,
plain: true,
layout: 'fit',
id: 'windowCalendrierSM_getIcsId',
items: new Ext.form.FormPanel({
frame: true,
bodyStyle: 'padding:5px',
standardSubmit: false,
method: 'POST',
baseCls: 'x-plain',
labelWidth: 110,
labelAlign: 'top',
bbar: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1,
iconCls: 'gear',
id: 'buttonCalendrierSM_getIcs_BBAR1Id',
handler: function() {
windowCalendrierSM_getIcs_BBAR1 = new Ext.Window({
title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_TITREFENETRE,
closable: true,
draggable: true,
modal: true,
width: 400,
resizable: false,
height: 400,
plain: true,
layout: 'fit',
id: 'windowCalendrierSM_getIcs_BBAR1Id',
items: new Ext.form.FormPanel({
frame: true,
bodyStyle: 'padding:5px',
standardSubmit: false,
method: 'POST',
baseCls: 'x-plain',
labelWidth: 110,
labelAlign: 'top',
buttons: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE,
iconCls: 'save',
handler: function () {
$j('#buttonCalendrierSM_getIcs_BBAR1Id').attr('rel', Ext.getCmp('windowCalendrierSM_getIcs_BBAR1Id_classifId').getValue());
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getIcs.php',
params: {
idSM: thisCustom.attr('rel'),
classifs: $j('#buttonCalendrierSM_getIcs_BBAR1Id').attr('rel'),
categorieRole: $j('#buttonCalendrierSM_getIcs_BBAR2Id').attr('rel')
},
success: function (result, request) {
$j.gritter.add({ title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE_CONFIRMTITRE, text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE_CONFIRMTEXTE, image: '_img/notification/ok.png', sticky: false, time: '1000' });
Ext.getCmp('windowCalendrierSM_getIcs_fieldId').setValue(result.responseText);
Ext.getCmp('windowCalendrierSM_getIcs_BBAR1Id').close();
}
});
}
}
],
items: [
new Ext.ux.form.LovCombo({
hiddenName: 'windowCalendrierSM_getIcs_BBAR1Id_classif',
id: 'windowCalendrierSM_getIcs_BBAR1Id_classifId',
anchor: '100%',
hideOnSelect: false,
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_classifPlanning.php'
}),
remoteSort: true,
autoLoad: false,
fields: [{ name: 'id', type: 'string' }, 'intitule', 'valeur']
}),
triggerAction: 'all',
valueField: 'id',
minChars: 1,
hideLabel: false,
fieldLabel: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_TITREFENETRE_CHAMP1,
allowBlank: true,
queryParam: 'term',
displayField: 'intitule',
mode: 'remote',
forceSelection: false,
listeners: {
afterrender: function () {
var store = Ext.getCmp('windowCalendrierSM_getIcs_BBAR1Id_classifId').getStore();
store.load({
callback: function () {
Ext.getCmp('windowCalendrierSM_getIcs_BBAR1Id_classifId').setValue($j('#buttonCalendrierSM_getIcs_BBAR1Id').attr('rel'));
comboMultiCustomList('windowCalendrierSM_getIcs_BBAR1Id_classifId', 200, false);
}
});
}
}
})
]
})
}).show();
}
},
{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_2,
iconCls: 'gear',
id: 'buttonCalendrierSM_getIcs_BBAR2Id',
handler: function() {
windowCalendrierSM_getIcs_BBAR1 = new Ext.Window({
title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_2_TITREFENETRE,
closable: true,
draggable: true,
modal: true,
width: 400,
resizable: false,
height: 400,
plain: true,
layout: 'fit',
id: 'windowCalendrierSM_getIcs_BBAR1Id',
items: new Ext.form.FormPanel({
frame: true,
bodyStyle: 'padding:5px',
standardSubmit: false,
method: 'POST',
baseCls: 'x-plain',
labelWidth: 110,
labelAlign: 'top',
buttons: [
{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE,
iconCls: 'save',
handler: function () {
$j('#buttonCalendrierSM_getIcs_BBAR2Id').attr('rel', Ext.getCmp('windowCalendrierSM_getIcs_BBAR2Id_classifId').getValue());
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getIcs.php',
params: {
idSM: thisCustom.attr('rel'),
classifs: $j('#buttonCalendrierSM_getIcs_BBAR1Id').attr('rel'),
categorieRole: $j('#buttonCalendrierSM_getIcs_BBAR2Id').attr('rel')
},
success: function (result, request) {
$j.gritter.add({ title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE_CONFIRMTITRE, text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_1_SAVE_CONFIRMTEXTE, image: '_img/notification/ok.png', sticky: false, time: '1000' });
Ext.getCmp('windowCalendrierSM_getIcs_fieldId').setValue(result.responseText);
Ext.getCmp('windowCalendrierSM_getIcs_BBAR1Id').close();
}
});
}
}
],
items: [
new Ext.ux.form.LovCombo({
hiddenName: 'windowCalendrierSM_getIcs_BBAR12d_classif',
id: 'windowCalendrierSM_getIcs_BBAR2Id_classifId',
anchor: '100%',
hideOnSelect: false,
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/store_categoriesRoles.php'
}),
remoteSort: true,
autoLoad: false,
fields: [{ name: 'id', type: 'string' }, 'intitule', 'valeur']
}),
triggerAction: 'all',
valueField: 'id',
minChars: 1,
hideLabel: false,
fieldLabel: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_ICS_BBAR_2_TITREFENETRE_CHAMP1,
allowBlank: true,
queryParam: 'term',
displayField: 'intitule',
mode: 'remote',
forceSelection: false,
listeners: {
afterrender: function () {
var store = Ext.getCmp('windowCalendrierSM_getIcs_BBAR2Id_classifId').getStore();
store.load({
callback: function () {
Ext.getCmp('windowCalendrierSM_getIcs_BBAR2Id_classifId').setValue($j('#buttonCalendrierSM_getIcs_BBAR2Id').attr('rel'));
comboMultiCustomList('windowCalendrierSM_getIcs_BBAR2Id_classifId', 200, false);
}
});
}
}
})
]
})
}).show();
}
}
],
items: [
{
xtype: 'textfield',
width: 490,
id: 'windowCalendrierSM_getIcs_fieldId',
fieldLabel: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL4_FIELDLABEL,
listeners: {
render: function () {
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/windowCalendrierSM_getIcs.php',
params: {
idSM: thisCustom.attr('rel'),
},
success: function (result, request) {
Ext.getCmp('windowCalendrierSM_getIcs_fieldId').setValue(result.responseText);
}
});
}
}
}
]
})
}).show();
});
$j('.calendrierSM_getShare').click(function () {
var thisCustom = $j(this);
function saveRights(thisCustom, e, record) {
window.scrollTopValueGridDroitListeContact = $j('.x-grid3-scroller-contactsGroupe_grid_gererDroitsUtilisateursId').scrollTop();
Ext.Ajax.request({
waitMsg: 'Mise à jour?',
url: '_ajax/changerEtatValeurLectureEcritureDroitUtilisateurSmartgroup.php',
params: {
state: record.data[e.dataIndex],
droit: $j(e.header).attr('rel'),
id: record.data['id'],
idSmartgroup: thisCustom.attr('rel')
},
success: function () {
gritter('ok');
contactsGroupe_grid_gererDroitsUtilisateursDataStore.reload();
}
});
}
var selectionSMenCours = grid_gererModelesMailing.selModel.getSelections();
if (thisCustom.attr('share') == 1) {
var caseLectureDroit1Utilisateur = new Ext.grid.CheckColumn({
header: 'Aucun droit',
dataIndex: 'aucun',
width: 80,
sortable: false
});
caseLectureDroit1Utilisateur.on('click', function (e, evt, record) {
saveRights(thisCustom, e, record);
});
var caseLectureDroit2Utilisateur = new Ext.grid.CheckColumn({
header: 'Lecture',
dataIndex: 'lecture',
width: 80,
sortable: false
});
caseLectureDroit2Utilisateur.on('click', function (e, evt, record) {
saveRights(thisCustom,e , record);
});
var caseLectureDroit3Utilisateur = new Ext.grid.CheckColumn({
header: 'Lecture / Ecriture',
dataIndex: 'lectureEcriture',
width: 120,
sortable: false
});
caseLectureDroit3Utilisateur.on('click', function (e, evt, record) {
saveRights(thisCustom,e, record);
});
var contactsGroupe_grid_gererDroitsUtilisateursColumnModel = new Ext.grid.ColumnModel(
[
{
header: 'Prénom',
sortable: true,
dataIndex: 'prenom',
width: 150,
renderer: function (value, cell) {
return value;
}
},
{
header: 'Nom',
sortable: true,
dataIndex: 'nom',
width: 150,
renderer: function (value, cell) {
return value;
}
},
caseLectureDroit1Utilisateur,
caseLectureDroit2Utilisateur,
caseLectureDroit3Utilisateur
]
);
var contactsGroupe_grid_gererDroitsUtilisateursDataStore = new Ext.data.Store({
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/gridPartageSmartgroupPlanning_droitUtilisateur.php',
method: 'POST'
}),
baseParams: {
sort: 'id',
dir: 'ASC',
idSmartgroup: thisCustom.attr('rel')
}, // this parameter is passed for any HTTP request
reader: new Ext.data.JsonReader(
{
root: 'results',
totalProperty: 'total',
id: 'id'
},
[
{ name: 'id', type: 'int', mapping: 'id' },
{ name: 'aucun', type: 'int', mapping: 'aucun' },
{ name: 'lecture', type: 'int', mapping: 'lecture' },
{ name: 'lectureEcriture', type: 'int', mapping: 'lectureEcriture' },
{ name: 'prenom', type: 'string', mapping: 'prenom' },
{ name: 'nom', type: 'string', mapping: 'nom' },
]
),
listeners: {
load: function () {
setTimeout(function () {
$j('.mesListe_droitUtilisateur').unbind('dblclick');
$j('.mesListe_droitUtilisateur').dblclick(function () {
var myMask = new Ext.LoadMask(smartGroupPlanningGererDroitUtilisateurs.getEl());
myMask.show();
var droit = $j(this).attr('rel');
Ext.Ajax.request({
waitMsg: 'Mise à jour?',
url: '_ajax/changerEtatValeurLectureEcritureDroitMultiUtilisateurSmartgroup.php',
params: {
state: true,
droit: droit,
idSmartgroup: thisCustom.attr('rel')
},
success: function () {
gritter('ok',);
contactsGroupe_grid_gererDroitsUtilisateursDataStore.reload({
callback: function () {
myMask.hide();
}
});
}
});
});
if (window.scrollTopValueGridDroitListeContact > 0) {
$j('.x-grid3-scroller-contactsGroupe_grid_gererDroitsUtilisateursId').scrollTop(window.scrollTopValueGridDroitListeContact);
window.scrollTopValueGridDroitListeContact = '';
}
}, 200)
}
}
});
var smartGroupPlanningGererDroitUtilisateurs = new Ext.grid.EditorGridPanel({
store: contactsGroupe_grid_gererDroitsUtilisateursDataStore,
stateful: false,
id: 'contactsGroupe_grid_gererDroitsUtilisateursId',
stripeRows: true,
height: 300,
enableColLock: true,
plugins: [
caseLectureDroit1Utilisateur,
caseLectureDroit2Utilisateur,
caseLectureDroit3Utilisateur
],
enableHdMenu: true,
loadMask: 'Chargement des données…',
cm: contactsGroupe_grid_gererDroitsUtilisateursColumnModel,
view: new Ext.grid.GridView({
forceFit: true
}),
selModel: new Ext.grid.RowSelectionModel({ singleSelect: false }),
});
window.calendrierSM_getShare = new Ext.Window({
title: 'Partager',
closable: true,
draggable: true,
modal: true,
width: 700,
resizable: false,
height: 300,
plain: true,
layout: 'fit',
id: 'calendrierSM_getShareId',
items: smartGroupPlanningGererDroitUtilisateurs,
listeners:{
close:function() {
store_gererModelesMailing.reload();
}
}
}).show();
} else {
Ext.MessageBox.show({
title:'Se désabonner',
msg: 'Vous n\'aurez plus accès à ce smartgroup.',
buttons: Ext.MessageBox.YESNO,
fn: function(btn, text) {
if(btn=='yes') {
console.log('yes');
Ext.Ajax.request({
waitMsg: 'Mise à jour',
url: '_ajax/unsubscribeSmartGroupGenerateurPlanning.php',
params: {
idSmartgroup: thisCustom.attr('rel')
},
success: function () {
store_gererModelesMailing.reload();
gritter('ok');
}
});
} else if(btn=='no') {
}
},
icon: Ext.MessageBox.QUESTION
})
}
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
/////////////////////////////////////////////
console.log('selectionSMenCours', selectionSMenCours);
function caseLectureDroitUtilisateurClick(element, evt, record) {
window.scrollTopValueGridDroitListeContact = $j('.x-grid3-scroller-contactsGroupe_grid_gererDroitsUtilisateursId').scrollTop();
Ext.Ajax.request({
waitMsg: 'Mise à jour',
url: '_ajax/changerEtatValeurLectureEcritureDroitUtilisateurSmartgroup.php',
params: {
state: record.data[this.dataIndex],
droit: 1,
id: record.data['id'],
idSmartgroup: thisCustom.attr('rel')
},
success: function () {
gritter('ok');
contactsGroupe_grid_gererDroitsUtilisateursDataStore.reload();
}
});
};
contactsGroupe_grid_gererDroitsUtilisateursDataStore.load();
});
}, 250);
}
}
});
cm_gererModelesMailing = new Ext.grid.ColumnModel([
expander,
{
header: ' ',
sortable: true,
dataIndex: 'id',
width: 60,
renderer: function (value, cell, record) {
return value;
}
},
{
header: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL1,
sortable: true,
dataIndex: 'intitule',
width: 330,
editor: {
xtype: 'textfield',
allowBlank: false
},
renderer: function (value, cell, record) {
if (record.data.nbPartage > 0) {
value += '
' + window.SMARTGROUP_NB_PARTAGE.replace("{nb}", record.data.nbPartage) + '';
}
return value;
}
},
{
header: window.MOT_CREEPAR,
sortable: true,
dataIndex: 'creator',
width: 150,
renderer: function (value, cell) {
return value;
}
},
{
header: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL2,
sortable: true,
dataIndex: 'dateC',
width: 100,
renderer: function (value, cell) {
return value;
}
},
{
header: ' ',
sortable: true,
hidden: !colonnesLien,
dataIndex: 'getLink',
width: 50,
renderer: function (value, cell, record) {
var iconStyle = record.data.linkOK == 1 ? '' : 'opacity: 0.3;';
var iconClass = record.data.linkOK == 1 ? 'calendrierSM_getLink' : 'linkKO';
return '';
}
},
{
header: ' ',
sortable: true,
hidden: !colonnesLien,
dataIndex: 'getIcs',
width: 50,
renderer: function (value, cell, record) {
//var iconStyle = record.data.linkOK == 1 ? '' : 'opacity: 0.3;'; //mdi mdi-calendar-import
//var iconClass = record.data.linkOK == 1 ? 'calendrierSM_getIcs' : 'icskO';
return '';
}
},
{
header: ' ',
sortable: true,
dataIndex: 'getShare',
width: 100,
renderer: function (value, cell, record) { //mdi mdi-cogs
var span = '';
if (record.data.gestion == 1 || record.data.droit == 3) {
icon = 'cogs';
qtip = window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_COL4TOOLTIP_PARTAGER;
span += '';
}
if (record.data.gestion == 0) {
icon = 'link-off';
qtip = 'Se désabonner';
span += '';
}
return '' + span + '
';
}
}
]);
grid_gererModelesMailing = new Ext.grid.EditorGridPanel({
id: 'grid_gererModelesMailingId',
store: store_gererModelesMailing,
height: 300,
stateful: false,
autoScroll: true,
stripeRows: true,
clicksToEdit: 2,
enableColLock: false,
enableHdMenu: false,
loadMask: 'Chargement des données…',
plugins: expander,
cm: cm_gererModelesMailing,
enableColLock: true,
selModel: new Ext.grid.RowSelectionModel({ singleSelect: false }),
view: new Ext.grid.GridView({
forceFit: true,
}),
tbar: [{
text: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_TBAR_SUPPRIMER,
iconCls: 'delete',
handler: function () {
var selectionSMenCours = grid_gererModelesMailing.selModel.getSelections();
var msgSuppr = window.SUPPRIMERCONFIRMATION_MESSAGE;
for (i = 0; i < grid_gererModelesMailing.selModel.getCount(); i++) {
if (selectionSMenCours[i].json.nbPartage > 0) {
msgSuppr = window.SMARTGROUP_SUPPRIMERCONFIRMATION_MESSAGE;
}
if (selectionSMenCours[i].json.droit < 3) {
gritter('ko', 'Cette action n\'est pas autorisée');
return false;
}
}
// ICI on va aller chercher la valeur de droitFinal (retournée depuis la page grid_gererSmartGroupsGenerateurPlanning.php et ajouté dans le mapping du store lignes 190-200)
// avec ce code :
//>alert('pas de droit ecriture') return false; - expliqué dans grid_gererSmartGroupsGenerateurPlanning.php
/*
var selectionslieuxAsupprimer = grid_gererModelesMailing.selModel.getSelections();
for(i = 0; i < grid_gererModelesMailing.selModel.getCount(); i++) {
if(selectionslieuxAsupprimer[i].json.droitFinal < 3) {
}
}
*/
if (grid_gererModelesMailing.selModel.getCount() == 0) {
gritter('ko', window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP_GRID_TBAR_SUPPRIMER_ERREUR1_TXT);
} else {
Ext.MessageBox.show({
title: window.SUPPRIMERCONFIRMATION_TITRE,
msg: msgSuppr,
buttons: Ext.MessageBox.YESNO,
fn: function (btn, text) {
if (btn == 'yes') {
var selectionslieuxAsupprimer = grid_gererModelesMailing.selModel.getSelections();
var lieuxAsupprimerTAB = [];
for (i = 0; i < grid_gererModelesMailing.selModel.getCount(); i++) {
lieuxAsupprimerTAB.push(selectionslieuxAsupprimer[i].json.id);
}
var lieuxAsupprimer = Ext.encode(lieuxAsupprimerTAB);
Ext.Ajax.request({
waitMsg: 'Patientez',
url: '_ajax/smartGroupGenerateurPlanning_supprimer.php',
params: {
ids: lieuxAsupprimer
},
success: function (result, request) {
store_gererModelesMailing.reload();
gritter('ok', window.DONNEESDEBASE_PRODUCTIONS_CATEGORIESROLE_GRID1_COLONNE2_MESSAGE_OK_TXT);
var valeurActuelleCombo = Ext.getCmp(idComboSM).getValue();
Ext.getCmp(idComboSM).getStore().reload({
callback: function () {
var store = Ext.getCmp(idComboSM).getStore();
var record = store.getById(valeurActuelleCombo);
if (typeof (record) !== 'undefined') {
Ext.getCmp(idComboSM).setValue(valeurActuelleCombo);
} else {
Ext.getCmp(idComboSM).setValue('');
Ext.getCmp(idComboSM).fireEvent('change');
}
}
});
}
});
}
},
icon: Ext.MessageBox.QUESTION
});
}
}
}]
});
function editerInlineModeleMailing(oGrid_event) {
Ext.Ajax.request({
waitMsg: 'Please wait',
url: '_ajax/editerInlineSmartGroupGenerateurPlanning.php',
params: {
id: oGrid_event.record.data.id,
intitule: oGrid_event.record.data.intitule
},
success: function () {
store_gererModelesMailing.reload();
gritter('ok');
Ext.getCmp(idComboSM).getStore().load();
}
});
}
grid_gererModelesMailing.on('afteredit', editerInlineModeleMailing);
grid_gererModelesMailing.on('beforeedit', function (oGrid_event) {
if (oGrid_event.record.data.droit < 3) {
gritter('ko', 'Cette action n\'est pas autorisée');
return false;
}
});
window_gererModelesMailing = new Ext.Window({
title: window.CALENDRIERS_GENERATEURPLANNING_MENUSELECTION_SMARTGROUP,
closable: true,
draggable: true,
modal: true,
width: 750,
resizable: false,
height: 500,
plain: true,
layout: 'fit',
id: 'window_gererModelesMailingId',
items: grid_gererModelesMailing
}).show();
store_gererModelesMailing.load();
}
function number_format (number, decimals, dec_point, thousands_sep, retourneEntier=false) {
// Strip all characters but numerical ones.
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
if(!retourneEntier) {
return s.join(dec);
} else {
toReturn = s.join(dec);
return toReturn.replace(dec_point+'00','');
}
}
Date.prototype.getWeek = function(start)
{
//Calcing the starting point
start = start || 0;
var today = new Date(this.setHours(0, 0, 0, 0));
var day = today.getDay() - start;
var date = today.getDate() - day+1;
// Grabbing Start/End Dates
var StartDate = new Date(today.setDate(date));
var EndDate = new Date(today.setDate(date + 6));
return [StartDate, EndDate];
}
function sortDates(a, b) {
return a.getTime() - b.getTime();
}
function tooltipValeurMultiCombo(idChamp,tabParams) {
_tooltipValeurMultiCombo(idChamp,tabParams);
}
Array.prototype.remove = function() {
var what, a = arguments, L = a.length, ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
window.tabLovCombo2Grid = new Array();
function lovCombo2Grid(idCombo,tabPreLoad) {
window.tabLovCombo2Grid[idCombo] = new Array();
Ext.apply(Ext.getCmp(idCombo),{
setValue: function(v){
this.constructor.prototype.setValue.apply(this, arguments);
if(typeof(v) !== 'undefined') {
window.tabLovCombo2Grid[idCombo] = v.split(',');
}
var tab = window.tabLovCombo2Grid[idCombo];
// Calcul longueur tab
var longueur = 0;
$j.each(tab, function(index,value) {
if(parseInt(value)>0) {
++longueur;
}
});
$j('#spanNB_'+idCombo).empty().append(longueur);
}
});
$j('#'+idCombo).parent().css('display','block');
$j('#'+idCombo).parent().parent().append('');
$j('#lovCombo2GridLoupe'+idCombo).click(function() {
DS_gridLov2Combo = new Ext.data.Store({
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/grid_valeurs_lovCombo2Grid.php',
method: 'POST'
}),
baseParams:{tabSelection:Ext.encode(window.tabLovCombo2Grid[idCombo]),table:Ext.getCmp(idCombo).getStore().proxy.url,sort: 'ordre', dir: 'ASC'},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'coche', type: 'int', mapping: 'coche'},
{name: 'intitule', type: 'string', mapping: 'intitule'},
{name: 'selectionne', type: 'int', mapping: 'selectionne'},
]),sortInfo:{field: 'selectionne', direction: "DESC"}
});
SM_gridLov2Combo = new Ext.grid.ColumnModel(
[{
header: window.LOVCOMBO2GRID_COL1,
sortable: true,
dataIndex: 'intitule',
width: 220
},{
header: window.LOVCOMBO2GRID_COL2,
sortable: true,
dataIndex: 'selectionne',
width: 70,
renderer:function(value) {
if(value==0) {
return window.LOVCOMBO2GRID_NON;
} else {
return window.LOVCOMBO2GRID_OUI;
}
}
}
]
);
GD_gridLov2Combo = new Ext.grid.EditorGridPanel({
store: DS_gridLov2Combo,
height:250,
stateful: true,
clicksToEdit:2,
loadMask:true,
collapsible:false,
collapsed:false,
stripeRows: true,
enableColLock:false,
view: new Ext.grid.GridView({
forceFit:true,
}),
enableHdMenu:false,
loadMask: 'Chargement des données…',
cm: SM_gridLov2Combo,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
listeners:{
cellclick:function(thisCustom, index, columnIndex, e) {
if(columnIndex==0) {
var record = DS_gridLov2Combo.getAt(index);
if($j(e.target).hasClass('boldItalicRow')) {
$j(e.target).parent().next().children().empty().append(window.LOVCOMBO2GRID_NON);
$j(e.target).parent().next().children().removeClass('boldItalicRow');
$j(e.target).removeClass('boldItalicRow');
var index = window.tabLovCombo2Grid[idCombo].indexOf(record.data.id);
window.tabLovCombo2Grid[idCombo].splice(index, 1);
} else {
$j(e.target).parent().next().children().empty().append(window.LOVCOMBO2GRID_OUI);
$j(e.target).parent().next().children().addClass('boldItalicRow');
$j(e.target).addClass('boldItalicRow');
window.tabLovCombo2Grid[idCombo].push(record.data.id);
}
}
}
},
tbar:[
{
text:window.TEXTE_LOVCOMBOTBAR_CHECKALL,
iconCls:'selectall',
handler:function() {
window.tabLovCombo2Grid[idCombo] = new Array();
DS_gridLov2Combo.each(function(e,index) {
var record = DS_gridLov2Combo.getAt(index);
var el = GD_gridLov2Combo.getView().getRow(index);
window.tabLovCombo2Grid[idCombo].push(record.data.id);
$j(el).find('.x-grid3-cell-inner').parent().next().children().empty().append(window.LOVCOMBO2GRID_OUI);
$j.each($j(el).find('.x-grid3-cell-inner'), function(index,value) {
value.addClass('boldItalicRow');
});
})
}
},
{
text:window.TEXTE_LOVCOMBOTBAR_UNCHECKALL,
iconCls:'unselectall',
handler:function() {
window.tabLovCombo2Grid[idCombo] = new Array();
DS_gridLov2Combo.each(function(e,index) {
var record = DS_gridLov2Combo.getAt(index);
var el = GD_gridLov2Combo.getView().getRow(index);
window.tabLovCombo2Grid[idCombo].remove(record.data.id);
$j(el).find('.x-grid3-cell-inner').parent().next().children().empty().append(window.LOVCOMBO2GRID_NON);
$j.each($j(el).find('.x-grid3-cell-inner'), function(index,value) {
value.removeClass('boldItalicRow');
});
})
}
},
'-',
{
xtype:'displayfield',
html:window.LOVCOMBO2GRID_RECHERCHERAPIDE+' : '
},
{
xtype:'textfield',
id:'GD_gridLov2Combo_rechercheRapideId',
width:200,
enableKeyEvents:true,
listeners:{
specialkey: function(f,e){
if(e.getKey() == e.ENTER){
DS_gridLov2Combo.baseParams.term=Ext.getCmp('GD_gridLov2Combo_rechercheRapideId').getValue();
DS_gridLov2Combo.load();
}
}
}
},
{
iconCls:'erase',
text:window.BUTTONRAZ,
handler:function() {
Ext.getCmp('GD_gridLov2Combo_rechercheRapideId').setValue('');
DS_gridLov2Combo.baseParams.term='';
DS_gridLov2Combo.load();
}
}
]
});
//DS_gridLov2Combo.load();
new Ext.Window({
title: window.LOV2COMBO_TITREFENETRE,
closable:true,
id:'lovCombo2GridWindowId',
draggable:true,
maximizable:false,
modal:true,
width: 700,
resizable:false,
height: 450,
plain:true,
layout: 'fit',
items:GD_gridLov2Combo,
listeners:{
close:function() {
var tab = window.tabLovCombo2Grid[idCombo];
Ext.getCmp(idCombo).setValue(tab.join(','));
},
show:function() {
valueProductions = Ext.getCmp(idCombo).getValue();
tabValuesProductions = valueProductions.split(',');
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(tabValuesProductions);
DS_gridLov2Combo.load({callback:function() {
$j.each(tabValuesProductions, function(index,value) {
var record = DS_gridLov2Combo.getAt(DS_gridLov2Combo.find('id',parseInt(value)));
record.data.selectionne=1;
record.commit();
});
DS_gridLov2Combo.each(function(e,index) {
var record = DS_gridLov2Combo.getAt(index);
if(inArray(record.data.id,tabValuesProductions)) {
var el = GD_gridLov2Combo.getView().getRow(index);
$j(el).find('.x-grid3-cell-inner').addClass('boldItalicRow');
}
});
window.tabLovCombo2Grid[idCombo] = tabValuesProductions;
}});
}
},
bbar:[
{xtype:'tbfill'},{
text:window.LOV2COMBO_BUTTONVALIDER,
iconCls:'check',
handler:function() {
Ext.getCmp('lovCombo2GridWindowId').close();
}
}
]
}).show();
});
}
window.tabLovCombo2Grid = new Array();
function lovCombo3Grid(idCombo,tabPreLoad) {
window.tabLovCombo2Grid[idCombo] = new Array();
Ext.apply(Ext.getCmp(idCombo),{
setValue: function(v){
this.constructor.prototype.setValue.apply(this, arguments);
if(typeof(v) !== 'undefined') {
window.tabLovCombo2Grid[idCombo] = v.split(',');
}
var tab = window.tabLovCombo2Grid[idCombo];
// Calcul longueur tab
var longueur = 0;
$j.each(tab, function(index,value) {
if(parseInt(value)>0) {
++longueur;
}
});
$j('#spanNB_'+idCombo).empty().append(longueur);
if(longueur > 0)
{
$j('#lovCombo2GridDelete'+idCombo).css('display', 'block')
}
}
});
$j('#'+idCombo).parent().css('display','none');
$j('#'+idCombo).parent().parent().append('');
$j('#lovCombo2GridDelete'+idCombo).click(function() {
Ext.getCmp('formulaire_rechercherContactMesure_productionId').setValue('');
$j('#spanNB_'+idCombo).empty().append(0);
$j('#lovCombo2GridDelete'+idCombo).css('display', 'none')
});
$j('#lovCombo2GridLoupe'+idCombo).click(function() {
DS_gridLov2Combo = new Ext.data.Store({
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: '_datasMysql/grid_valeurs_lovCombo3Grid.php',
method: 'POST'
}),
baseParams:{
tabSelection: Ext.encode(window.tabLovCombo2Grid[idCombo]),
table: Ext.getCmp(idCombo).getStore().proxy.url,
sort: 'ordre',
dir: 'ASC',
idProduction: Ext.getCmp('fieldSetAutreProduction_formulaire_productionId').getValue()
},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
{name: 'nom', type: 'string', mapping: 'nom'},
{name: 'selectionne', type: 'int', mapping: 'selectionne'},
]),sortInfo:{field: 'id', direction: "ASC"}, //{field: 'selectionne', direction: "DESC"} //permet de filtrer par oui ou non
listeners:{
load: function(grid) {
setTimeout(function() {
var grid = Ext.getCmp('GD_gridLov2Combo_Id')
grid.getStore().each(function(record, index) {
var cellElement = grid.getView().getCell(index, 0);
var nom = record.get('nom');
$j(cellElement).tooltip({
container: 'body',
boundary:'window',
trigger: 'hover',
delay: {
// hide: 100
},
placement: 'left',
title: nom,
html: true
});
});
}, 250);
},
}
});
//boldItalicRow
SM_gridLov2Combo = new Ext.grid.ColumnModel([{
header: window.LOVCOMBO2GRID_COL1,
sortable: false,
dataIndex: 'nom',
width: 220,
renderer: function(value, metadata, record) {
return value;
}
}, {
header: window.LOVCOMBO2GRID_COL2,
sortable: false,
dataIndex: 'selectionne',
width: 70,
renderer: function(value, metadata, record) {
if (value === 0) {
return window.LOVCOMBO2GRID_NON;
} else {
return window.LOVCOMBO2GRID_OUI;
}
}
}]);
GD_gridLov2Combo = new Ext.grid.EditorGridPanel({
store: DS_gridLov2Combo,
autoload: false,
height:$j(window).height()-190,
stateful: true,
clicksToEdit:2,
id: 'GD_gridLov2Combo_Id',
loadMask:true,
collapsible:false,
collapsed:false,
xtype:'grid',
stripeRows: true,
enableColLock:false,
view: new Ext.grid.GridView({
forceFit:true,
getRowClass: function(row, index) {
var cls = '';
var data = row.data;
if (data.selectionne == 1) {
var cls = 'ligne_gras ligne_italic';
}
return cls;
}
}),
enableHdMenu:false,
loadMask: 'Chargement des données…',
cm: SM_gridLov2Combo,
selModel: new Ext.grid.RowSelectionModel({
singleSelect:false
}),
listeners:{
afterrender: function(grid) {
var gridEl = grid.getEl();
var firstSubDiv = gridEl.dom.querySelector('div');
console.log(firstSubDiv)
var SubDiv = ((((firstSubDiv.childNodes[1]).firstChild).firstChild).childNodes[1]).firstChild;
finalAcces = SubDiv.children
console.log(finalAcces)
for (var key in finalAcces) {
console.log(key)
}
},
cellclick:function(thisCustom, index, columnIndex, e) {
if(window.preventClickReload_GD_gridLov2Combo) {
return false;
}
window.preventClickReload_GD_gridLov2Combo=true;
if(columnIndex==0) {
var record = DS_gridLov2Combo.getAt(index);
valueProductions = window.tabLovCombo2Grid[idCombo];
valueProductions = valueProductions.map(String);
var idRoleRecherche = record.data.id.toString()
var tableauVerif = valueProductions
let etatIdTrouvee = false;
//console.log("-----------Tableau---------")
//console.log(idRoleRecherche)
//console.log(tableauVerif)
//console.log("-----------Tableau---------")
for (let i = 0; i < tableauVerif.length; i++) {
if (tableauVerif[i] === idRoleRecherche) {
etatIdTrouvee = true;
break;
}
}
if(etatIdTrouvee) {
console.log("------ 1 ------");
//console.log(e.target);
$j(e.target).parent().next().children().empty().append(window.LOVCOMBO2GRID_NON);
$j(e.target).parent().next().children().removeClass('boldItalicRow');
$j(e.target).removeClass('boldItalicRow');
$j(e.target).closest('.x-grid3-row').removeClass("ligne_gras ligne_italic");
$j(e.target).parent().next().children().removeClass('ligne_gras');
$j(e.target).removeClass('ligne_gras');
tableau = window.tabLovCombo2Grid[idCombo];
tableau = tableau.map(String);
//var tableau = window.tabLovCombo2Grid[idCombo]
var valeur = record.data.id.toString();
var indexSupression = tableau.indexOf(valeur);
console.log("-----------Tableau avec index---------")
console.log(indexSupression)
console.log(tableau)
console.log("-----------Tableau avec index---------")
console.log("indexSupression : " + indexSupression)
// Si l'élément avec l'ID spécifié est trouvé, le supprimer du tableau
if (indexSupression !== -1) {
console.log("Trouvé !")
tableau.splice(indexSupression, 1);
//console.log('-------******-------')
var chaine = ""
chaine = tableau.map(function(element) {
return element;
}).join(',');
Ext.getCmp('formulaire_rechercherContactMesure_productionId').setValue(chaine)
valueProductions = Ext.getCmp(idCombo).getValue();
tabValuesProductions = valueProductions.split(',');
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(tabValuesProductions);
DS_gridLov2Combo.load({callback:function() {
window.preventClickReload_GD_gridLov2Combo=false;
//console.log("store reload")
//console.log('-------******-------')
}});
}
else
{
console.log("Non trouvé !")
window.preventClickReload_GD_gridLov2Combo=false;
}
//console.log(window.tabLovCombo2Grid[idCombo])
} else {
console.log("------ 2 ------");
$j(e.target).parent().next().children().empty().append(window.LOVCOMBO2GRID_OUI);
$j(e.target).parent().next().children().addClass('boldItalicRow');
$j(e.target).addClass('boldItalicRow');
window.preventClickReload_GD_gridLov2Combo=false;
window.tabLovCombo2Grid[idCombo].push(record.data.id.toString());
//console.log(window.tabLovCombo2Grid[idCombo]);
//Ext.getCmp('formulaire_rechercherContactMesure_productionId').setValue(window.tabLovCombo2Grid[idCombo]);
var chaine = ""
var tableau = window.tabLovCombo2Grid[idCombo]
chaine = tableau.map(function(element) {
return element;
}).join(',');
Ext.getCmp('formulaire_rechercherContactMesure_productionId').setValue(chaine)
valueProductions = window.tabLovCombo2Grid[idCombo];
//console.log('valeur prod');
//console.log(valueProductions);
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(valueProductions);
DS_gridLov2Combo.load({callback:function() {
//console.log("record.data.id : "+record.data.id);
//console.log(window.tabLovCombo2Grid[idCombo])
}});
}
}
}
},
tbar:new Ext.Toolbar({
items:[
{
text:window.TEXTE_LOVCOMBOTBAR_CHECKALL,
iconCls:'selectall',
handler:function() {
window.tabLovCombo2Grid[idCombo] = new Array();
DS_gridLov2Combo.each(function(e,index) {
var record = DS_gridLov2Combo.getAt(index);
var el = GD_gridLov2Combo.getView().getRow(index);
window.tabLovCombo2Grid[idCombo].push(record.data.id);
$j(el).find('.x-grid3-cell-inner').parent().next().children().empty().append(window.LOVCOMBO2GRID_OUI);
$j.each($j(el).find('.x-grid3-cell-inner'), function(index,value) {
value.addClass('boldItalicRow');
console.log("select ALL !")
});
})
valueProductions = window.tabLovCombo2Grid[idCombo];
valueProductions = valueProductions.map(String);
//console.log("---------- Valeur select all ----------")
//console.log(valueProductions);
//console.log("---------- Valeur select all ----------")
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(valueProductions);
DS_gridLov2Combo.load({callback:function() {
//console.log(window.tabLovCombo2Grid[idCombo])
}});
}
},
{
text:window.TEXTE_LOVCOMBOTBAR_UNCHECKALL,
iconCls:'unselectall',
handler:function() {
window.tabLovCombo2Grid[idCombo] = new Array();
DS_gridLov2Combo.each(function(e,index) {
var record = DS_gridLov2Combo.getAt(index);
var el = GD_gridLov2Combo.getView().getRow(index);
window.tabLovCombo2Grid[idCombo].remove(record.data.id);
$j(el).find('.x-grid3-cell-inner').parent().next().children().empty().append(window.LOVCOMBO2GRID_NON);
$j.each($j(el).find('.x-grid3-cell-inner'), function(index,value) {
value.removeClass('boldItalicRow');
//console.log("unselect 1 !")
value.closest('.x-grid3-row').removeClass("ligne_gras ligne_italic");
Ext.getCmp('formulaire_rechercherContactMesure_productionId').setValue('')
});
})
valueProductions = window.tabLovCombo2Grid[idCombo];
//console.log(valueProductions);
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(valueProductions);
DS_gridLov2Combo.load({callback:function() {
console.log(window.tabLovCombo2Grid[idCombo])
}});
}
},
'-',
{
xtype:'displayfield',
html:window.LOVCOMBO2GRID_RECHERCHERAPIDE+' : '
},
{
xtype:'textfield',
id:'GD_gridLov2Combo_rechercheRapideId',
width:200,
enableKeyEvents:true,
listeners:{
specialkey: function(f,e){
if(e.getKey() == e.ENTER){
DS_gridLov2Combo.baseParams.term=Ext.getCmp('GD_gridLov2Combo_rechercheRapideId').getValue();
DS_gridLov2Combo.load();
}
}
}
},
{
iconCls:'erase',
text:window.BUTTONRAZ,
handler:function() {
Ext.getCmp('GD_gridLov2Combo_rechercheRapideId').setValue('');
DS_gridLov2Combo.baseParams.term='';
//DS_gridLov2Combo.load();
}
}
],
style:'background-color:#F9FBFD'
})
});
//DS_gridLov2Combo.load();
new Ext.Window({
title: window.LOV2COMBO_TITREFENETRE,
closable:true,
id:'lovCombo2GridWindowId',
frichtee:true,
draggable:true,
maximizable:false,
modal:true,
width: 700,
resizable:false,
plain:true,
items:GD_gridLov2Combo,
html:' style="text-align: center;">
![](_img/ajax-loader5.gif)
',
listeners:{
close:function() {
var tab = window.tabLovCombo2Grid[idCombo];
Ext.getCmp(idCombo).setValue(tab.join(','));
},
show:function() {
valueProductions = Ext.getCmp(idCombo).getValue();
tabValuesProductions = valueProductions.split(',');
$j('#lovCombo2GridWindow_inner').empty().append(reponse.content);
DS_gridLov2Combo.baseParams.tabSelection = Ext.encode(tabValuesProductions);
console.log(valueProductions)
DS_gridLov2Combo.load({callback:function() {
//$j.each(tabValuesProductions, function(index,value) {
// var record = DS_gridLov2Combo.getAt(DS_gridLov2Combo.find('id',parseInt(value)));
// record.data.selectionne=1;
// record.commit();
//});
//DS_gridLov2Combo.each(function(e,index) {
// var record = DS_gridLov2Combo.getAt(index);
// if(inArray(record.data.id,tabValuesProductions)) {
// var el = GD_gridLov2Combo.getView().getRow(index);
// $j(el).find('.x-grid3-cell-inner').addClass('boldItalicRow');
// }
//});
//window.tabLovCombo2Grid[idCombo] = tabValuesProductions;
}});
}
},
bbar:[
{xtype:'tbfill'},{
text:window.LOV2COMBO_BUTTONVALIDER,
iconCls:'check',
handler:function() {
Ext.getCmp('lovCombo2GridWindowId').close();
}
}
]
}).show();
Ext.getCmp('GD_gridLov2Combo_rechercheRapideId').on('keyup', function (field, e) {
var searchTerm = field.getValue();
// Chargez le magasin uniquement si le terme de recherche a au moins trois caractères
if (searchTerm.length >= 3) {
DS_gridLov2Combo.baseParams.term = searchTerm;
DS_gridLov2Combo.load();
}
});
});
}
function isInt(n) {
return n % 1 === 0;
}
function isValidBarcode(barcode) {
// check length
if (barcode.length < 8 || barcode.length > 18 ||
(barcode.length != 8 && barcode.length != 12 &&
barcode.length != 13 && barcode.length != 14 &&
barcode.length != 18)) {
return false;
}
var lastDigit = Number(barcode.substring(barcode.length - 1));
var checkSum = 0;
if (isNaN(lastDigit)) { return false; } // not a valid upc/ean
var arr = barcode.substring(0,barcode.length - 1).split("").reverse();
var oddTotal = 0, evenTotal = 0;
for (var i=0; i'
}).show();
*/
}
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
function unique(array){
return array.filter(function(el, index, arr) {
return index == arr.indexOf(el);
});
}
function onlyUniqueArray(value, index, self) {
return self.indexOf(value) === index;
}
function strip_tags(str, allow) {
// making sure the allow arg is a string containing only tags in lowercase ()
allow = (((allow || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;
var commentsAndPhpTags = /|<\?(?:php)?[\s\S]*?\?>/gi;
return str.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
return allow.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
});
}
function comboSelectNextItem( combo, nextPrev) {
var store = combo.getStore();
var value = combo.getValue();
var index = store.find( combo.valueField, value );
var next_index = index + nextPrev;
var next_record = store.getAt( next_index );
if(typeof(next_record) === 'undefined') {
return false;
} else {
ComboSetter(combo,next_record.data.id,false);
return true;
}
}
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf())
dat.setDate(dat.getDate() + days);
return dat;
}
function getRangeDates(startDate, stopDate) {
var dateArray = new Array();
var currentDate = startDate;
while (currentDate < stopDate) {
dateArray.push( new Date (currentDate) )
currentDate = currentDate.addDays(1);
}
return dateArray;
}
function validEmail(e) {
var filter = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
return String(e).search (filter) != -1;
}
function containSpecialCharacters(chaine) {
if(/^[a-zA-Z0-9- ]*$/.test(chaine) == false) {
return false;
}
return true;
}
function makeid()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 15; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
function inArray(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}
function addslashes(str) {
return (str + '')
.replace(/[\\"']/g, '\\$&')
.replace(/\u0000/g, '\\0');
}
$j.fn.scrollTo = function( target, options, callback ){
if(typeof options == 'function' && arguments.length == 2){ callback = options; options = target; }
var settings = $j.extend({
scrollTarget : target,
offsetTop : 50,
duration : 500,
easing : 'swing'
}, options);
return this.each(function(){
var scrollPane = $j(this);
var scrollTarget = (typeof settings.scrollTarget == "number") ? settings.scrollTarget : $j(settings.scrollTarget);
var scrollY = (typeof scrollTarget == "number") ? scrollTarget : scrollTarget.offset().top + scrollPane.scrollTop() - parseInt(settings.offsetTop);
scrollPane.animate({scrollTop : scrollY }, parseInt(settings.duration), settings.easing, function(){
if (typeof callback == 'function') { callback.call(this); }
});
});
}
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function zeroPad(num, places) {
var zero = places - num.toString().length + 1;
return Array(+(zero > 0 && zero)).join("0") + num;
}
function preventDefaultForScrollKeys(e) {
if (keys[e.keyCode]) {
preventDefault(e);
return false;
}
}
function disableScroll() {
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
document.onkeydown = preventDefaultForScrollKeys;
}
function enableScroll() {
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
}
function scrollToAnchor(aid){
var aTag = $j("a[name='"+ aid +"']");
$j('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
function dateDiff(date1, date2){
var diff = {} // Initialisation du retour
var tmp = date2 - date1;
tmp = Math.floor(tmp/1000); // Nombre de secondes entre les 2 dates
diff.sec = tmp % 60; // Extraction du nombre de secondes
tmp = Math.floor((tmp-diff.sec)/60); // Nombre de minutes (partie entière)
diff.min = tmp % 60; // Extraction du nombre de minutes
tmp = Math.floor((tmp-diff.min)/60); // Nombre d'heures (entières)
diff.hour = tmp % 24; // Extraction du nombre d'heures
tmp = Math.floor((tmp-diff.hour)/24); // Nombre de jours restants
diff.day = tmp;
return diff;
}
function explode(delimiter, string, limit) {
// discuss at: http://phpjs.org/functions/explode/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// example 1: explode(' ', 'Kevin van Zonneveld');
// returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
if (arguments.length < 2 || typeof delimiter === 'undefined' || typeof string === 'undefined') return null;
if (delimiter === '' || delimiter === false || delimiter === null) return false;
if (typeof delimiter === 'function' || typeof delimiter === 'object' || typeof string === 'function' || typeof string ===
'object') {
return {
0: ''
};
}
if (delimiter === true) delimiter = '1';
// Here we go...
delimiter += '';
string += '';
var s = string.split(delimiter);
if (typeof limit === 'undefined') return s;
// Support for limit
if (limit === 0) limit = 1;
// Positive limit
if (limit > 0) {
if (limit >= s.length) return s;
return s.slice(0, limit - 1)
.concat([s.slice(limit - 1)
.join(delimiter)
]);
}
// Negative limit
if (-limit >= s.length) return [];
s.splice(s.length + limit);
return s;
}
function implode(glue, pieces) {
// discuss at: http://phpjs.org/functions/implode/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Waldo Malqui Silva
// improved by: Itsacon (http://www.itsacon.net/)
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']);
// returns 1: 'Kevin van Zonneveld'
// example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'});
// returns 2: 'Kevin van Zonneveld'
var i = '',
retVal = '',
tGlue = '';
if (arguments.length === 1) {
pieces = glue;
glue = '';
}
if (typeof pieces === 'object') {
if (Object.prototype.toString.call(pieces) === '[object Array]') {
return pieces.join(glue);
}
for (i in pieces) {
retVal += tGlue + pieces[i];
tGlue = glue;
}
return retVal;
}
return pieces;
}
Ext.override(Ext.form.ComboBox, {
setValue : function(v, fireSelect){
var text = v;
if(this.valueField){
var r = this.findRecord(this.valueField, v);
if(r){
text = r.data[this.displayField];
if (fireSelect) {
this.fireEvent('select', this, r, this.store.indexOf(r));
}
}else if(Ext.isDefined(this.valueNotFoundText)){
text = this.valueNotFoundText;
}
}
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = v;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = v;
return this;
}
});
function ComboSetter(comboBox, value, fireSelect) {
var store = comboBox.store;
var valueField = comboBox.valueField;
var displayField = comboBox.displayField;
var recordNumber = store.find(valueField, value, 0);
if (recordNumber == -1)
return -1;
var displayValue = store.getAt(recordNumber).data[displayField];
comboBox.setValue(value,fireSelect);
comboBox.setRawValue(displayValue);
comboBox.selectedIndex = recordNumber;
return recordNumber;
}
function ComboSetterCustom(comboBox, value, fireSelect) {
var store = comboBox.store;
var valueField = comboBox.valueField;
var displayField = comboBox.displayField;
var recordNumber = store.findExact(valueField, parseInt(value), 0);
console.log(recordNumber);
if (recordNumber == -1)
return -1;
var displayValue = store.getAt(recordNumber).data[displayField];
comboBox.setValue(parseInt(value),fireSelect);
comboBox.setRawValue(displayValue);
comboBox.selectedIndex = recordNumber;
return recordNumber;
}
Ext.override(Ext.grid.GroupingView, {
beforeMenuShow : function(){
var field = this.getGroupField();
var g = this.hmenu.items.get('groupBy');
if(g){
g.setDisabled(this.cm.config[this.hdCtxIndex].groupable === false);
}
/*
var s = this.hmenu.items.get('showGroups');
if(s){
s.setDisabled(!field && this.cm.config[this.hdCtxIndex].groupable === false);
s.setChecked(!!field, true);
}
*/
}
});
/*
Ext.override(Ext.form.BasicForm,{
getFieldValues : function(dirtyOnly){
console.log('ziou');
var o = {},
n,
key,
val;
this.items.each(function(f) {
if ((dirtyOnly !== true || f.isDirty())) {
n = f.getName();
key = o[n];
val = f.getValue();
if(Ext.isDefined(key)){
if(Ext.isArray(key)){
o[n].push(val);
}else{
o[n] = [key, val];
}
}else{
o[n] = val;
}
}
});
return o;
}
});
*/
Ext.override(Ext.data.Store,{
afterEdit : function(record, hashPrevious){
if(this.modified.indexOf(record) == -1){
this.modified.push(record);
}
this.fireEvent('update', this, record, Ext.data.Record.EDIT, hashPrevious);
},
// private
afterReject : function(record, hashPrevious){
this.modified.remove(record);
this.fireEvent('update', this, record, Ext.data.Record.REJECT, hashPrevious);
}
});
function cleanHTML(input) {
// 1. remove line breaks / Mso classes
var stringStripper = /(\n|\r| clas__s=(")?M__so[a-zA-Z]+(")?)/g;
var output = input.replace(stringStripper, ' ');
// 2. strip Word generated HTML comments
var commentSripper = new RegExp('','g');
var output = output.replace(commentSripper, '');
var tagStripper = new RegExp('<(/)*(meta|link|sp__an|\\?xml:|st1:|o:|font)(.*?)>','gi');
// 3. remove tags leave content if any
output = output.replace(tagStripper, '');
// 4. Remove everything in between and including tags '