etat de l'imprimante actualis + liste des codes dispos pour l'adherent
darcs-hash:20061110133521-f46e9-24bce8f22f9b7a14cba214e664084b3103e848d9.gz
This commit is contained in:
parent
20f3593951
commit
e8391dfd40
3 changed files with 459 additions and 356 deletions
|
@ -44,20 +44,63 @@ class root:
|
|||
'scripts':['impression.js', 'popup.js'],
|
||||
}
|
||||
index.exposed = True
|
||||
|
||||
##########################
|
||||
# devis
|
||||
##########################
|
||||
#
|
||||
# methode qui affiche la template du devis
|
||||
#
|
||||
|
||||
def devis(self):
|
||||
return {
|
||||
'template':'impression-devis',
|
||||
'values':
|
||||
{
|
||||
'devis':cherrypy.session['impression'].devisDetaille(),
|
||||
'total':cherrypy.session['impression'].prix(),
|
||||
'nomFichier':cherrypy.session['impression'].fileName(),
|
||||
},
|
||||
'standalone':True,
|
||||
}
|
||||
devis.exposed=True
|
||||
|
||||
|
||||
##########################
|
||||
# AJAX
|
||||
##########################
|
||||
#
|
||||
# methode qui renvoie la liste des codes de l'adherent
|
||||
#
|
||||
def codeList(self):
|
||||
try:
|
||||
listeBrute = crans.impression.digicode.list_code()
|
||||
# liste de la forme :
|
||||
# [(code, age, description),...]
|
||||
listeBrute = [item[0] for item in listeBrute if item[2] == cherrypy.session['uid']]
|
||||
return {'codes': listeBrute}
|
||||
except Exception, e:
|
||||
cherrypy.log('erreur lors de la creation de la liste de codes :' + str(e), 'IMPRESSION', 1)
|
||||
return {'erreur':str(e)}
|
||||
codeList.exposed= True
|
||||
|
||||
#
|
||||
# methode qui indique quel fichier utiliser
|
||||
#
|
||||
def useFile(self, fileName):
|
||||
try:
|
||||
filepath = os.path.join(os.path.join(FILE_UPLOAD_BASE_FOLDER, cherrypy.session['uid']+"/"), fileName)
|
||||
cherrypy.session['impression'] = crans.impression.impression(filepath, cherrypy.session['uid'])
|
||||
return {'nbPages': cherrypy.session['impression'].pages()}
|
||||
except Exception, e:
|
||||
cherrypy.log("useFile: %s" % str(e), 'IMPRESSION', 1)
|
||||
cherrypy.log("useFile (erreur): %s" % str(e), 'IMPRESSION', 1)
|
||||
return {'erreur':str(e) }
|
||||
useFile.exposed= True
|
||||
|
||||
|
||||
|
||||
#
|
||||
# methode pour changer les parametres
|
||||
#
|
||||
def changeSettings(self, copies=None, couleurs=None, recto_verso=None, agrafes=None, papier=None):
|
||||
try:
|
||||
nouvPrix = cherrypy.session['impression'].changeSettings(papier=papier, couleurs=couleurs, agraphes=agrafes, recto_verso=recto_verso, copies=int(copies))
|
||||
|
@ -68,6 +111,9 @@ class root:
|
|||
changeSettings.exposed = True
|
||||
|
||||
|
||||
#
|
||||
# methode pour lancer l'impression
|
||||
#
|
||||
def lancerImpression(self):
|
||||
try:
|
||||
cherrypy.session['impression'].imprime()
|
||||
|
@ -76,16 +122,39 @@ class root:
|
|||
except Exception, e:
|
||||
cherrypy.log("lancerImpression (erreur): %s" % str(e), 'IMPRESSION', 1)
|
||||
return {"erreur":str(e)}
|
||||
cherrypy.log("impression demandee " , 'IMPRESSION')
|
||||
return {'code':str(crans.impression.digicode.gen_code("Impression intranet : " + cherrypy.session['uid'])) + "#"}
|
||||
return {'code':str(crans.impression.digicode.gen_code(cherrypy.session['uid'])) + "#"}
|
||||
lancerImpression.exposed = True
|
||||
|
||||
#
|
||||
# methode pour récupérer l'état de l'imprimante
|
||||
#
|
||||
def etatImprimante(self):
|
||||
try:
|
||||
try:
|
||||
return {"printer_state" : "<br />".join(crans.impression.etat_imprimante.etat())
|
||||
except Exception, e:
|
||||
return {"printer_state" : 'Imprimante hors ligne'}
|
||||
etatImprimante.exposed = True
|
||||
|
||||
|
||||
|
||||
|
||||
##########################
|
||||
# privees
|
||||
##########################
|
||||
#
|
||||
# methode pour obtenir la liste des fichiers uploadés
|
||||
#
|
||||
def getUploadedFileListFor(self, adh):
|
||||
file_folder = os.path.join(FILE_UPLOAD_BASE_FOLDER, cherrypy.session['uid']+"/")
|
||||
if not os.path.isdir(file_folder):
|
||||
return []
|
||||
return os.listdir(file_folder)
|
||||
|
||||
|
||||
#
|
||||
# methode pour enregistrer un fichier
|
||||
#
|
||||
def savePDF(self, aFile):
|
||||
|
||||
_, tempFileName = tempfile.mkstemp()
|
||||
|
@ -110,22 +179,6 @@ class root:
|
|||
return newFilePath
|
||||
|
||||
|
||||
##########################
|
||||
# devis
|
||||
##########################
|
||||
#
|
||||
# methode qui affiche la template du devis
|
||||
#
|
||||
|
||||
def devis(self):
|
||||
return {
|
||||
'template':'impression-devis',
|
||||
'values':
|
||||
{
|
||||
'devis':cherrypy.session['impression'].devisDetaille(),
|
||||
'total':cherrypy.session['impression'].prix(),
|
||||
'nomFichier':cherrypy.session['impression'].fileName(),
|
||||
},
|
||||
'standalone':True,
|
||||
}
|
||||
devis.exposed=True
|
||||
|
||||
|
||||
|
|
|
@ -1,332 +1,381 @@
|
|||
/* ************************************************************
|
||||
* Impression
|
||||
************************************************************
|
||||
* Impression.settings : panneau de configuration
|
||||
* Impression.popup : popup
|
||||
* Impression.AJAX : ajax
|
||||
*/
|
||||
Impression = {};
|
||||
|
||||
/*****************************
|
||||
Impression.settings
|
||||
*****************************/
|
||||
|
||||
Impression.settings = {};
|
||||
|
||||
//
|
||||
//// images : images used for previewing
|
||||
//
|
||||
Impression.settings.images = [
|
||||
"portrait_couleurs_agraphediagonale.png",
|
||||
"portrait_couleurs_pasdagraphes.png",
|
||||
"portrait_couleurs_uneagraphe.png",
|
||||
"portrait_couleurs_Deuxagraphes.png",
|
||||
"portrait_couleurs_troisAgraphes.png",
|
||||
"portrait_couleurs_stitching.png",
|
||||
"portrait_nb_agraphediagonale.png",
|
||||
"portrait_nb_pasdagraphes.png",
|
||||
"portrait_nb_uneagraphe.png",
|
||||
"portrait_nb_Deuxagraphes.png",
|
||||
"portrait_nb_troisAgraphes.png",
|
||||
"portrait_nb_stitching.png",
|
||||
"portrait_transparent_couleurs.png",
|
||||
"portrait_transparent_nb.png",
|
||||
];
|
||||
|
||||
Impression.settings.preloadImage = function(imageName) {
|
||||
var image = new Image();
|
||||
image.src = "/static/images/"+imageName;
|
||||
}
|
||||
|
||||
Impression.settings.preloadAllImages = function() {
|
||||
log("Preloading images...");
|
||||
map(this.preloadImage,this.images);
|
||||
}
|
||||
|
||||
//
|
||||
//// init : parse every field and display preview
|
||||
//
|
||||
Impression.settings.init = function () {
|
||||
log("Init settings...");
|
||||
this.theform = document.form_impression;
|
||||
this.disableForm(false);
|
||||
}
|
||||
//
|
||||
//// reset : reset form and then re-init settings
|
||||
//
|
||||
Impression.settings.reset = function () {
|
||||
log("Reset form");
|
||||
this.theform.reset();
|
||||
this.init();
|
||||
}
|
||||
|
||||
Impression.settings.disableForm = function(bool)
|
||||
{
|
||||
log("Set Disable Form : " + bool);
|
||||
var fields = this.theform.elements;
for( var i=0; i< fields.length; i++)
|
||||
{
|
||||
this.setDisableField( fields[i], bool );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//// getValue : parse a field and store value in fielld.name
|
||||
//
|
||||
Impression.settings.getValue = function(field)
|
||||
{
|
||||
if (field.value)
|
||||
{
|
||||
this[field.name] = field.value;
|
||||
log( field.name + " is now " + this[field.name]);
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("Can't get fieldValue");
|
||||
}
|
||||
}
|
||||
//
|
||||
//// getCopies : parse copies field
|
||||
//
|
||||
Impression.settings.getCopies = function(field) {
|
||||
if ( (!field.value) || (parseInt(field.value)!=field.value-0) || (parseInt(field.value) < 1) )
|
||||
{
|
||||
this.copies = 1;
|
||||
logError("Can't get copies");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.copies = parseInt(field.value);
|
||||
}
|
||||
log("copies is now " + this.copies);
|
||||
}
|
||||
|
||||
//
|
||||
//// setValue : set field value
|
||||
//
|
||||
Impression.settings.setValue = function(afield, avalue) {
|
||||
afield.value = avalue;
|
||||
this.getValue(afield)
|
||||
}
|
||||
|
||||
//
|
||||
//// setDisableField : set field disabled on/off
|
||||
//
|
||||
Impression.settings.setDisableField = function( afield, isdisabled ) {
|
||||
afield.disabled = isdisabled ;
|
||||
}
|
||||
|
||||
//
|
||||
//// disableField : set field disabled on
|
||||
//
|
||||
Impression.settings.disableField = function(afield) {
|
||||
this.setDisableField(afield, true);
|
||||
}
|
||||
|
||||
//
|
||||
//// fieldChanges : when a field is changed
|
||||
//
|
||||
Impression.settings.update = function (field) {
|
||||
var orientation = "portrait";
|
||||
if (this.theform.type_impression_couleur.checked)
|
||||
this.getValue(this.theform.type_impression_couleur);
|
||||
else
|
||||
this.getValue(this.theform.type_impression_nb);
|
||||
|
||||
if (this.theform.disposition_recto.checked)
|
||||
this.getValue(this.theform.disposition_recto);
|
||||
else
|
||||
this.getValue(this.theform.disposition_recto_verso);
|
||||
this.getValue(this.theform.papier);
|
||||
this.getCopies(this.theform.nb_copies);
|
||||
this.getValue(this.theform.agrafes);
|
||||
// Contraintes
|
||||
if (
|
||||
( this.papier != "A4" ) ||
|
||||
( (this.disposition == "recto") && (this.nb_pages>50) ) ||
|
||||
( (this.disposition == "rectoverso") && (this.nb_pages>100) ) ) {
|
||||
this.setValue(this.theform.agrafes, "pasdagraphes");
|
||||
this.disableField(this.theform.agrafes);
|
||||
this.getValue(this.theform.agrafes);
|
||||
} else {
|
||||
this.setDisableField(this.theform.agrafes, false);
|
||||
}
|
||||
if (this.papier == "A4tr")
|
||||
{
|
||||
this.theform.disposition_recto.checked = true;
|
||||
this.disableField(this.theform.disposition_recto);
|
||||
this.disableField(this.theform.disposition_recto_verso);
|
||||
this.getValue(this.theform.disposition_recto);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setDisableField(this.theform.disposition_recto, false);
|
||||
this.setDisableField(this.theform.disposition_recto_verso, false);
|
||||
}
|
||||
|
||||
this.updatePreview();
|
||||
Impression.AJAX.recalcPrix();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//// updatePreview : update preview with new value
|
||||
//
|
||||
Impression.settings.updatePreview = function()
|
||||
{
|
||||
var image_name = "";
|
||||
if (this.papier == "A4tr")
|
||||
image_name = "portrait_transparent_" + this.type_impression + ".png";
|
||||
else
|
||||
image_name = "portrait_" + this.type_impression + '_' + this.agrafes + ".png";
|
||||
var image = createDOM("IMG",{'src':'/static/images/'+image_name});
|
||||
log("Updating preview (new image : " + image_name + ")");
|
||||
replaceChildNodes("preview",image)
|
||||
}
|
||||
|
||||
|
||||
/*****************************
|
||||
Impression.popup
|
||||
*****************************/
|
||||
Impression.popup = {};
|
||||
|
||||
Impression.popup.popupImpression = function(code) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Impression en cours...",
|
||||
DIV(
|
||||
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.png)"},
|
||||
SPAN("code: "+code),
|
||||
A({"href":"https://wiki.crans.org/VieCrans/ImpressionReseau", "class":"aide", "target":"_blank"}, "Comment récupérer mon impression ? ")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
Impression.popup.popupError = function(erreur) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Erreur",
|
||||
DIV({"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-warning.png)"},
|
||||
SPAN(erreur),
|
||||
A({"href":"#", "class":"aide", "target":"_blank"}, "Envoyer un rapport aux nounous"),
|
||||
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
Impression.popup.popupSolde = function(code) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Solde insuffisant",
|
||||
DIV(
|
||||
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-solde.png)"},
|
||||
SPAN("pas assez de sous"),
|
||||
A({"href":"https://wiki.crans.org/CransPratique/SoldeImpression", "class":"aide", "target":"_blank"}, "Comment recharger mon compte ? "),
|
||||
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************
|
||||
Impression.AJAX
|
||||
*****************************/
|
||||
|
||||
Impression.AJAX = {};
|
||||
|
||||
|
||||
Impression.AJAX.modifPrix = function( text, wheel )
|
||||
{
|
||||
if (wheel)
|
||||
{
|
||||
var image = createDOM("IMG",{'src':'/static/images/indicator.gif'});
|
||||
}
|
||||
else
|
||||
{
|
||||
var image = new DIV({});
|
||||
}
|
||||
var item = new DIV({'onclick':'Impression.AJAX.recalcPrix();'}, image, text);
|
||||
replaceChildNodes("prix_placeholder",item);
|
||||
}
|
||||
|
||||
Impression.AJAX.modifNbPages = function( nbpages )
|
||||
{
|
||||
Impression.settings.nb_pages = nbpages;
|
||||
replaceChildNodes("fileNbPages",nbpages);
|
||||
}
|
||||
|
||||
Impression.AJAX.call = function(page, callBack) {
|
||||
logDebug("calling AJAX : " + page)
|
||||
var e = loadJSONDoc(page);
|
||||
e.addCallback(callBack);
|
||||
e.addErrback(this.errorHandler);
|
||||
}
|
||||
|
||||
Impression.AJAX.errorHandler = function(d) {
|
||||
//Impression.AJAX..modifPrix("Erreur", false);
|
||||
logError("AJAX Error: " + d);
|
||||
Impression.AJAX.modifPrix("Erreur...", false);
|
||||
}
|
||||
|
||||
|
||||
Impression.AJAX.usefile = function(filename) {
|
||||
var item = new DIV({}, "Calculs en cours...");
|
||||
this.modifPrix("Analyse du fichier...", true);
|
||||
this.call('useFile?fileName=' + filename,this.analysefini );
|
||||
}
|
||||
|
||||
Impression.AJAX.analysefini = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (usefile)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
Impression.settings.disableForm(true);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else {
|
||||
Impression.AJAX.modifPrix("Analyse terminée", true);
|
||||
Impression.settings.update();
|
||||
Impression.AJAX.modifNbPages(AJAXResp.nbPages);
|
||||
}
|
||||
}
|
||||
|
||||
Impression.AJAX.recalcPrix = function()
|
||||
{
|
||||
settings = Impression.settings;
|
||||
var url = "changeSettings?copies=" + settings.copies
|
||||
+"&couleurs="+ settings.type_impression
|
||||
+"&papier="+ settings.papier
|
||||
+"&recto_verso="+ settings.disposition
|
||||
+"&agrafes="+ settings.agrafes;
|
||||
this.modifPrix("Calcul en cours", true);
|
||||
this.call(url, this.changePrix);
|
||||
}
|
||||
|
||||
Impression.AJAX.changePrix = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (recalcPrix)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
Impression.settings.disableForm(true);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else {
|
||||
Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false);
|
||||
}
|
||||
}
|
||||
|
||||
Impression.AJAX.lancerImpression = function(AJAXResp)
|
||||
{
|
||||
var url = "lancerImpression";
|
||||
Impression.settings.disableForm(true);
|
||||
this.call(url, this.etatImpression);
|
||||
}
|
||||
|
||||
Impression.AJAX.etatImpression = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (lancerImpression)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else if (AJAXResp.SoldeInsuffisant) {
|
||||
Impression.popup.popupSolde();
|
||||
Impression.settings.disableForm(false);
|
||||
Impression.settings.update();
|
||||
} else {
|
||||
Impression.popup.popupImpression(AJAXResp.code);
|
||||
}
|
||||
}
|
||||
/* ************************************************************
|
||||
* Impression
|
||||
************************************************************
|
||||
* Impression.settings : panneau de configuration
|
||||
* Impression.popup : popup
|
||||
* Impression.AJAX : ajax
|
||||
*/
|
||||
Impression = {};
|
||||
|
||||
/*****************************
|
||||
Impression.settings
|
||||
*****************************/
|
||||
|
||||
Impression.settings = {};
|
||||
|
||||
//
|
||||
//// images : images used for previewing
|
||||
//
|
||||
Impression.settings.images = [
|
||||
"portrait_couleurs_agraphediagonale.png",
|
||||
"portrait_couleurs_pasdagraphes.png",
|
||||
"portrait_couleurs_uneagraphe.png",
|
||||
"portrait_couleurs_Deuxagraphes.png",
|
||||
"portrait_couleurs_troisAgraphes.png",
|
||||
"portrait_couleurs_stitching.png",
|
||||
"portrait_nb_agraphediagonale.png",
|
||||
"portrait_nb_pasdagraphes.png",
|
||||
"portrait_nb_uneagraphe.png",
|
||||
"portrait_nb_Deuxagraphes.png",
|
||||
"portrait_nb_troisAgraphes.png",
|
||||
"portrait_nb_stitching.png",
|
||||
"portrait_transparent_couleurs.png",
|
||||
"portrait_transparent_nb.png",
|
||||
];
|
||||
|
||||
Impression.settings.preloadImage = function(imageName) {
|
||||
var image = new Image();
|
||||
image.src = "/static/images/"+imageName;
|
||||
}
|
||||
|
||||
Impression.settings.preloadAllImages = function() {
|
||||
log("Preloading images...");
|
||||
map(this.preloadImage,this.images);
|
||||
}
|
||||
|
||||
//
|
||||
//// init : parse every field and display preview
|
||||
//
|
||||
Impression.settings.init = function () {
|
||||
log("Init settings...");
|
||||
this.theform = document.form_impression;
|
||||
this.disableForm(false);
|
||||
}
|
||||
//
|
||||
//// reset : reset form and then re-init settings
|
||||
//
|
||||
Impression.settings.reset = function () {
|
||||
log("Reset form");
|
||||
this.theform.reset();
|
||||
this.init();
|
||||
}
|
||||
|
||||
Impression.settings.disableForm = function(bool)
|
||||
{
|
||||
log("Set Disable Form : " + bool);
|
||||
var fields = this.theform.elements;
|
||||
for( var i=0; i< fields.length; i++)
|
||||
{
|
||||
this.setDisableField( fields[i], bool );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//// getValue : parse a field and store value in fielld.name
|
||||
//
|
||||
Impression.settings.getValue = function(field)
|
||||
{
|
||||
if (field.value)
|
||||
{
|
||||
this[field.name] = field.value;
|
||||
log( field.name + " is now " + this[field.name]);
|
||||
}
|
||||
else
|
||||
{
|
||||
logError("Can't get fieldValue");
|
||||
}
|
||||
}
|
||||
//
|
||||
//// getCopies : parse copies field
|
||||
//
|
||||
Impression.settings.getCopies = function(field) {
|
||||
if ( (!field.value) || (parseInt(field.value)!=field.value-0) || (parseInt(field.value) < 1) )
|
||||
{
|
||||
this.copies = 1;
|
||||
logError("Can't get copies");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.copies = parseInt(field.value);
|
||||
}
|
||||
log("copies is now " + this.copies);
|
||||
}
|
||||
|
||||
//
|
||||
//// setValue : set field value
|
||||
//
|
||||
Impression.settings.setValue = function(afield, avalue) {
|
||||
afield.value = avalue;
|
||||
this.getValue(afield);
|
||||
}
|
||||
|
||||
//
|
||||
//// setDisableField : set field disabled on/off
|
||||
//
|
||||
Impression.settings.setDisableField = function( afield, isdisabled ) {
|
||||
afield.disabled = isdisabled ;
|
||||
}
|
||||
|
||||
//
|
||||
//// disableField : set field disabled on
|
||||
//
|
||||
Impression.settings.disableField = function(afield) {
|
||||
this.setDisableField(afield, true);
|
||||
}
|
||||
|
||||
//
|
||||
//// fieldChanges : when a field is changed
|
||||
//
|
||||
Impression.settings.update = function (field) {
|
||||
var orientation = "portrait";
|
||||
if (this.theform.type_impression_couleur.checked)
|
||||
this.getValue(this.theform.type_impression_couleur);
|
||||
else
|
||||
this.getValue(this.theform.type_impression_nb);
|
||||
|
||||
if (this.theform.disposition_recto.checked)
|
||||
this.getValue(this.theform.disposition_recto);
|
||||
else
|
||||
this.getValue(this.theform.disposition_recto_verso);
|
||||
this.getValue(this.theform.papier);
|
||||
this.getCopies(this.theform.nb_copies);
|
||||
this.getValue(this.theform.agrafes);
|
||||
// Contraintes
|
||||
if (
|
||||
( this.papier != "A4" ) ||
|
||||
( (this.disposition == "recto") && (this.nb_pages>50) ) ||
|
||||
( (this.disposition == "rectoverso") && (this.nb_pages>100) ) )
|
||||
{
|
||||
this.setValue(this.theform.agrafes, "pasdagraphes");
|
||||
this.disableField(this.theform.agrafes);
|
||||
this.getValue(this.theform.agrafes);
|
||||
} else {
|
||||
this.setDisableField(this.theform.agrafes, false);
|
||||
}
|
||||
if (this.papier == "A4tr")
|
||||
{
|
||||
this.theform.disposition_recto.checked = true;
|
||||
this.disableField(this.theform.disposition_recto);
|
||||
this.disableField(this.theform.disposition_recto_verso);
|
||||
this.getValue(this.theform.disposition_recto);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setDisableField(this.theform.disposition_recto, false);
|
||||
this.setDisableField(this.theform.disposition_recto_verso, false);
|
||||
}
|
||||
|
||||
this.updatePreview();
|
||||
Impression.AJAX.recalcPrix();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//// updatePreview : update preview with new value
|
||||
//
|
||||
Impression.settings.updatePreview = function()
|
||||
{
|
||||
var image_name = "";
|
||||
if (this.papier == "A4tr")
|
||||
image_name = "portrait_transparent_" + this.type_impression + ".png";
|
||||
else
|
||||
image_name = "portrait_" + this.type_impression + '_' + this.agrafes + ".png";
|
||||
var image = createDOM("IMG",{'src':'/static/images/'+image_name});
|
||||
log("Updating preview (new image : " + image_name + ")");
|
||||
replaceChildNodes("preview",image)
|
||||
}
|
||||
|
||||
|
||||
/*****************************
|
||||
Impression.popup
|
||||
*****************************/
|
||||
Impression.popup = {};
|
||||
|
||||
Impression.popup.popupImpression = function(code) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Impression en cours...",
|
||||
DIV(
|
||||
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.png)"},
|
||||
SPAN("code: "+code),
|
||||
A({"href":"https://wiki.crans.org/VieCrans/ImpressionReseau", "class":"aide", "target":"_blank"}, "Comment récupérer mon impression ? ")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
Impression.popup.popupError = function(erreur) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Erreur",
|
||||
DIV({"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-warning.png)"},
|
||||
SPAN(erreur),
|
||||
A({"href":"#", "class":"aide", "target":"_blank"}, "Envoyer un rapport aux nounous"),
|
||||
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
Impression.popup.popupSolde = function(code) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Solde insuffisant",
|
||||
DIV(
|
||||
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-solde.png)"},
|
||||
SPAN("pas assez de sous"),
|
||||
A({"href":"https://wiki.crans.org/CransPratique/SoldeImpression", "class":"aide", "target":"_blank"}, "Comment recharger mon compte ? "),
|
||||
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
Impression.popup.popupCodes = function(codeList) {
|
||||
Popup.hide();
|
||||
Popup.create({}, "Codes de mes impressions",
|
||||
DIV(
|
||||
{"id":"printingPopupContent", "style":"background-image:url(/static/images/dialog-printer.png)"},
|
||||
SPAN("Mes codes"),
|
||||
//UL({"size":"4", "style":"width:6em;; height:4em;padding:0;margin:0;list-style-type:none;overflow:auto;"}, map(function (code) {return LI({}, code);}, codeList)),
|
||||
SELECT({"size":"4", "style":"width:100%;"}, map(function (code) {return LI({}, code);}, codeList)),
|
||||
Popup.closeLink({"class":"aide", "style":"text-align:right;"}, "Fermer")));
|
||||
Popup.display();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************
|
||||
Impression.mesCodes
|
||||
*****************************/
|
||||
Impression.mesCodes = {};
|
||||
Impression.mesCodes.getCodes = function ()
|
||||
{
|
||||
Impression.AJAX.call('codeList', this.displayCodes );
|
||||
}
|
||||
|
||||
Impression.mesCodes.displayCodes = function (result) {
|
||||
if (result.codes)
|
||||
Impression.popup.popupCodes(result.codes);
|
||||
else if (result.erreur)
|
||||
logError('erreur distante (codeLlist) : ' + result.erreur);
|
||||
else
|
||||
logError('erreur bizarre (codeLlist) : ');
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Impression.AJAX
|
||||
*****************************/
|
||||
Impression.AJAX = {};
|
||||
|
||||
|
||||
Impression.AJAX.modifPrix = function( text, wheel )
|
||||
{
|
||||
if (wheel)
|
||||
{
|
||||
var image = createDOM("IMG",{'src':'/static/images/indicator.gif'});
|
||||
}
|
||||
else
|
||||
{
|
||||
var image = new DIV({});
|
||||
}
|
||||
var item = new DIV({'onclick':'Impression.AJAX.recalcPrix();'}, image, text);
|
||||
replaceChildNodes("prix_placeholder",item);
|
||||
}
|
||||
|
||||
Impression.AJAX.modifNbPages = function( nbpages )
|
||||
{
|
||||
Impression.settings.nb_pages = nbpages;
|
||||
replaceChildNodes("fileNbPages",nbpages);
|
||||
}
|
||||
|
||||
Impression.AJAX.call = function(page, callBack) {
|
||||
logDebug("calling AJAX : " + page);
|
||||
var e = loadJSONDoc(page);
|
||||
e.addCallback(callBack);
|
||||
e.addErrback(this.errorHandler);
|
||||
}
|
||||
|
||||
Impression.AJAX.errorHandler = function(d) {
|
||||
//Impression.AJAX..modifPrix("Erreur", false);
|
||||
logError("AJAX Error: " + d);
|
||||
Impression.AJAX.modifPrix("Erreur...", false);
|
||||
}
|
||||
|
||||
|
||||
Impression.AJAX.usefile = function(filename) {
|
||||
var item = new DIV({}, "Calculs en cours...");
|
||||
this.modifPrix("Analyse du fichier...", true);
|
||||
this.call('useFile?fileName=' + filename,this.analysefini );
|
||||
}
|
||||
|
||||
Impression.AJAX.analysefini = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (usefile)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
Impression.settings.disableForm(true);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else {
|
||||
Impression.AJAX.modifPrix("Analyse terminée", true);
|
||||
Impression.settings.update();
|
||||
Impression.AJAX.modifNbPages(AJAXResp.nbPages);
|
||||
}
|
||||
}
|
||||
|
||||
Impression.AJAX.recalcPrix = function()
|
||||
{
|
||||
settings = Impression.settings;
|
||||
var url = "changeSettings?copies=" + settings.copies
|
||||
+"&couleurs="+ settings.type_impression
|
||||
+"&papier="+ settings.papier
|
||||
+"&recto_verso="+ settings.disposition
|
||||
+"&agrafes="+ settings.agrafes;
|
||||
this.modifPrix("Calcul en cours", true);
|
||||
this.call(url, this.changePrix);
|
||||
}
|
||||
|
||||
Impression.AJAX.changePrix = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (recalcPrix)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.AJAX.modifPrix(AJAXResp.erreur, false);
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
Impression.settings.disableForm(true);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else {
|
||||
Impression.AJAX.modifPrix("Coût : " + AJAXResp.nouvPrix + "€", false);
|
||||
}
|
||||
}
|
||||
|
||||
Impression.AJAX.lancerImpression = function(AJAXResp)
|
||||
{
|
||||
var url = "lancerImpression";
|
||||
Impression.settings.disableForm(true);
|
||||
this.call(url, this.finImpression);
|
||||
}
|
||||
|
||||
Impression.AJAX.finImpression = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (lancerImpression)');
|
||||
if (AJAXResp.erreur) {
|
||||
Impression.popup.popupError(AJAXResp.erreur);
|
||||
logWarning('Erreur distante : ' + AJAXResp.erreur);
|
||||
} else if (AJAXResp.SoldeInsuffisant) {
|
||||
Impression.popup.popupSolde();
|
||||
Impression.settings.disableForm(false);
|
||||
Impression.settings.update();
|
||||
} else {
|
||||
Impression.popup.popupImpression(AJAXResp.code);
|
||||
}
|
||||
}
|
||||
|
||||
Impression.AJAX.getPrinterState = function()
|
||||
{
|
||||
var url = "etatImprimante";
|
||||
Impression.AJAX.call(url, Impression.AJAX.displayPrinterState);
|
||||
}
|
||||
|
||||
Impression.AJAX.displayPrinterState = function(AJAXResp)
|
||||
{
|
||||
logDebug('AJAX terminated (getPrinterState)');
|
||||
if (AJAXResp.erreur) {
|
||||
logWarning('Erreur distante (etatImprimante) : ' + AJAXResp.erreur);
|
||||
} else {
|
||||
replaceChildNodes("etatImprimanteIci", AJAXResp.printer_state)
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(Impression.AJAX.getPrinterState, 30000);
|
||||
|
|
|
@ -57,9 +57,10 @@
|
|||
<li><span style="font-weight:bold;">pages: </span><span id="fileNbPages"></span></li>
|
||||
|
||||
#end if
|
||||
<li id="actionEtatImprimante"><span style="font-weight:bold;">État
|
||||
imprimante:</span><br /><span> $etatImprimante </span></li>
|
||||
<li id="actionEtatImprimante" onclick="Impression.AJAX.getPrinterState();"><span style="font-weight:bold;">État
|
||||
imprimante:</span><br /><span id="etatImprimanteIci"> $etatImprimante </span></li>
|
||||
<li id="actionNouvelleImpression"><a href="index">Nouvelle impression</a></li>
|
||||
<li id="actionMesCodes"><a href="#" onclick="Impression.mesCodes.getCodes(); return false;">Mes codes</a></li>
|
||||
|
||||
<!-- <li><a href="historique">Historique</a></li> -->
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue