--- /dev/null
+/*
+Copyright (c) Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+For licensing, see README.txt or http://www.pentilanero.com (Cecill-C or AGPL or LGPL)
+*/
+Ext.ns("EntSavoie.GestionVieScolaire");
+EntSavoie.GestionVieScolaire.EDTAdminSynchro = function (config) {
+ Ext.apply(this, config);
+ Ext.QuickTips.init();
+ Ext.form.Field.prototype.msgTarget = 'side';
+
+ this.wait = null;
+
+ this.lastUploadDate = this.lastUploadDate || new Ext.form.Label({
+ text: '',
+ style : 'padding: 5px 5px 5px 5px; text-align: left; color:#3764A0; font-size: 12px;'
+ });
+
+ this.lastUploadDatePanel = this.lastUploadDatePanel || new Ext.form.FormPanel({
+ border: false,
+ labelWidth: 220,
+ style: "margin-top: 10px;",
+ padding: 5,
+ items: [
+ this.lastUploadDate
+ ]
+ });
+
+ this.lastSynchroDate = this.lastSynchroDate || new Ext.form.Label({
+ text: '',
+ style : 'padding: 5px 5px 5px 5px; text-align: left; color:#3764A0; font-size: 12px;'
+ });
+
+ this.lastSynchroDatePanel = this.lastSynchroDatePanel || new Ext.form.FormPanel({
+ border: false,
+ labelWidth: 220,
+ style: "margin-top: 10px;",
+ padding: 5,
+ items: [
+ this.lastSynchroDate
+ ]
+ });
+
+
+ this.filterText = this.filterText || new Ext.form.Label({
+ text: this.i18n.GestionVieScolaire.EDTAdminSynchro.filterText,
+ style : 'padding: 5px 5px 5px 5px; text-align: center; color:#3764A0; font-size: 12px;'
+ });
+
+ this.emptyText = this.emptyText || new Ext.form.Label({
+ text: " ",
+ style : 'padding: 5px 5px 5px 5px; text-align: left; color:#3764A0; font-size: 12px;'
+ });
+
+ this.filterBeginDate = this.filterBeginDate || new Ext.form.DateField({
+ fieldLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.beginDate,
+ format: "d-m-Y",
+ allowBlank: true,
+ value: new Date(),
+ width: 100,
+ editable: true,
+ style: "padding-left: 20px !important;",
+ name: 'startdt'
+ });
+
+ this.filterEndDate = this.filterEndDate || new Ext.form.DateField({
+ fieldLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.endDate,
+ format: "d-m-Y",
+ allowBlank: true,
+ value: (new Date()).add(Date.MONTH, 1),
+ width: 100,
+ editable: true,
+ style: "padding-left: 20px !important;",
+ name: 'enddt'
+ });
+
+ // Store for teachers
+ this.filterTeacherStore = this.filterTeacherStore || new Ext.data.JsonStore({
+ autoLoad: true,
+ root: 'enseignants',
+ idProperty: 'id',
+ fields: ["id",'name'],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistTeachers.jsp',
+ sortInfo:{
+ field: 'name',
+ direction: "ASC"
+ }
+ });
+
+ // Store for classes
+ this.filterClassesStore = this.filterClassesStore || new Ext.data.JsonStore({
+ autoLoad: true,
+ root: 'orgs',
+ idProperty: 'organizationId',
+ fields: ['organizationId' , 'name'],
+ url: this.renderURLAjax+'&jspPage=%2Fajax%2FlistClasses.jsp',
+ sortInfo:{
+ field: 'name',
+ direction: "ASC"
+ }
+ });
+
+ this.filterTeacherCombo = this.filterTeacherCombo || new Ext.form.ComboBox({
+ listClass: "gestionVieScolaire-portlet",
+ name: "enseignantImport",
+ fieldLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.teacherCombo.fieldLabel,
+ emptyText: this.i18n.GestionVieScolaire.EDTAdminSynchro.teacherCombo.emptyText,
+ valueField: 'id',
+ displayField: 'name',
+ editable: false,
+ triggerAction: 'all',
+ allowBlank: true,
+ store: this.filterTeacherStore
+ });
+
+ this.filterClassCombo = this.filterClassCombo || new Ext.form.ComboBox({
+ listClass: "gestionVieScolaire-portlet",
+ name: "divisionImport",
+ fieldLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.classCombo.fieldLabel,
+ emptyText: this.i18n.GestionVieScolaire.EDTAdminSynchro.classCombo.emptyText,
+ valueField: 'organizationId',
+ displayField: 'name',
+ editable: false,
+ triggerAction: 'all',
+ allowBlank: true,
+ store: this.filterClassesStore
+ });
+
+ this.filterPanel = this.filterPanel || new Ext.form.FormPanel({
+ border: true,
+ id: 'filterPanel',
+ labelWidth: 150,
+ fileUpload: false,
+ style: "margin-top: 10px;",
+ padding: 5,
+ left: '100px',
+ items: [
+ {
+ border: false,
+ layout: "column",
+ width: 600,
+ items: [this.filterText]
+ },
+ {
+ border: false,
+ layout: "column",
+ width: 500,
+ items: [
+ {
+ columnWidth: 0.7,
+ border: false,
+ layout: "form",
+ labelWidth: 220,
+ items: [this.filterBeginDate]
+ },
+ {
+ columnWidth: 0.3,
+ border: false,
+ layout: "form",
+ labelWidth: 30,
+ items: [this.filterEndDate]
+ },
+ ]
+ },
+ this.filterTeacherCombo,
+ this.filterClassCombo,
+ ]
+ });
+
+
+ this.groupCheckbox = this.groupCheckbox || new Ext.form.Checkbox({
+ boxLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.groupCheckboxLabel,
+ checked: false,
+ name: "groupCheckboxLabel"
+ });
+
+ this.agendaCheckbox = this.agendaCheckbox || new Ext.form.Checkbox({
+ boxLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.agendaCheckboxLabel,
+ checked: false,
+ id: 'agendaCheckbox',
+ name: "agendaCheckboxLabel"
+ });
+
+ this.schedulerCheckbox = this.schedulerCheckbox || new Ext.form.Checkbox({
+ boxLabel: this.i18n.GestionVieScolaire.EDTAdminSynchro.schedulerCheckboxLabel,
+ checked: false,
+ id: "schedulerCheckbox",
+ name: "schedulerCheckbox",
+ listeners: {
+ check: function () {
+ // Enable or disable both agenda checkbox and filterPanel when clicked on scheduler checkbox
+ console.log("check simple event : value="+Ext.getCmp('schedulerCheckbox').getValue());
+ console.log("check simple event : value="+this.getValue());
+ if (Ext.getCmp('schedulerCheckbox').getValue() == true) {
+ console.log("enable filter");
+ Ext.getCmp('filterPanel').enable();
+ Ext.getCmp('agendaCheckbox').setValue(true);
+ Ext.getCmp('agendaCheckbox').enable();
+ Ext.getCmp('filterPanel').doLayout();
+ } else {
+ console.log("disable filter");
+ Ext.getCmp('filterPanel').disable();
+ Ext.getCmp('agendaCheckbox').setValue(false);
+ Ext.getCmp('agendaCheckbox').disable();
+ Ext.getCmp('filterPanel').doLayout();
+ }
+ }
+ }
+ });
+
+
+ this.checkboxPanel = this.checkboxPanel || new Ext.form.FormPanel({
+ border: false,
+ labelWidth: 50,
+ fileUpload: false,
+ style: "margin-top: 10px;",
+ padding: 5,
+ items: [
+ this.groupCheckbox,
+ this.schedulerCheckbox
+ ]
+ });
+
+
+ // The import button
+ this.runSyncBtn = this.runSyncBtn || new Ext.Button({
+ text: this.i18n.GestionVieScolaire.EDTAdminSynchro.runSyncBtn,
+ handler: this.onRunSync,
+ top: '30px',
+ align: 'center',
+ style: "margin-top: 10px;",
+ scope: this
+ });
+
+ // File picker
+ this.EDTFile = this.EDTFile || new Ext.ux.form.FileUploadField({
+ emptyText: this.i18n.GestionVieScolaire.EDTAdminSynchro.EDTFile,
+ fieldLabel: "",
+ buttonText: this.i18n.GestionVieScolaire.EDTAdminSynchro.select
+ });
+
+
+ // The button panel
+ this.buttonPanel = this.buttonPanel || new Ext.FormPanel({
+ border: false,
+ labelWidth: 50,
+ columnWidth: 0.7,
+ fileUpload: true,
+ style: "margin-top: 10px;margin-left: 50px;",
+ padding: 5,
+ items: [
+ this.EDTFile,
+ {
+ border : false,
+ height:20
+ },
+ this.runSyncBtn
+ ]
+ });
+
+ // Main panel definition
+ EntSavoie.GestionVieScolaire.EDTAdminSynchro.superclass.constructor.call(this, {
+ title: this.i18n.GestionVieScolaire.EDTAdminSynchro.title,
+ border: false,
+ layout:'form',
+ width: "auto",
+ labelWidth: 220,
+ style: "margin-top: 10px;",
+ padding: 5,
+ items: [
+ this.lastUploadDatePanel,
+ this.lastSynchroDatePanel,
+ this.checkboxPanel,
+
+ {
+ border: false,
+ layout: "column",
+ width: 800,
+ items: [
+ {
+ columnWidth: 0.15,
+ border: false,
+ labelWidth: 120,
+ items: [this.emptyText]
+ },
+ {
+ columnWidth: 0.85,
+ border: false,
+ items: [
+ this.agendaCheckbox,
+ this.filterPanel
+ ]
+ }
+ ]
+ },
+ {
+ border : false,
+ height:20
+ },
+ this.buttonPanel
+ ]
+ });
+
+ // Listeners
+ this.on("render", this.onRenderSynchro, this);
+
+ this.filterTeacherCombo.on("select", this.onSelectTeacherCombo, this);
+ this.filterClassCombo.on("select", this.onSelectClassCombo, this);
+
+};
+
+Ext.extend(EntSavoie.GestionVieScolaire.EDTAdminSynchro, Ext.Panel, {
+ initComponent: function () {
+ EntSavoie.GestionVieScolaire.EDTAdminSynchro.superclass.initComponent.call(this);
+ this.filterPanel.disable();
+ this.agendaCheckbox.disable();
+ this.filterTeacherStore.load();
+ this.filterClassesStore.load();
+
+ // Retrieve last upload date
+ Ext.Ajax.request({
+ url: this.actionURLAjax,
+ params: {
+ cmd: "getSynchroInfos"
+ },
+ scope: this,
+ success: this.onSuccessGetSynchroInfos,
+ failure: this.onFailureGetSynchroInfos
+ });
+
+ },
+
+ // Set filter dates
+ onRenderSynchro: function(panel){
+ Ext.apply(Ext.form.VTypes, {
+ dateValid : function(val, field) {
+ var start = panel.filterBeginDate.getValue();
+ var end = panel.filterEndDate.getValue();
+ if(end>start){
+ return true;
+ }
+ return false;
+ },
+ dateValidText : panel.i18n.GestionVieScolaire.EDTAdminSynchro.dateValidText
+ });
+
+ },
+
+ // Select specific teacher
+ onSelectTeacherCombo: function(cmp, record, index) {
+ if (record.get("id")=="0") {
+ cmp.reset();
+ }
+ },
+
+ // Select specific class
+ onSelectClassCombo: function(cmp, record, index) {
+ if (record.get("organizationId")=="0") {
+ cmp.reset();
+ }
+ },
+
+ // Run the import
+ onRunSync: function(btn) {
+
+ this.buttonPanel.getForm().submit({
+ url: this.actionURLAjax+'&cmd=runEDTSync&fileParam=' + this.EDTFile.id
+ + '&syncMembership=' +this.groupCheckbox.getValue()+ '&syncCDT=' +this.schedulerCheckbox.getValue()+ '&syncAgenda=' +this.agendaCheckbox.getValue()
+ + '&teacherId=' + this.filterTeacherCombo.getValue() + '&classId=' + this.filterClassCombo.getValue()
+ + '&beginDate=' + this.filterBeginDate.getValue() + '&endDate=' + this.filterEndDate.getValue(),
+ success:this.onSuccessRunEDTSync,
+ failure:this.onFailureRunEDTSync,
+ scope:this
+ });
+
+ },
+
+ onSuccessRunEDTSync: function(response, options) {
+
+ var backObj = Ext.decode(response.responseText);
+ Ext.Msg.alert(this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.success.title, this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.success.msg);
+// if (!backObj.success) {
+// Ext.Msg.alert(this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.failure.title, this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.failure.msg);
+// }
+ },
+
+ onFailureRunEDTSync: function(response, options) {
+ Ext.Msg.alert(this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.failure.title, this.i18n.GestionVieScolaire.EDTAdminSynchro.runEDTSync.failure.msg);
+ },
+
+
+ // Get sync infos has succeeded => update date labels
+ onSuccessGetSynchroInfos: function(response, options) {
+
+ var backObj = Ext.decode(response.responseText);
+ if (!backObj.success) {
+ Ext.Msg.alert(this.i18n.GestionVieScolaire.EDTAdminSynchro.getlastupload.failure.title, this.i18n.GestionVieScolaire.EDTAdminSynchro.getlastupload.failure.msg);
+ } else {
+ if (!backObj.isUploaded) {
+ this.lastUploadDate.setText(this.i18n.GestionVieScolaire.EDTAdminSynchro.lastUploadDateLabel + ' : ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.noUpload);
+ } else {
+ this.lastUploadDate.setText(this.i18n.GestionVieScolaire.EDTAdminSynchro.lastUploadDateLabel + ' : ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.a + ' ' + backObj.latestuploadhour + ' ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.le + ' ' + backObj.latestuploadday);
+ this.lastUploadDatePanel.doLayout();
+ }
+
+ if (!backObj.isSynchronized) {
+ this.lastSynchroDate.setText(this.i18n.GestionVieScolaire.EDTAdminSynchro.lastSynchroDateLabel + ' : ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.noSynchro);
+ } else {
+ this.lastSynchroDate.setText(this.i18n.GestionVieScolaire.EDTAdminSynchro.lastSynchroDateLabel + ' : ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.a + ' ' + backObj.latestsynchrohour + ' ' + this.i18n.GestionVieScolaire.EDTAdminSynchro.le + ' ' + backObj.latestsynchroday);
+ this.lastSynchroDatePanel.doLayout();
+ }
+
+ }
+ },
+
+ onFailureGetSynchroInfos: function(response, options) {
+ Ext.Msg.alert(this.i18n.GestionVieScolaire.EDTAdminSynchro.getlastupload.failure.title, this.i18n.GestionVieScolaire.EDTAdminSynchro.getlastupload.failure.msg);
+ }
+
+
+});
+
+