From d87c41e637ad0a2aacadf6f6927381d3ff4ee4f7 Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Sat, 16 May 2009 03:40:10 +0200 Subject: [PATCH] [intranet/impression, lib/impression_canon] modifications de l'AJAX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: 8beebdd91330205ba08932d269ccb6b * Ajout de l'option livret * agra{f,ph}es -> agrafage * paper -> papier * True & False au lieu d'utiliser des noms de constantes à rallonge darcs-hash:20090516014010-bd074-69a54cc50369c5351542a7b82ddf6b5215e421d1.gz --- intranet/modules/impression/main.py | 5 ++- .../modules/impression/static/impression.js | 39 +++++++++++-------- .../impression/templates/impression.tmpl | 26 ++++++------- lib/impression/impression_canon.py | 16 ++++++-- 4 files changed, 50 insertions(+), 36 deletions(-) diff --git a/intranet/modules/impression/main.py b/intranet/modules/impression/main.py index fda4bf93..94e751c5 100644 --- a/intranet/modules/impression/main.py +++ b/intranet/modules/impression/main.py @@ -172,11 +172,12 @@ class main(ModuleBase): # # methode pour changer les parametres # - def changeSettings(self, copies=None, couleurs=None, recto_verso=None, agrafes=None, papier=None): + def changeSettings(self, copies=None, couleur=None, recto_verso=None, agrafage=None, papier=None, livret=None): if not cherrypy.session.has_key('impression') or cherrypy.session['impression'] == None : return {'nouvPrix':0.0} try: - nouvPrix = cherrypy.session['impression'].changeSettings(papier=papier, couleurs=couleurs, agraphes=agrafes, recto_verso=recto_verso, copies=int(copies)) + nouvPrix = cherrypy.session['impression'].changeSettings(papier=papier, couleur=couleur, agrafage=agrafage, recto_verso=recto_verso, copies=int(copies), livret=livret) + crans.cp.log("changeSettings returns : %s" % str(nouvPrix)) except Exception, e: crans.cp.log("changeSettings : %s" % str(e), 'IMPRESSION', 1) return {"erreur":str(e)} diff --git a/intranet/modules/impression/static/impression.js b/intranet/modules/impression/static/impression.js index bf2d283c..72cd050e 100644 --- a/intranet/modules/impression/static/impression.js +++ b/intranet/modules/impression/static/impression.js @@ -129,6 +129,7 @@ Impression.settings.disableField = function(afield) { // Impression.settings.update = function () { var orientation = "portrait"; + Impression.settings.livret="False" if (this.theform.type_impression_couleur.checked) this.getValue(this.theform.type_impression_couleur); else @@ -139,22 +140,25 @@ Impression.settings.update = function () { else if (this.theform.disposition_recto_verso.checked) this.getValue(this.theform.disposition_recto_verso); else - this.getValue(this.theform.disposition_recto_verso_short); - this.getValue(this.theform.papier); + { + this.getValue(this.theform.disposition_livret); + Impression.settings.livret="True"; + } + this.getValue(this.theform.papier); this.getCopies(this.theform.nb_copies); - this.getValue(this.theform.agrafes); - // Contraintes + this.getValue(this.theform.agrafage); + // Contraintes if ( - ( this.papier != "A4" ) || - ( (this.disposition == "recto") && (this.nb_pages>50) ) || - ( (this.disposition == "rectoverso") && (this.nb_pages>100) ) || - ( (this.disposition == "rectoversoshort") && (this.nb_pages>100) )) + /* ( 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); + this.setValue(this.theform.agrafage, "None"); + this.disableField(this.theform.agrafage); + this.getValue(this.theform.agrafage); } else { - this.setDisableField(this.theform.agrafes, false); + this.setDisableField(this.theform.agrafage, false); } if (this.papier == "A4tr") { @@ -317,11 +321,12 @@ Impression.AJAX.analysefini = function(AJAXResp) 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; + var url = "changeSettings?copies=" + settings.copies + +"&couleur="+ settings.type_impression + +"&papier="+ settings.papier + +"&recto_verso="+ settings.disposition + +"&agrafage="+ settings.agrafage + +"&livret="+ settings.livret; this.modifPrix("Calcul en cours", true); this.call(url, this.changePrix); } diff --git a/intranet/modules/impression/templates/impression.tmpl b/intranet/modules/impression/templates/impression.tmpl index 4e986818..c9396a76 100644 --- a/intranet/modules/impression/templates/impression.tmpl +++ b/intranet/modules/impression/templates/impression.tmpl @@ -19,10 +19,10 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
Type d'impression -
@@ -31,15 +31,15 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
- - + #for type_agrafes in $crans.impression.impression_canon.DICT_AGRAFAGE.keys() + #end for
@@ -50,16 +50,16 @@ Crans.messages.setMessage('$errorMsg.replace("\'","\\\'")', 'errorMessage')
Disposition -
diff --git a/lib/impression/impression_canon.py b/lib/impression/impression_canon.py index 5fdbb01d..a9b7560a 100755 --- a/lib/impression/impression_canon.py +++ b/lib/impression/impression_canon.py @@ -183,6 +183,10 @@ class impression: couleur = kw.get('couleur', None) if couleur in [True, False]: self._settings['couleur'] = couleur + elif couleur == "True": + self._settings['couleur'] = True + elif couleur == "False": + self._settings['couleur'] = False try: if int(kw['copies']) >= 1: @@ -191,6 +195,8 @@ class impression: pass recto_verso = kw.get('recto_verso', None) + if recto_verso == "True": recto_verso = True + if recto_verso == "False": recto_verso = False if recto_verso in [True, False]: self._settings['recto_verso'] = recto_verso @@ -207,6 +213,8 @@ class impression: self._settings['agrafage'] = agrafage livret = kw.get('livret', None) + if livret == "True": livret = True + if livret == "False": livret = False if livret in [True, False]: self._settings['livret'] = livret self._settings['portrait'] = not(livret) @@ -330,9 +338,9 @@ class impression: c_impression = c_papier * pages + impression.c_face_nb * pages # Cout des agrafes - if self._settings['agrafe'] in ["Top", "Bottom", "Left", "Right"] or self._settings['livret']: + if self._settings['agrafage'] in ["Top", "Bottom", "Left", "Right"] or self._settings['livret']: nb_agrafes = 2 - elif self._settings['agrafe'] in ["None", None]: + elif self._settings['agrafage'] in ["None", None]: nb_agrafes = 0 else: nb_agrafes = 1 @@ -397,10 +405,10 @@ class impression: #Indique la présence d'un bac de sortie avec agrafeuse # options += " -o Option20=MBMStaplerStacker -o OutputBin=StackerDown" - if self._settings['paper'] == 'A4tr': + if self._settings['papier'] == 'A4tr': options += ' -o InputSlot=SideDeck -o MediaType=OHP' options += ' -o pdf-paper=571x817 -o PageSize=A4' - elif self._settings['paper'] == 'A4': + elif self._settings['papier'] == 'A4': options += ' -o pdf-paper=571x817 -o PageSize=A4' else: options += ' -o pdf-expand -o pdf-paper=825x1166 -o PageSize=A3'