@@ -25,6 +25,7 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
2525 {form_hidden_fields}
2626 < div class ="modal-body ">
2727
28+ < div class ="js-colissimo-field-status ">
2829 {form_field field="new_status"}
2930 < label >
3031 {intl d='colissimolabel.bo.default' l="Order status change after processing"}
@@ -48,14 +49,19 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
4849 </ label >
4950 </ div >
5051 {/form_field}
52+ </ div >
5153
5254 {loop type="colissimolabel.label-info" name="form-label-infos" order_id=$ID limit=1}
5355
5456 {form_field field="order_id" value_key=$ORDER_ID}
5557 < input type ="checkbox " name ="{$name} " value ="{$ORDER_ID} " checked hidden >
5658 {/form_field}
5759
58- < td class ="text-center ">
60+ {form_field field="return_label"}
61+ < input type ="hidden " name ="{$name} " id ="colissimo-return-label " value ="0 ">
62+ {/form_field}
63+
64+ < td class ="text-center js-colissimo-field-signed ">
5965 {form_field field="signed" value_key=$ORDER_ID}
6066 < div class ="checkbox ">
6167 < label for ="colissimolabel-input-signedDelivery ">
@@ -109,7 +115,10 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
109115 < table class = "table table-striped" id = "colissimo-label-table" data-url = "{url path=" / admin / module / ColissimoLabel / order / { $order_id } / ajax-get-labels "} ">
110116 < caption >
111117 { intl l = "Labels Colissimo" d = "colissimolabel.bo.default" }
112- < button class = "btn btn-primary pull-right" name = "target" data-toggle = "modal" data-target = "#modal-colissimo-label" >
118+ < button class = "btn btn-default pull-right" id = "colissimo-open-return" style = "margin-right:10px;" >
119+ { intl l = "Generate return label" d = "colissimolabel.bo.default" }
120+ </ button >
121+ < button class = "btn btn-primary pull-right" id = "colissimo-open-standard" name = "target" >
113122 { intl l = "Generate new label" d = "colissimolabel.bo.default" }
114123 </ button >
115124 </ caption >
@@ -150,6 +159,7 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
150159 $modalErrorAlert = $modalError . find ( '.alert' ) ,
151160 $modalInputWeight = $modal . find ( '#colissimo-input-weight' ) ,
152161 $modalInputSignedDelivery = $modal . find ( "input[name='signedDelivery']" ) ,
162+ $returnField = $modal . find ( '#colissimo-return-label' ) ,
153163 $table = $ ( '#colissimo-label-table' ) ;
154164
155165 function print ( url , number ) {
@@ -191,7 +201,19 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
191201 $modalFooter . removeClass ( 'hide' ) ;
192202 $modalLoader . addClass ( 'hide' ) ;
193203 $modalError . addClass ( 'hide' ) ;
194- $modalErrorAlert . html ( '' )
204+ $modalErrorAlert . html ( '' ) ;
205+
206+ if ( $returnField . val ( ) !== '1' ) {
207+ $returnField . val ( '0' ) ;
208+ }
209+
210+ if ( $returnField . val ( ) === '1' ) {
211+ $modal . find ( '.js-colissimo-field-status' ) . addClass ( 'hide' ) ;
212+ $modal . find ( '.js-colissimo-field-signed' ) . addClass ( 'hide' ) ;
213+ } else {
214+ $modal . find ( '.js-colissimo-field-status' ) . removeClass ( 'hide' ) ;
215+ $modal . find ( '.js-colissimo-field-signed' ) . removeClass ( 'hide' ) ;
216+ }
195217 } ) ;
196218
197219 $modal . on ( 'shown.bs.modal' , function ( event ) {
@@ -204,12 +226,31 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
204226 elem . value = val ;
205227 } ) ;
206228
207- // modal action print
229+ $modal . on ( 'hidden.bs.modal' , function ( ) {
230+ $returnField . val ( '0' ) ;
231+ $modal . find ( '.js-colissimo-field-status' ) . removeClass ( 'hide' ) ;
232+ $modal . find ( '.js-colissimo-field-signed' ) . removeClass ( 'hide' ) ;
233+ } ) ;
234+
208235 $table . on ( 'click' , '.js-action-print' , function ( e ) {
209236 e . preventDefault ( ) ;
210237 print ( $ ( this ) . attr ( 'href' ) , this . dataset . number ) ;
211238 } ) ;
212239
240+ $ ( '#colissimo-open-return' ) . on ( 'click' , function ( e ) {
241+ e . preventDefault ( ) ;
242+ $returnField . val ( '1' ) ;
243+ $modal . find ( 'input[name="new_status"][value="nochange"]' ) . prop ( 'checked' , true ) ;
244+ $modalInputSignedDelivery . prop ( 'checked' , false ) ;
245+ $modal . modal ( 'show' ) ;
246+ } ) ;
247+
248+ $ ( '#colissimo-open-standard' ) . on ( 'click' , function ( e ) {
249+ e . preventDefault ( ) ;
250+ $returnField . val ( '0' ) ;
251+ $modal . modal ( 'show' ) ;
252+ } ) ;
253+
213254 $modal . find ( 'form' ) . on ( 'submit' , function ( e ) {
214255 e . preventDefault ( ) ;
215256 $modalBody . addClass ( 'hide' ) ;
@@ -225,6 +266,7 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
225266
226267 request . done ( function ( json ) {
227268 $modalLoader . addClass ( 'hide' ) ;
269+ $returnField . val ( '0' ) ;
228270 if ( json . error ) {
229271 $modalErrorAlert . html ( Array . isArray ( json . error ) ? json . error [ 0 ] : json . error ) ;
230272
@@ -241,6 +283,7 @@ <h4 class="modal-title" id="exampleModalLabel">{intl l="Colissimo Labels" d="col
241283 request . fail ( function ( jqXHR , textStatus ) {
242284 console . log ( 'jsonfail' ) ;
243285 $modalLoader . addClass ( 'hide' ) ;
286+ $returnField . val ( '0' ) ;
244287 $modalError . removeClass ( 'hide' ) ;
245288 $modalErrorAlert . html ( textStatus ) ;
246289 } ) ;
0 commit comments