PageSourceSearch

https://boutique.ngpresse.fr/core/aboshop/app.controller.js?v=

js ngpresse.fr collected 2026-10-08 07:09:42 UTC 132,842 bytes, 3,649 lines download raw bytes

1/**
2 * Created by florent on 15/10/15.
3 */
4
5var AboShopApp = angular.module('AboShopApp')
6	.filter('iif', function () {
7	   return function(input, trueValue, falseValue) {
8	        return input ? trueValue : falseValue;
9	   };
10	})
11    .filter('to_trusted', ['$sce', function($sce){
12        return function(text) {
13        	if(text !== undefined){
14            	return $sce.trustAsHtml(text);
15        	}
16        	return "";
17        };
18    }])
19    .filter('cut', function () {
20        return function (value, wordwise, max, tail) {
21            if (!value) return '';
22
23            max = parseInt(max, 10);
24            if (!max) return value;
25            if (value.length <= max) return value;
26
27            value = value.substr(0, max);
28            if (wordwise) {
29                var lastspace = value.lastIndexOf(' ');
30                if (lastspace != -1) {
31                  //Also remove . and , so its gives a cleaner result.
32                  if (value.charAt(lastspace-1) == '.' || value.charAt(lastspace-1) == ',') {
33                    lastspace = lastspace - 1;
34                  }
35                  value = value.substr(0, lastspace);
36                }
37            }
38
39            return value + (tail || ' ...');
40        };
41    })
42
43    // APPEL MANUEL SUR JSON -> A REMPLACER PAR DES APPELS API
44    .factory('contacts', ['$http', function ($http, utils) {
45        var path = '../apiserver/contacts.json';
46        var contacts = $http.get(path).then(function (resp) {
47            return resp.data.contacts;
48        });
49
50        var factory = {};
51        factory.all = function () {
52            return contacts;
53        };
54        factory.get = function (id) {
55            return contacts.then(function(){
56                return utils.findById(contacts, id);
57            });
58        };
59        return factory;
60    }])
61
62
63    // UTILITAIRES POUR MANIPULER DES TABLEAUX JSON (sur le scope)
64    .factory('utils', function () {
65        return {
66
67            // Util for finding an object by its 'id' property among an array
68            copieTableau: function copieTableau(arr1, arr2, clear) {
69            	if(clear){
70            		while (arr1.length) {
71				    	arr1.pop();
72				    }
73            	}
74                for (var i = 0; i < arr2.length; i++) {
75                    arr1.push(arr2[i]);
76                }
77            },
78
79            // Util for finding an object by its 'id' property among an array
80            findById: function findById(a, id, prop) {
81            	if(prop === undefined){
82            		prop = "id";
83            	}
84                for (var i = 0; i < a.length; i++) {
85                    if (a && a !== undefined && a[i] && a[i] !== undefined && a[i][prop] == id) return a[i];
86                }
87                return null;
88            },
89
90            // Util for returning a randomKey from a collection that also isn't the current key
91            newRandomKey: function newRandomKey(coll, key, currentKey){
92                var randKey;
93                do {
94                    randKey = coll[Math.floor(coll.length * Math.random())][key];
95                } while (randKey == currentKey);
96                return randKey;
97            },
98
99            // Util for returning object contains in array by property value
100            contains: function contains(arr, property, val){
101
102				 var matches = _.filter(arr, function(obj){
103				 	var objChild = obj;
104				 	var arrProperty = property.split(".");
105				 	while(arrProperty.length && (objChild = objChild[arrProperty.shift()]));
106				    if (objChild == val){
107				      return obj;
108				    }
109				 });
110				 return matches;
111			}
112
113        };
114    })
115
116    .controller('logoutCtrl', function($rootScope,$scope,$localStorage,$location,Auth, TbsWS ) {
117    	$rootScope.doLogout();
118	})
119
120	.controller('productsCtrl', function( $rootScope, $scope, TbsWS, googleTagManager) {
121		$rootScope.tryInitPage($scope).then(
122			function(data){
123				TbsWS.canAccess().then(
124					function(){
125						googleTagManager.pageCategory = 'list';
126					}
127					,function(error) {
128		        	  $rootScope.goPage(undefined,'common/login');
129					}
130			    );
131				$rootScope.tryEndPage();
132		   },function(error) {
133	              console.error("Initialisation impossible");
134	        }
135		);
136	})
137
138	.controller('searchCtrl', function( $rootScope, $scope, TbsWS, googleTagManager) {
139		$rootScope.tryInitPage($scope).then(
140			function(data){
141				TbsWS.canAccess().then(
142					function(){
143						googleTagManager.pageCategory = 'list';
144					}
145					,function(error) {
146		        	  $rootScope.goPage(undefined,'common/login');
147					}
148			    );
149				$rootScope.tryEndPage();
150		   },function(error) {
151	              console.error("Initialisation impossible");
152	        }
153		);
154	})
155
156	.controller('contactCtrl', function( $rootScope, $scope, contactManager, $timeout, formulaireManager, TbsWS ) {
157		$rootScope.tryInitPage($scope).then(
158			function(data){
159				TbsWS.canAccess().then(
160					function(){
161						$scope.contactEmails = [];
162						$scope.addressCompany = "";
163
164						$scope.contactForm=contactManager.getContactFormInit();
165
166						$rootScope.$watch('preferredLanguage',function(){
167							contactManager.getAddressCompany().then(function(address){
168								$scope.addressCompany = address;
169							});
170						});
171
172						contactManager.getHasMailContact().then(function(hasMail){
173							if(hasMail == "true"){
174								contactManager.getContactForm($scope.contactForm);
175							}
176						});
177
178						contactManager.getContactMails().then(function(contactEmails){
179							$scope.contactEmails = contactEmails;
180						});
181
182						$scope.sendmessage = function(contactForm){
183							$rootScope.spinnerShow();
184							contactManager.sendMessage(contactForm).then(
185								function(status){
186									$rootScope.spinnerHide();
187								}
188							);
189						};
190					}
191					,function(error) {
192		        	  $rootScope.goPage(undefined,'common/login');
193					}
194			    );
195				$rootScope.tryEndPage();
196
197		   },function(error) {
198	              console.error("Initialisation impossible");
199	        }
200		);
201	})
202
203	.controller('trylogCtrl', function( $scope, $rootScope, $location, customerManager, $filter, TbsWS, $timeout, Auth, formulaireManager) {
204		$rootScope.tryInitPage($scope).then(
205			function(data){
206
207				function signinHeader(formCode){
208		        	$rootScope.signin.inProgress = true;
209		        	delete $rootScope.signin.mail;
210	            	delete $rootScope.signin.civilite;
211	            	delete $rootScope.signin.prenom;
212	            	delete $rootScope.signin.nom;
213
214		        	if(!customerManager.checkSigninFunction(formCode)){
215		        		formulaireManager.resetForm(formCode);
216		        		$rootScope.goPage(undefined,'common/login');
217		        	} else {
218		        		customerManager.signinFunction(formCode).then(function(success){
219		        			formulaireManager.resetForm(formCode);
220		        			if(!success){
221		        				$rootScope.goPage(undefined,'common/login');
222		        			} else  if(success.startsWith(customerManager.LOGIN)) {
223		        				if(success.startsWith(customerManager.LOGIN_OK)){
224					        		$rootScope.signin.resetInProgress();
225		        					if ($location.path() == '/common/logout'){
226					        			$rootScope.goPage(undefined);
227					        		} else if ($location.path() == '/common/login'){
228					        			if($rootScope.signin.fromBasket){
229					        				cartManager.setStartTunnelAchat(false);
230					        				if(commonConfig.forceRedirectToHomeAfterConnexion) {
231					        					$rootScope.goPage();
232					        				} else {
233					        					$rootScope.goPage(undefined,'common/delivery');
234					        				}
235					        			} else {
236					        				if(commonConfig.forceRedirectToHomeAfterConnexion) {
237					        					$rootScope.goPage();
238					        				} else {
239					        					$rootScope.goPage(undefined,'common/profil/init');
240					        				}
241					        			}
242					        		} else if(commonConfig.forceRedirectToHomeAfterConnexion) {
243			        					$rootScope.goPage();
244			        				}
245		        				} else {
246	    							customerManager.routingSpecific(success);
247	    						}
248		        			} else {
249			        			$rootScope.goPage(undefined,'common/login');
250			        		}
251			        	},function(error){
252			        		console.error(JSON.stringify(error));
253					        $rootScope.goPage(undefined,'common/login');
254			        	});
255		        	}
256		        };
257
258				$timeout(function() {
259					$scope.status = 'inprogress';
260					var path = $location.path();
261					var password = path.substr(path.lastIndexOf('/') + 1);
262					path = path.substr(0,path.lastIndexOf('/'));
263					var email = path.substr(path.lastIndexOf('/') + 1);
264					var emailDecrypt = Auth.decrypt(email);
265					var passwordDecrypt = Auth.decrypt(password);
266
267					var formCode = customerManager.getExistUserForm(false);
268
269					var ob = _.findWhere(formCode.fields, {name: "email"});
270					ob.value = emailDecrypt;
271					ob = _.findWhere(formCode.fields, {name: "password"});
272					ob.value = passwordDecrypt;
273
274					signinHeader(formCode);
275					$rootScope.tryEndPage();
276				},1000);
277
278		   },function(error) {
279	              console.error("Initialisation impossible");
280	        }
281		);
282	})
283
284	.controller('validateAccountCtrl', function( $scope, $rootScope, $location, customerManager, $filter, TbsWS, $timeout, cartManager, commonConfig, $stateParams, Auth) {
285		$rootScope.tryInitPage($scope).then(
286			function(data){
287				$scope.status = 'inprogress';
288				codeClient = $stateParams.CODE_CLIENT;
289
290				var path = $location.path(),
291				idactivation = path.substr(path.lastIndexOf('/') + 1);
292				if(codeClient === undefined || codeClient == ''){
293					$scope.status = 'noactivation';
294				} else {
295					customerManager.validateAccount(codeClient).then(
296						function(status){
297							$scope.status = status;
298							if($scope.status == "autoconnexion"){
299			          			let route = 'common/login';
300								if(Auth.isClientConnecte()){
301									route = 'common/profil/init';
302								}
303								$timeout(function() {
304								  $rootScope.goPage(undefined,route);
305								}, commonConfig.redirectDelayAfterAccountActivation*1000);
306							}
307						}
308					);
309				}
310				TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
311		       .then(function(dico){
312					$scope.gohome = dico["404"]["gohome"];
313		        });
314				$rootScope.tryEndPage();
315		   },function(error) {
316	              console.error("Initialisation impossible");
317	        }
318		);
319	})
320
321	.controller('activateCustomerCtrl', function( $scope, $rootScope, $location, customerManager, $filter, TbsWS, $timeout, cartManager, commonConfig) {
322		$rootScope.tryInitPage($scope).then(
323			function(data){
324				$scope.status = 'inprogress';
325				var path = $location.path(),
326				idactivation = path.substr(path.lastIndexOf('/') + 1);
327				if(idactivation == 'activate' || idactivation == ''){
328					$scope.status = 'noactivation';
329				} else {
330					customerManager.validateCustomer(idactivation).then(
331						function(status){
332							$scope.status = status;
333							if($scope.status == "autoconnexion"){
334								cartManager.loadCartWaiting().then(
335					          		function(status){
336					          			var route = 'common/profil/init';
337					          			if(cartManager.model.cart.lignes.length > 0){
338					          				route = 'common/delivery';
339					          			}
340
341										$timeout(function() {
342										  $rootScope.goPage(undefined,route);
343										}, commonConfig.redirectDelayAfterAccountActivation*1000);
344					          		}
345					          	);
346							}
347						}
348					);
349				}
350				TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
351		       .then(function(dico){
352					$scope.gohome = dico["404"]["gohome"];
353		        });
354				$rootScope.tryEndPage();
355		   },function(error) {
356	              console.error("Initialisation impossible");
357	        }
358		);
359	})
360
361	.controller('activatenewsletterCtrl', function( $scope, $rootScope, $location, customerManager, $filter, TbsWS ) {
362		$rootScope.tryInitPage($scope).then(
363			function(data){
364				$scope.status = 'inprogress';
365				var path = $location.path(),
366				idactivation = path.substr(path.lastIndexOf('/') + 1);
367
368				if(idactivation == 'activatenewsletter' || idactivation == ''){
369					$scope.status = 'noactivation';
370				} else {
371					customerManager.validateNewsletter(idactivation).then(
372						function(status){
373							$scope.status = status;
374						}
375					);
376				}
377				TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
378		       .then(function(dico){
379					$scope.gohome = dico["404"]["gohome"];
380		        });
381				$rootScope.tryEndPage();
382		   },function(error) {
383	              console.error("Initialisation impossible");
384	        }
385		);
386	})
387
388	.controller('cmsCtrl', function( $scope, $rootScope, $location, TbsWS, $filter, $stateParams, $state, cmsManager) {
389		$rootScope.tryInitPage($scope).then(
390			function(data){
391				TbsWS.canAccess().then(
392					function(){
393						let idpage = $stateParams.ID_PAGE;
394
395		          		$scope.titrePage = "";
396			          	$scope.contentPage = "";
397						loadPage();
398						$rootScope.$watch('preferredLanguage',function(){
399							loadPage();
400						});
401
402						function loadPage(){
403							TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/' +idpage,'public').then(
404								function(cms){
405									if(cms && cms !== ""){
406										$scope.titrePage = cms.titrePage;
407										$scope.contentPage = cms.contentPage;
408										if($state.current.data.seoMap === undefined){
409											$state.current.data.seoMap = [];
410										}
411										if(cms.seo !== undefined && cms.seo !== null &&
412											(cms.seo.urlRewrite === undefined || cms.seo.urlRewrite === null || cms.seo.urlRewrite === "")) {
413											let ob = cmsManager.getHrefCms(cms);
414											cms.seo.urlRewrite = ob.url;
415										}
416										if (cms.seo !== undefined && cms.seo !== null && cms.seo.urlRewrite !== undefined
417											&& cms.seo.urlRewrite !== null && cms.seo.urlRewrite !== "") {
418											if (cms.seo.urlRewrite.startsWith('/') === false) {
419												cms.seo.urlRewrite = '/' + cms.seo.urlRewrite;
420											}
421										}
422										$state.current.data.seoMap.push(cms.seo);
423									} else {
424										$scope.titrePage = $filter('translate')("Unvailable content");
425									}
426								}
427								,function(error) {
428									console.error(error);
429								}
430							);
431						}
432					}
433					,function(error) {
434		        	  $rootScope.goPage(undefined,'common/login');
435					}
436			    );
437				$rootScope.tryEndPage();
438		   },function(error) {
439	              console.error("Initialisation impossible");
440	        }
441		);
442	})
443
444	.controller('productarticleCtrl', function($rootScope,$scope,$localStorage,$location,TbsWS,productsManager,customerManager,commonConfig,wishlistManager,categoriesManager, $timeout,$stateParams, googleTagManager, pianoManager) {
445		$rootScope.tryInitPage($scope).then(
446			function(data){
447				TbsWS.canAccess().then(
448					function(){
449						googleTagManager.pageCategory = 'product';
450
451						var path = $location.path(),
452							idproduct = undefined,
453							fakeProduct={},
454							pays = [],
455							zones = [],
456							modifQteEnCours=false,
457							loadInProgress=true;
458
459						idproduct = $stateParams.ID_PRODUCT;
460
461						$scope.productline = commonConfig.productline;
462						$scope.btnCartOnly = commonConfig.btnCartOnly;
463						$scope.hideWishList = commonConfig.hideWishList;
464
465						if($rootScope.categoryBreadcrumb !== undefined){
466							$scope.categoryBreadcrumb=$rootScope.categoryBreadcrumb;
467							delete $rootScope.categoryBreadcrumb;
468
469							if ($scope.categoryBreadcrumb.parent != null) {
470								categoriesManager.getCategory($scope.categoryBreadcrumb.parent).then(
471									function(category){
472										$scope.categoryParent = category;
473									}
474								)
475							}
476						}
477
478			            $rootScope.$watch('user',function(){
479			            	if(loadInProgress == false){
480			            		_reloadProduct();
481			            	}
482			            });
483
484			            $rootScope.$watch('preferredLanguage',function(){
485			            	if(loadInProgress == false){
486				            	_reloadProduct();
487				            }
488			            });
489
490						$scope.sharedurl = "img/icon-share.png?v="+commonConfig.forceversion;
491
492				        $scope.quantite = {};
493				        $scope.quantite.min = 0;
494				        $scope.quantite.max = 0;
495
496				        $scope.addQte = function(type, value) {
497				        	if(!modifQteEnCours){
498				        		modifQteEnCours=true;
499				        		$scope.subscriptionForm.quantity.value = parseInt($scope.subscriptionForm.quantity.value)+parseInt(value);
500				        	}
501				        };
502
503				        $scope.loadDeclinaison = function loadDeclinaison(type, value){
504				        	if(value !== undefined){
505								$rootScope.spinnerShow();
506								fakeProduct.refProduit = $scope.product.refProduit;
507
508								fakeProduct.typeParameter = type;
509								fakeProduct.valueParameter = value;
510
511								productsManager.loadProduct(fakeProduct,$scope.criteres).then(
512									function(product){
513					          			$scope.product = product;
514					          			$scope.notearrondi = Math.round(parseFloat(product.note.replace(',', '.'))*2)/2;
515					          			$scope.quantite.min = product.quantiteMin;
516			        					$scope.quantite.max = product.quantiteMax;
517
518										// piano tracking
519										pianoManager.clickProductDeclinaison(product);
520
521										$rootScope.spinnerHide().then(
522					    					function(){
523					    						$scope.subscriptionForm = productsManager.getSubscriptionForm($scope.product,pays,zones);
524												modifQteEnCours = false;
525					    					}
526				    					);
527									}
528								);
529							}
530				        };
531
532				        $scope.commentForm = customerManager.getCommentForm(
532);
533				        $scope.noteForm = customerManager.getNoteForm();
534
535				        $scope.$watch("subscriptionForm.quantity.value",function(newval, oldval,scope){
536				        	var n = ~~Number(newval);
537				        	if(!String(n) === newval ||
538				        	  (n < scope.quantite.min || n > scope.quantite.max)){
539				        		//restore value
540				        		if($scope.subscriptionForm.quantity !== undefined){
541				        			$scope.subscriptionForm.quantity.value = parseInt(oldval);
542				        		}
543				        	} else if($scope.criteres !== undefined && $scope.criteres[productsManager.PARAMETER_QUANTITY] !== undefined && newval != $scope.criteres[productsManager.PARAMETER_QUANTITY]){
544				        		$scope.criteres[productsManager.PARAMETER_QUANTITY] = parseInt(newval);
545				        		$scope.loadDeclinaison(productsManager.PARAMETER_QUANTITY,$scope.criteres[productsManager.PARAMETER_QUANTITY]);
546				        	}
547				        }, true);
548
549				        $scope.product = null;
550				        function _reloadProduct(){
551				        	fakeProduct.refProduit = idproduct;
552
553							productsManager.loadProduct(fakeProduct).then(
554								function(product){
555									productsManager.initConstant($scope);
556				          			$scope.product = product;
557
558									// piano tracking
559									pianoManager.addCoreProperty('page', product.libelle);
560									if (product.codeSelection.categories) {
561										pianoManager.addCoreProperty('page_chapter1', product.codeSelection.categories[0].value);
562									}
563
564									$timeout(function() {
565										$(".carousel").carousel({
566											interval : parseInt(commonConfig.slidetransition)*1000
567										});
568									});
569
570									$scope.share = {
571						              url: path,
572						              name: $scope.product.libelle,
573						              image: $scope.product.images[0]
574						          	};
575
576				          			$scope.notearrondi = Math.round(parseFloat(product.note.replace(',', '.'))*2)/2;
577				          			$scope.quantite.min = product.quantiteMin;
578		        					$scope.quantite.max = product.quantiteMax;
579
580				        			$scope.criteres = productsManager.getCriteras(product);
581
582						          	$scope.subscriptionForm = productsManager.getSubscriptionForm($scope.product,[]);
583						          	if(product.produitsLies !== undefined && product.produitsLies.length > 0){
584						          		$scope.linkproducts = product.produitsLies;
585						          	} else {
586							          	productsManager.getRelatedProducts(product,4).then(
587							          		function(relatedProducts){
588							          			$scope.linkproducts = relatedProducts;
589							          	});
590						          	}
591						          	if(product.categoriesLies !== undefined && product.categoriesLies.length > 0){
592						          		$scope.linkcategories = product.categoriesLies;
593						          	}
594						          	loadInProgress=false;
595								}
596							);
597					    }
598
599					    $scope.wishlistForm = wishlistManager.getWishlistForm();
600					    $scope.addToWishlist = function addToWishlist(wishlistForm, product, $event){
601					    	$($event.currentTarget).prop('checked', !$($event.currentTarget).is(":checked"));
602					    	wishlistManager.addToWishlist(wishlistForm, product).then(function(status){
603					    		if(status){
604					    			$($event.currentTarget).prop('checked', true);
605					    		} else {
606					    			$($event.currentTarget).prop('checked', false);
607					    		}
608					    	});
609					    };
610
611					    $scope.sendComment = function sendComment(commentForm){
612					    	customerManager.createComment(commentForm, $scope.product).then(
613					    		function(status){
614					    			if(status){
615		            					$('#commentModal').modal('show');
616					    			}
617					    		}
618					    	);
619					    };
620
621					    _reloadProduct();
622					}
623					,function(error) {
624					  $rootScope.goPage(undefined,'common/login');
625					}
626				);
627				$rootScope.tryEndPage();
628		   },function(error) {
629	              console.error("Initialisation impossible");
630	        }
631		);
632
633
634	})
635
636	.controller('productsubscriptionCtrl', function($rootScope,$scope,$localStorage,$location,TbsWS,productsManager,customerManager,commonConfig,wishlistManager,$timeout,cartManager,$stateParams, atInternetManager, googleTagManager, pianoManager, $filter) {
637		$rootScope.tryInitPage($scope).then(
638			function(data){
639				TbsWS.canAccess().then(
640					function(){
641						googleTagManager.pageCategory = 'product';
642
643						var path = $location.path(),
644							res = path.split('/'),
645							idproduct = undefined,
646							refAboEchu = undefined,
647							fakeProduct={},
648							pays = [],
649							zones = [],
650							modifQteEnCours=false,
651							loadInProgress=true;
652
653						idproduct = $stateParams.ID_PRODUCT;
654						refAboEchu = $stateParams.REF_ABO_ECHU;
655
656				        $scope.productline = commonConfig.productline;
657						$scope.btnCartOnly = commonConfig.btnCartOnly;
658						$scope.hideProductSubscriptionFormNumber = commonConfig.hideProductSubscriptionFormNumber;
659						$scope.hideWishList = commonConfig.hideWishList;
660						$scope.displayDescriptionCourteOnProductPage = commonConfig.displayDescriptionCourteOnProductPage;
661
662						if($rootScope.categoryBreadcrumb !== undefined){
663							$scope.categoryBreadcrumb=$rootScope.categoryBreadcrumb;
664							delete $rootScope.categoryBreadcrumb;
665						}
666
667			            $rootScope.$watch('user',function(){
668			            	if(loadInProgress == false){
669			            		_reloadProduct();
670			            	}
671			            });
672
673			            $rootScope.$watch('preferredLanguage',function(){
674			            	if(loadInProgress == false){
675				            	_reloadProduct();
676				            }
677			            });
678
679						$scope.sharedurl = "img/icon-share.png?v="+commonConfig.forceversion;
680
681				        $scope.quantite = {};
682				        $scope.quantite.min = 0;
683				        $scope.quantite.max = 0;
684
685				        $scope.addQte = function(type, value) {
686				        	if(!modifQteEnCours){
687				        		modifQteEnCours=true;
688				        		$scope.subscriptionForm.quantity.value = parseInt($scope.subscriptionForm.quantity.value)+parseInt(value);
689				        	}
690				        };
691
692				        $scope.loadDeclinaison = function loadDeclinaison(type, value){
693				        	if(value !== undefined && (productsManager.PARAMETER_QUANTITY == type || $scope.criteres[type] != value)){
694
695								$rootScope.spinnerShow();
696								fakeProduct.refProduit = $scope.product.refProduit;
697
698								fakeProduct.typeParameter = type;
699								fakeProduct.valueParameter = value;
700
701								productsManager.loadProduct(fakeProduct,$scope.criteres).then(
702									function(product){
703							  			$scope.product = product;
704					          			$scope.notearrondi = Math.round(parseFloat(product.note.replace(',', '.'))*2)/2;
705					          			$scope.quantite.min = product.quantiteMin;
706			        					$scope.quantite.max = product.quantiteMax;
707
708										// piano tracking
709										pianoManager.clickProductDeclinaison(product);
710
711										valideProduitReabonnement($scope.subscription, product);
712
713										$rootScope.spinnerHide().then(
714					    					function(){
715					        					$scope.criteres = productsManager.getCriteras($scope.product,pays,zones);
716					        					$scope.subscriptionForm = productsManager.getSubscriptionForm($scope.product,pays,zones);
717												$scope.hideProductSubscriptionFormNumber = $scope.hideProductSubscriptionFormNumber || $scope.subscriptionForm.hideProductSubscriptionFormNumber;
718						          				modifQteEnCours = false;
719					    					}
720				    					);
721									}
722								);
723							}
724				        };
725
726				        $scope.commentForm = customerManager.getCommentForm(
726);
727				        $scope.noteForm = customerManager.getNoteForm();
728
729				        $scope.$watch("subscriptionForm.quantity.value",function(newval, oldval,scope){
730				        	var n = ~~Number(newval);
731				        	if(!String(n) === newval ||
732				        	  (n < scope.quantite.min || n > scope.quantite.max)){
733				        		//restore value
734				        		if($scope.subscriptionForm.quantity !== undefined){
735				        			$scope.subscriptionForm.quantity.value = parseInt(oldval);
736				        		}
737				        	} else if($scope.criteres !== undefined && $scope.criteres[productsManager.PARAMETER_QUANTITY] !== undefined && newval != $scope.criteres[productsManager.PARAMETER_QUANTITY]){
738				        		//load new value
739				        		$scope.criteres[productsManager.PARAMETER_QUANTITY] = parseInt(newval);
740				        		$scope.loadDeclinaison(productsManager.PARAMETER_QUANTITY,$scope.criteres[productsManager.PARAMETER_QUANTITY]);
741				        	}
742				        }, true);
743
744				        $scope.product = null;
745				        function _reloadProduct(){
746				        	fakeProduct.refProduit = idproduct;
747				        	var productLoad=false,
748				        		paysLoad=false,
749				        		zonesLoad=false;
750
751							productsManager.loadProduct(fakeProduct).then(
752								function(product){
753									productsManager.initConstant($scope);
754				          			$scope.product = product;
755
756									// piano tracking
757									pianoManager.addCoreProperty('page', product.libelle);
758									if (product.codeSelection.categories) {
759										pianoManager.addCoreProperty('page_chapter1', product.codeSelection.categories[0].value);
760									}
761
762									$timeout(function() {
763										$(".carousel").carousel({
764											interval : parseInt(commonConfig.slidetransition)*1000
765										});
766									});
767
768									if (product.images !== undefined && product.images.length > 0) {
769										$scope.share = {
770											url: path,
771											name: $scope.product.libelle,
772											image: $scope.product.images[0]
773										};
774									}
775
776				          			$scope.notearrondi = Math.round(parseFloat(product.note.replace(',', '.'))*2)/2;
777				          			$scope.quantite.min = product.quantiteMin;
778		        					$scope.quantite.max = product.quantiteMax;
779
780				          			productLoad=true;
781
782				          			commonConfig.useZones=true;
783				          			if(commonConfig.useZones){
784							          	TbsWS.getZones(product.zonesLivraison).then(
785									          function(listzones){
786									          	zones = listzones;
787									          	zonesLoad=true;
788									          	_tryEndLoad();
789									          }
790									          ,function(error) {
791									          	console.error(error);
792									        }
793										);
794									} else {
795							          	TbsWS.getCountriesByDeliveryZone(product.zonesLivraison).then(
796									          function(listpays){
797									          	pays = listpays;
798									          	paysLoad=true;
799									          	_tryEndLoad();
800									          }
801									          ,function(error) {
802									          	console.error(error);
803									        }
804										);
805									}
806
807									if(refAboEchu !== undefined) {
808										$scope.produitReabonnementValide = false;
809										customerManager.getSubscription(refAboEchu).then(
810											function(subscription) {
811												$scope.subscription = subscription;
812												valideProduitReabonnement(subscription, product);
813											}
814										);
815									} else {
816										$scope.produitReabonnementValide = true;
817
818										if(product.produitsLies !== undefined && product.produitsLies.length > 0){
819											$scope.linkproducts = product.produitsLies;
820										} else {
821											productsManager.getRelatedProducts(product,4).then(
822												function(relatedProducts){
823													$scope.linkproducts = relatedProducts;
824												});
825										}
826
827										if(product.categoriesLies !== undefined && product.categoriesLies.length > 0){
828											$scope.linkcategories = product.categoriesLies;
829										}
830									}
831								}
832							);
833
834							function _tryEndLoad(){
835								if(productLoad && (paysLoad||zonesLoad)){
836
837		        					$scope.criteres = productsManager.getCriteras($scope.product,pays,zones);
838									$scope.subscriptionForm = productsManager.getSubscriptionForm($scope.product,pays,zones);
839									$scope.hideProductSubscriptionFormNumber = $scope.hideProductSubscriptionFormNumber || $scope.subscriptionForm.hideProductSubscriptionFormNumber;
840									loadInProgress = false;
841								}
842							}
843					    }
844
845						function valideProduitReabonnement(subscription, product) {
846							if(subscription != null && product != null){
847								$scope.produitReabonnementValide = false;
848								if(subscription.produitsReabonnements != null) {
849									for(let i = 0; i < subscription.produitsReabonnements.length; i++) {
850										let productReab = subscription.produitsReabonnements[i];
851										if(productReab.refProduit === product.refProduit) {
852											$scope.product.refAboEchu = subscription.refAbonnement;
853											$scope.produitReabonnementValide = true;
854											$scope.product.codeClientLiv = subscription.codeClient;
855											break;
856										}
857									}
858								}
859							}
860						}
861
862					    $scope.wishlistForm = wishlistManager.getWishlistForm();
863					    $scope.addToWishlist = function addToWishlist(wishlistForm, product, $event){
864					    	$($event.currentTarget).prop('checked', !$($event.currentTarget).is(":checked"));
865					    	wishlistManager.addToWishlist(wishlistForm, product).then(function(status){
866					    		if(status){
867					    			$($event.currentTarget).prop('checked', true);
868					    		} else {
869					    			$($event.currentTarget).prop('checked', false);
870					    		}
871					    	});
872					    };
873
874					    $scope.setNote = function setNote(newNote){
875					    	$scope.notearrondi = newNote;
876					    	_reloadProduct();
877					    	customerManager.setNewNote(newNote,$scope.product).then(
878					    		function(status){
879					    			if(status){
880					    				_reloadProduct();
881		            					$('#commentModal').modal('show');
882					    			}
883
884					    		}
885					    	);
886					    };
887
888					    $scope.sendComment = function sendComment(commentForm){
889					    	customerManager.createComment(commentForm, $scope.product).then(
890					    		function(status){
891					    			if(status){
892		            					$('#commentModal').modal('show');
893					    			}
894					    		}
895					    	);
896					    };
897
898					    $scope.addToCartEventSubscription = function addToCartEventSubscription($event, product, quantite, subscriptionForm){
899							var ctaName = product.affLibAcheter ? product.libAcheter : $filter('translate')(product.dicoShopNow);
900							$rootScope.gtmClickCta(ctaName, 'product');
901
902							// piano tracking
903							pianoManager.sendEvent('click.action', {
904								click: product.affLibAcheter ? product.libAcheter : $filter('translate')(product.dicoShopNow),
905								click_chapter1: product.libelle,
906								click_chapter2: product.tarif.codeDureeAbonnement ? product.tarif.codeDureeAbonnement.value : null,
907								click_chapter3: product.tarif.zoneLivraison ? product.tarif.zoneLivraison.libZonePort : null
908							});
909
910							if(product.tarif.montantLibre){
911					    		$event.stopPropagation();
912					    		cartManager.sendMontantLibre(product, quantite, subscriptionForm);
913					    	} else {
914					    		$rootScope.addToCartEvent($event, product, quantite);
915					    	}
916					    };
917
918					    _reloadProduct();
919					}
920					,function(error) {
921					  $rootScope.goPage(undefined,'common/login');
922					}
923				);
924				$rootScope.tryEndPage();
925		   },function(error) {
926	              console.error("Initialisation impossible");
927	        }
928		);
929
930
931	})
932
933	.controller('productlistsubscriptionCtrl', function($rootScope,$scope,$location,$filter,commonConfig,customerManager, TbsWS, pianoManager) {
934		$rootScope.tryInitPage($scope).then(
935			function(data){
936				TbsWS.canAccess().then(
937					function(){
938						// piano tracking
939						pianoManager.addCoreProperty('page', $filter('translate')('DICO_REABONNER_LISTE_PRODUITS'));
940						pianoManager.addCoreProperty('page_chapter1', $filter('translate')('DICO_REABONNER_LISTE_PRODUITS'));
941
942						var path = $location.path(), res = path.split('/'),
943						refAboEchu = res[3];
944
945						$scope.productline = commonConfig.productline;
946			            $scope.classline = "col-md-3";
947			            if(commonConfig.nbproductsbyline == 3){
948			            	$scope.classline = "col-sm-4 ";
949			            }
950
951			            $scope.loaddataended = false;
952			            var reloadInProgress = false;
953
954						if(refAboEchu != null) {
955							customerManager.getSubscription(refAboEchu).then(
956								function(subscription) {
957									$scope.refAboEchu = subscription.refAbonnement;
958									$scope.products = subscription.produitsReabonnements;
959									for(let i = 0; i < $scope.products.length; i++) {
960										let product = $scope.products[i];
961										product.refAboEchu = subscription.refAbonnement;
962										product.codeClientLiv = subscription.codeClient;
963									}
964									$scope.loaddataended = true;
965								}
966							);
967						}
968					}
969					,function(error) {
970					  $rootScope.goPage(undefined,'common/login');
971					}
972				);
973
974				$rootScope.tryEndPage();
975			},
976			function(error) {
977				console.error('Initialisation impossible');
978			}
979		);
980	})
981
982	.controller('productdonationCtrl', function($rootScope,$scope,$location,productsManager,cartManager, TbsWS ) {
983		$rootScope.tryInitPage($scope).then(
984			function(data){
985				TbsWS.canAccess().then(
986					function(){
987						var path = $location.path(),
988						idproduct = path.substr(path.lastIndexOf('/') + 1),
989						fakeProduct={},
990						pays = [];
991
992						$scope.productline = commonConfig.productline;
993						$scope.btnCartOnly = commonConfig.btnCartOnly;
994
995						if($rootScope.categoryBreadcrumb !== undefined){
996							$scope.categoryBreadcrumb=$rootScope.categoryBreadcrumb;
997							delete $rootScope.categoryBreadcrumb;
998						}
999
1000						$rootScope.$watch('preferredLanguage',function(){
1001				            	_reloadProduct();
1002			            });
1003
1004						$scope.donateForm = cartManager.getDonateForm();
1005
1006				        $scope.product = null;
1007				        function _reloadProduct(){
1008				        	fakeProduct.refProduit = idproduct;
1009
1010							productsManager.loadProduct(fakeProduct).then(
1011								function(product){
1012				          			$scope.product = product;
1013
1014									// piano tracking
1015									pianoManager.addCoreProperty('page', product.libelle);
1016									if (product.codeSelection.categories) {
1017										pianoManager.addCoreProperty('page_chapter1', product.codeSelection.categories[0].value);
1018									}
1019
1020									if(product.produitsLies !== undefined && product.produitsLies.length > 0){
1021						          		$scope.linkproducts = product.produitsLies;
1022						          	} else {
1023							          	productsManager.getRelatedProducts(product,4).then(
1024							          		function(relatedProducts){
1025							          			$scope.linkproducts = relatedProducts;
1026							          	});
1027							        }
1028
1029						          	if(product.categoriesLies !== undefined && product.categoriesLies.length > 0){
1030						          		$scope.linkcategories = product.categoriesLies;
1031						          	}
1032								}
1033							);
1034					    }
1035
1036					    $scope.sendDonation = cartManager.sendDonation;
1037
1038					    _reloadProduct();
1039					}
1040					,function(error) {
1041					  $rootScope.goPage(undefined,'common/login');
1042					}
1043				);
1044
1045				$rootScope.tryEndPage();
1046			}
1047		);
1048	})
1049
1050	/*.controller('cartCtrl', function($rootScope,$scope,commonConfig,cartManager,Auth, TbsWS, googleTagManager, atInternetManager) {
1051		$rootScope.tryInitPage($scope).then(
1052			function(data){
1053				TbsWS.canAccess().then(
1054					function(){
1055						googleTagManager.pageCategory = 'checkout';
1056						googleTagManager.checkoutStep(1);
1057						googleTagManager.checkoutEvent(cartManager.model.cart.lignes);
1058
1059						$scope.cartloading=false;
1060						$scope.promocode = cartManager.getPromoCodeField();
1061
1062						cartManager.loadCartWaiting().then(
1063							function(){
1064								$scope.cartloading=true;
1065								$scope.cart = cartManager.model.cart;
1066					            $scope.deleteToCart = cartManager.deleteToCart;
1067								$scope.displaydescriptioncourteoncartpage=commonConfig.displaydescriptioncourteoncartpage;
1068								$scope.displayBeneficiaries=commonConfig.displayBeneficiaries;
1069
1070						        $scope.order = function order() {
1071						        	if (commonConfig.atInternetId !== undefined) {
1072										for (var i = 0; i < $scope.cart.lignes.length; ++i) {
1073											var ligne = $scope.cart.lignes[i];
1074
1075											var type = '';
1076											if (ligne.produit.tarif.arrondiSurTtc) {
1077												type = 'PARTICULIER';
1078											} else {
1079												type = 'PRO';
1080											}
1081											atInternetManager.send({name: 'coordonnees', chapter1: 'boutiqueMM-' + commonConfig.target, chapter2: type, chapter3: ligne.produit.libelle, level2: '74'});
1082										}
1083									}
1084
1085						        	if(Auth.isClientConnecte()){
1086						            	$rootScope.goPage(undefined,'common/delivery');
1087						           } else {
1088					        			cartManager.setStartTunnelAchat(true);
1089						           		$rootScope.goPage(undefined,'common/login');
1090						           }
1091						        };
1092					        });
1093					}
1094					,function(error) {
1095					  $rootScope.goPage(undefined,'common/login');
1096					}
1097				);
1098
1099				$rootScope.tryEndPage();
1100
1101		   },function(error) {
1102	              console.error("Initialisation impossible");
1103	        }
1104		);
1105	})*/
1106
1107	.controller('cartCtrl', function($rootScope,$scope,$filter,$timeout,commonConfig,cartManager,Auth, TbsWS, googleTagManager, pianoManager, customerManager, formulaireManager, atInternetManager, productsManager, $location) {
1108		$rootScope.tryInitPage($scope).then(
1109			function(data){
1110				/* NC-24 — Repositionnement du focus après suppression d'un article */
1111				$scope.$on('cartItemDeleted', function() {
1112					$timeout(function() {
1113						var buttons = document.querySelectorAll('.price-close');
1114						if (buttons.length > 0) {
1115							buttons[0].focus();
1116						} else {
1117							var h1 = document.querySelector('.basket-page h1');
1118							if (h1) {
1119								h1.setAttribute('tabindex', '-1');
1120								h1.focus();
1121							}
1122						}
1123					}, 100);
1124				});
1125
1126				$scope.displaydescriptioncourteoncartpage=commonConfig.displaydescriptioncourteoncartpage;
1127				$scope.displayBeneficiaries=commonConfig.displayBeneficiaries;
1128				$scope.hideFormQuantity=commonConfig.hideFormQuantity;
1129				$scope.displaySpecificNrcoFpPreviOnCartPage=commonConfig.displaySpecificNrcoFpPreviOnCartPage;
1130				$scope.hideProductImageOnCartPage=commonConfig.hideProductImageOnCartPage;
1131
1132				// NC-24 (RGAA 7.1 / 12.8) — Suppression accessible : nom explicite via aria-label
1133				// dans le template + repositionnement du focus après suppression.
1134				$scope.deleteFromCart = function deleteFromCart($event, ligne, index) {
1135					if ($event) $event.preventDefault();
1136					var totalBefore = ($scope.cart && $scope.cart.lignes) ? $scope.cart.lignes.length : 0;
1137					var promise = cartManager.deleteToCart(ligne.refLigneCommande);
1138					var repositionFocus = function() {
1139						setTimeout(function() {
1140							var remaining = ($scope.cart && $scope.cart.lignes) ? $scope.cart.lignes.length : 0;
1141							var target;
1142							if (remaining <= 0) {
1143								// Plus d'article : focus sur le H1 "Mon panier"
1144								target = document.querySelector('.basket-heading h1');
1145								if (target && !target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1');
1146							} else {
1147								// Prendre le bouton "Supprimer" à l'index précédent si c'était le dernier,
1148								// sinon le bouton à l'index courant (qui est maintenant l'élément suivant).
1149								var buttons = document.querySelectorAll('.basket-detail .price-close');
1150								var newIndex = (index >= remaining) ? remaining - 1 : index;
1151								target = buttons[newIndex];
1152							}
1153							if (target && typeof target.focus === 'function') target.focus();
1154						}, 100);
1155					};
1156					if (promise && typeof promise.finally === 'function') {
1157						promise.finally(repositionFocus);
1158					} else if (promise && typeof promise.then === 'function') {
1159						promise.then(repositionFocus, repositionFocus);
1160					} else {
1161						repositionFocus();
1162					}
1163				};
1164
1165				// Support clavier : la touche Espace n'active pas naturellement <a href> — on la gère.
1166				$scope.handleDeleteKey = function handleDeleteKey($event, ligne, index) {
1167					if ($event.key === ' ' || $event.key === 'Spacebar' || $event.keyCode === 32) {
1168						$event.preventDefault();
1169						$scope.deleteFromCart($event, ligne, index);
1170					}
1171				};
1172
1173				var search = $location.search();
1174				if (search.refProduit != null) {
1175					productsManager.loadProduct({refProduit: search.refProduit}).then(function (product) {
1176						$rootScope.addToCart(product, 1);
1177					});
1178					$location.search('refProduit', null);
1179				}
1180
1181				$rootScope.tryEndPage();
1182
1183				if(commonConfig.forceAskInfoCustomerInfoOnDelivery === false) {
1184					//Code d'origine
1185					TbsWS.canAccess().then(
1186							function(){
1187								googleTagManager.pageCategory = 'checkout';
1188								googleTagManager.checkoutStep(1);
1189
1190								$scope.cartloading=false;
1191								$scope.promocode = cartManager.getPromoCodeField();
1192
1193								cartManager.loadCartWaiting().then(
1194									function(){
1195										$scope.cartloading=true;
1196										$scope.cart = cartManager.model.cart;
1197							            $scope.deleteToCart = cartManager.deleteToCart;
1198							            $scope.deleteToCartWithFocus = cartManager.deleteToCart; /* NC-24 */
1199
1200										googleTagManager.checkoutEvent(cartManager.model.cart.lignes, cartManager.model.cart.totalTtc, cartManager.model.cart.id);
1201
1202								        $scope.order = function order() {
1203											// piano tracking
1204											pianoManager.sendEvent('click.action', {
1205												click: $filter('translate')('DICO_COMMANDER')
1206											});
1207
1208								        	if (commonConfig.atInternetId !== undefined) {
1209												for (var i = 0; i < $scope.cart.lignes.length; ++i) {
1210													var ligne = $scope.cart.lignes[i];
1211
1212													var type = '';
1213													if (ligne.produit.tarif.arrondiSurTtc) {
1214														type = 'PARTICULIER';
1215													} else {
1216														type = 'PRO';
1217													}
1218													atInternetManager.send({name: 'coordonnees', chapter1: 'boutiqueMM-' + commonConfig.target, chapter2: 'abonnement', chapter3: type + '-' + ligne.produit.libelle, level2: '74'});
1219												}
1220											}
1221
1222								        	if(Auth.isClientConnecte()){
1223								            	$rootScope.goPage(undefined,'common/delivery');
1224								           } else {
1225								        	    cartManager.setStartTunnelAchat(true);
1226								        		if(commonConfig.oAuthExterne !== undefined && commonConfig.oAuthExterne.ssoQiota){
1227								        			$rootScope.callloginexterne();
1228								        		} else {
1229								        			$rootScope.goPage(undefined,'common/login');
1230								        		}
1231								           }
1232								        };
1233							        });
1234							}
1235							,function(error) {
1236							  $rootScope.goPage(undefined,'common/login');
1237							}
1238						);
1239				} else {
1240					//Nouveau code avec le routage direct vers la page de paiement si numerique et demande de complemente dinfo
1241					TbsWS.canAccess().then(
1242						function(){
1243							googleTagManager.pageCategory = 'checkout';
1244							googleTagManager.checkoutStep(1);
1245
1246							$scope.cartloading=false;
1247							$scope.promocode = cartManager.getPromoCodeField();
1248
1249							cartManager.loadCartWaiting().then(
1250								function(){
1251									$scope.cartloading=true;
1252									$scope.cart = cartManager.model.cart;
1253						            $scope.deleteToCart = cartManager.deleteToCart;
1254						            $scope.deleteToCartWithFocus = cartManager.deleteToCart; /* NC-24 */
1255
1256									googleTagManager.checkoutEvent(cartManager.model.cart.lignes, cartManager.model.cart.totalTtc, cartManager.model.cart.id);
1257
1258							        $scope.order = function order() {
1259										// piano tracking
1260										pianoManager.sendEvent('click.action', {
1261											click: $filter('translate')('DICO_COMMANDER')
1262										});
1263
1264							        	if(!Auth.isClientConnecte()) {
1265							        		_tryCallXiti();
1266							        		cartManager.setStartTunnelAchat(true);
1267							        		if(commonConfig.oAuthExterne !== undefined && commonConfig.oAuthExterne.ssoQiota){
1268							        			$rootScope.callloginexterne();
1269							        		} else {
1270							        			$rootScope.goPage(undefined,'common/login');
1271							        		}
1272						            		return;
1273							        	}
1274
1275							        	TbsWS.call('setcustomertocart/' + cartManager.model.cart.id,'private').then(
1276						        			function(status){
1277
1278									        	if(commonConfig.forceAskInfoCustomerInfoOnDelivery && cartManager.addressIsRequired() === false) {
1279								        			console.log('on essaye le complement dinfo');
1280									        		let showPopup=false;
1281									        		let addressFormInit = {};
1282									        		addressFormInit.alert = [];
1283									        		TbsWS.call('getcustomercart/'+cartManager.model.cart.id,'private').then(
1284												        	function(customer){
1285												        		let adresse = customerManager.getDeliveryAddress(customer);
1286												        		let isGift = adresse.estParrainnage;
1287
1288												        		customerManager.checkComplementInfo(customer, adresse, isGift, 'cart').then(
1289													            	function(askComplementInfo){
1290													            		if(askComplementInfo) {
1291													            			if(customerManager.addressIsPro(adresse) || adresse.estParrainnage) {
1292														        				goToNextPage('common/delivery');
1293													            			} else {
1294													            				$rootScope.openModalAddress(adresse, order, isGift, undefined, false, customer.adresses, customer, false, 'cart');
1295													        				}
1296													        			} else {
1297													        				goToNextPage();
1298												        				}
1299													            	}
1300													            );
1301												    });
1302								        		} else {
1303								        			console.log('pas de complement dinfo');
1304								        			goToNextPage();
1305								        		}
1306
1307									        	function goToNextPage(forceNextPage){
1308									        		let nextPage = 'common/delivery';
1309									        		if(forceNextPage !== undefined) {
1310									        			nextPage = forceNextPage;
1311									        		}
1312									        		_tryCallXiti();
1313								        			$rootScope.goPage(undefined, nextPage);
1314									        	}
1315						        			}
1316						        		);
1317
1318							        	function _tryCallXiti(){
1319								        	if (commonConfig.atInternetId !== undefined) {
1320												for (var i = 0; i < $scope.cart.lignes.length; ++i) {
1321													var ligne = $scope.cart.lignes[i];
1322
1323													var type = '';
1324													if (ligne.produit.tarif.arrondiSurTtc) {
1325														type = 'PARTICULIER';
1326													} else {
1327														type = 'PRO';
1328													}
1329													atInternetManager.send({name: 'coordonnees', chapter1: 'boutiqueMM-' + commonConfig.target, chapter2: 'abonnement', chapter3: type + '-' + ligne.produit.libelle, level2: '74'});
1330												}
1331											}
1332							        	}
1333							        };
1334							        //$scope.order(false);
1335						        });
1336						}
1337						,function(error) {
1338						  $rootScope.goPage(undefined,'common/login');
1339						}
1340					);
1341				}
1342
1343		   },function(error) {
1344	              console.error("Initialisation impossible");
1345	        }
1346		);
1347	})
1348
1349	.controller('paymentstatusCtrl', function($rootScope, $scope, paymentManager, $location, TbsWS, googleTagManager) {
1350		console.log('paymentstatusCtrl');
1351
1352		$rootScope.tryInitPage($scope).then(
1353			function(data){
1354				console.log('paymentstatusCtrl after tryInitPage');
1355				googleTagManager.pageCategory = 'purchase';
1356
1357	          	var path = $location.path(),
1358	          	search = $location.search(),
1359				status = 0;
1360
1361	          	if(search !== undefined && search.status !== undefined && typeof(search.status) !== "boolean" && !isNaN(search.status)){
1362					status=search.status;
1363				}
1364
1365				if(search !== undefined && search.orderId !== undefined && typeof(search.orderId) !== "boolean" && !isNaN(search.orderId)){
1366					$scope.orderId = search.orderId;
1367					paymentManager.validCommande(search.orderId, status);
1368
1369					$scope.optins = [];
1370					$scope.optinsMessage = '';
1371					$scope.optinsStatus = null;
1372					paymentManager.getOptins(0,50).then(function (optins) {
1373						$scope.optins = optins;
1374					});
1375					$scope.setoptins = function (optins) {
1376						paymentManager.setOptins(optins).then(function (success){
1377							if (success) {
1378								$scope.optinsMessage = 'DICO_VALIDATION_OPTINS_SUCCESS';
1379								$scope.optinsStatus = 'success';
1380							}
1381						});
1382					}
1383				}
1384
1385				$location.search({});
1386
1387				var back = paymentManager.getMessage(status);
1388				$scope.message = back.message;
1389				$scope.status = back.status;
1390				$scope.messageDetails = back.messageDetails;
1391				$scope.modePaiement = back.modePaiement;
1392
1393				TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
1394		       .then(function(dico){
1395					$scope.gohome = dico["404"]["gohome"];
1396		        });
1397
1398				// On supprime le page.display générique : sur la page de statut de commande,
1399				// seul l'événement page.display avec goal_type/purchase_amount (émis par
1400				// _endValidationCommande) doit remonter. Placé ici (et non avant tryInitPage,
1401				// qui remet skipPianoPageDisplay à false) pour que le flag soit encore vrai
1402				// au moment où tryEndPage2 le teste.
1403				$rootScope.skipPianoPageDisplay = true;
1404
1405				$rootScope.tryEndPage();
1406		   },function(error) {
1407	              console.error("Initialisation impossible");
1408	        }
1409		);
1410	})
1411
1412	.controller('paymentstatuspayboxCtrl', function($rootScope, $scope, paymentManager, $location, TbsWS) {
1413		$rootScope.tryInitPage($scope).then(
1414			function(data){
1415	          	var path = $location.path(),
1416	          	search = $location.search(),
1417				status=0;
1418				if(search !== undefined && search.Erreur !== undefined && typeof(search.Erreur) !== "boolean"){
1419					if (search.Erreur = '00000'){
1420						if(search.Trans != undefined && typeof(search.Trans) !== "boolean" && !isNaN(search.Trans)){
1421							status="1";
1422						} else{
1423							status="7";
1424						}
1425					}
1426
1427				}
1428
1429				if(search !== undefined && search.Ref !== undefined && typeof(search.Ref) !== "boolean" && isNaN(search.Ref)){
1430				    var elem = search.Ref.split('/');
1431				    if (elem[1] != undefined && !isNaN(elem[1])){
1432				    	$scope.orderId = elem[1];
1433				    }
1434				}
1435
1436				$location.search({});
1437
1438				$location.search('status', status);
1439                $location.search('orderId', $scope.orderId);
1440                $rootScope.goPage(undefined,'common/paymentstatus');
1441
1442				$rootScope.tryEndPage();
1443		   },function(error) {
1444	              console.error("Initialisation impossible");
1445	        }
1446		);
1447	})
1448
1449	.controller('paymentstatuspayboxerrorCtrl', function($rootScope, $scope, paymentManager, $location, TbsWS) {
1450		$rootScope.tryInitPage($scope).then(
1451			function(data){
1452	          	var path = $location.path(),
1453	          	search = $location.search(),
1454				// Force erreur paybox
1455	          	status=7;
1456	          	if(search !== undefined && search.Ref !== undefined && typeof(search.Ref) !== "boolean" && isNaN(search.Ref)){
1457				    var elem = search.Ref.split('/');
1458				    if (elem[1] != undefined && !isNaN(elem[1])){
1459				    	$scope.orderId = elem[1];
1460				    }
1461				}
1462
1463				$location.search({});
1464
1465				$location.search('status', status);
1466                $location.search('orderId', $scope.orderId);
1467                $rootScope.goPage(undefined,'common/paymentstatus');
1468
1469				$rootScope.tryEndPage();
1470		   },function(error) {
1471	              console.error("Initialisation impossible");
1472	        }
1473		);
1474	})
1475
1476
1477	.controller('autologinCtrl', function($rootScope, $scope, Auth, $window, $timeout, $location, TbsWS) {
1478		$rootScope.tryInitPage($scope).then(
1479			function(data){
1480				var search = $location.search();
1481				$timeout(function() {
1482					Auth.doAutoLogin(search).then(function(success){
1483			        	$location.search({});
1484			        	$rootScope.signin.resetInProgress();
1485		    			if($rootScope.signin.fromBasket){
1486		    				cartManager.setStartTunnelAchat(false);
1487		    				$rootScope.goPage(undefined,'common/delivery');
1488		    			} else {
1489		    				$rootScope.goPage(undefined,'common/profil/init');
1490		    			}
1491			        });
1492				});
1493
1494				$rootScope.tryEndPage();
1495
1496		   },function(error) {
1497	              console.error("Initialisation impossible");
1498	        }
1499		);
1500	})
1501
1502	.controller('loginQiotaCtrl', function($rootScope, $scope, $localStorage, $location, Auth, customerManager, cartManager, formulaireManager, $interval, $timeout, commonConfig, TbsWS) {
1503		$rootScope.tryInitPage($scope).then(
1504			function(data){
1505
1506				if (Auth.isClientConnecte()) {
1507					$rootScope.goPage(undefined,'common/profil/init');
1508				} else {
1509					$rootScope.callloginexterneQiota(true,false);
1510				}
1511				$rootScope.tryEndPage();
1512		   },function(error) {
1513	              console.error("Initialisation impossible");
1514	        }
1515		);
1516	})
1517
1518	.controller('loginIframeCtrl', function($rootScope, $scope, $localStorage, $location, Auth, customerManager, cartManager, formulaireManager, $interval, $timeout, commonConfig, TbsWS) {
1519		$rootScope.tryInitPage($scope).then(
1520			function(data){
1521
1522				if (Auth.isClientConnecte()) {
1523					$rootScope.goPage(undefined,'common/profil/init');
1524					return;
1525				}
1526
1527				let callBack = function callBack(e) {
1528					//Traitement specifique en mode Telegramme qui nous envoit la validation du formulaire par un postMessage dans l'iframe
1529					let json;
1530					try{
1531						json = JSON.parse(e.data);
1532					} catch(e){
1533						return;
1534					}
1535					//console.log(json);
1536					//console.log(e.origin);
1537					//console.log(commonConfig.oAuthExterne.urlFront);
1538					//console.log(commonConfig.commonroot);
1539					if(e.origin === commonConfig.oAuthExterne.urlFront && json.mesg !== undefined){
1540        				if(json.mesg === 'redir' && json.link !== undefined && json.link.startsWith(commonConfig.commonroot)) {
1541        					//Bouton Me Connecter sur le formulaire du Telegramme
1542        					$timeout(function() {
1543        						customerManager.afterLogin(customerManager.LOGIN_OK);
1544    						},100);
1545        				} else if(json.mesg === 'close') {
1546        					//Bouton Retour sur l'espace mon compte ou Retour à la boutique sur la boutique
1547        					$timeout(function() {
1548        						//Si je suis sur lespace moncompte
1549        						if (commonConfig.module !== undefined && commonConfig.module.others) {
1550								//if (commonConfig.commonroot.contains('moncompte')) {
1551									$rootScope.goPage(undefined, 'common/profil/init');
1552								} else {
1553									$rootScope.goPage();
1554								}
1555    						},100);
1556        				}
1557        			}
1558        			$rootScope.detachEvent(callBack);
1559				};
1560				$rootScope.attachEvent(callBack, false);
1561
1562				let url = commonConfig.oAuthExterne.urlFront;
1563
1564	        	let callBackCode = function callBackCode(code){
1565	        		console.log("callBackCode");
1566	        		var stopTime,
1567	            	hideModal = false;
1568	            	$scope.buttonshow=false;
1569	            	$rootScope.spinnerShow();
1570
1571	        		Auth.endLoginExternalToken(code).then(function(){
1572		        		$rootScope.spinnerHide().then(
1573	    					function(){
1574	    						hideModal = true;
1575	            				function updateTime(){
1576	            					if(hideModal){
1577	            						$interval.cancel(stopTime);
1578	            						customerManager.afterLogin(customerManager.LOGIN_OK);
1579	            					}
1580	            				}
1581	            				stopTime = $interval(updateTime, 50);
1582	    					}
1583    					);
1584		        	});
1585	        		commonConfig.oAuthExterne.callBackCodeEnabled = false;
1586				};
1587				commonConfig.oAuthExterne.callBackCodeEnabled = true;
1588	        	commonConfig.oAuthExterne.callBackCode = callBackCode;
1589
1590		        if(commonConfig.oAuthExterne !== undefined && commonConfig.oAuthExterne.ssoQiota){
1591	        		console.log("login from iframe ssoQiota");
1592	        		$rootScope.attachEvent($rootScope.callBackAuthorize);
1593		        	let redirect_uri = commonConfig.commonroot + "/content/sso/silentiframe.html";
1594		        	//ob.referer = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '');
1595		        	url += "?redirect_uri="+redirect_uri+"&referer="+commonConfig.oAuthExterne.referer+"&uri_referer="+commonConfig.clientroot+"&iframe=true";
1596		        } else {
1597		        	url += '?referer='+commonConfig.clientroot+'&embed=true';
1598		        }
1599		        $scope.url = url;
1600
1601
1602				//$scope.url = commonConfig.oAuthExterne.urlFront + '?referer='+(location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: ''))+'&embed=true';
1603
1604				var existuser={};
1605				existuser.alert = {};
1606				existuser.alert.message = [];
1607				$scope.existuser = existuser;
1608
1609				$rootScope.$watch('preferredLanguage',function(){
1610					$timeout(function() {
1611					  reloadForm();
1612					});
1613	            });
1614
1615	            function reloadForm(){
1616	            	$scope.existuser = customerManager.getExistUserForm(true);
1617	            }
1618
1619				$rootScope.tryEndPage();
1620
1621		   },function(error) {
1622	              console.error("Initialisation impossible");
1623	        }
1624		);
1625	})
1626
1627	.controller('loginCtrl', function($rootScope, $scope, $localStorage, $location, Auth, customerManager, cartManager, formulaireManager, $interval, $timeout, commonConfig, TbsWS, $stateParams) {
1628		$rootScope.tryInitPage($scope).then(
1629			function(data){
1630
1631				if (Auth.isClientConnecte()) {
1632					$rootScope.goPage(undefined,'common/profil/init');
1633					return;
1634				}
1635
1636				let openForget = $stateParams.OPEN_FORGET;
1637
1638				var newuser={};
1639				newuser.alert = {};
1640				newuser.alert.message = [];
1641				$scope.newuser = newuser;
1642
1643				var existuser={};
1644				existuser.alert = {};
1645				existuser.alert.message = [];
1646				$scope.existuser = existuser;
1647
1648				$scope.externallogin = (commonConfig.idpurl===undefined?false:true);
1649				$scope.hideSignupForm = commonConfig.hideSignupForm;
1650				$scope.autocompleteAddress = commonConfig.autocompleteAddress;
1651
1652				//Surcharge du lien cgv si externe
1653				$scope.cgvspecifique=false;
1654				if (commonConfig.surchargePageCgv !== undefined){
1655					$scope.cgvspecifique=true;
1656					$scope.linkCgv=commonConfig.surchargePageCgv;
1657				}
1658
1659				if(commonConfig.privateshop == true){
1660					Auth.displayMessageIfWasConnecte();
1661				}
1662
1663				$rootScope.$watch('preferredLanguage',function(){
1664					$timeout(function() {
1665					  reloadForm();
1666					});
1667	            });
1668
1669				$scope.showPassword = function showPassword(event, uniqname) {
1670					if (document.getElementsByName(uniqname).length == 1) {
1671						const type = document.getElementsByName(uniqname)[0].type;
1672						if (type == 'password') {
1673							document.getElementsByName(uniqname)[0].type = 'text';
1674							event.target.className = 'glyphicon glyphicon-eye-close';
1675						} else {
1676							document.getElementsByName(uniqname)[0].type = 'password';
1677							event.target.className = 'glyphicon glyphicon-eye-open';
1678						}
1679					}
1680				};
1681
1682	            $scope.openMessage = function openMessage(text){
1683	            	$rootScope.openModalInformation( "DICO_INFORMATION", text);
1684	            };
1685
1686				$scope.signin = function signin(formCode){
1687					if($scope.externallogin == false){
1688						var stopTime,
1689		            		hideModal = false;
1690		            	$scope.buttonshow=false;
1691		            	$rootScope.spinnerShow();
1692
1693			        	customerManager.signinFunction(formCode).then(function(success){
1694			        		$rootScope.spinnerHide().then(
1695		    					function(){
1696		    						if(success && (success.startsWith(customerManager.LOGIN) || success == 'logout')){
1697			    						hideModal = true;
1698			            				function updateTime(){
1699			            					if(hideModal){
1700			            						$interval.cancel(stopTime);
1701			            						customerManager.afterLogin(success);
1702			            					}
1703			            				}
1704			            				stopTime = $interval(updateTime, 50);
1705				            		} else {
1706				            			$scope.buttonshow=true;
1707				            		}
1708		    					}
1709	    					);
1710			        	});
1711			        }
1712		        };
1713
1714		        if(commonConfig.createaccountenabled){
1715					$scope.signup  = function signup(newuserForm){
1716						var stopTime,
1717		            		hideModal = false;
1718		            	$scope.buttonshow=false;
1719		            	$rootScope.spinnerShow();
1720
1721			        	customerManager.signupFunction(newuserForm).then(function(success){
1722			        		$rootScope.spinnerHide().then(
1723		    					function(){
1724					        		if(success>0){
1725			    						hideModal = true;
1726			            				function updateTime(){
1727			            					if(hideModal){
1728			            						$interval.cancel(stopTime);
1729												$rootScope.createAccountMessage=true;
1730												if(success==2){
1731													//autovalidation + autoconnexion
1732													$rootScope.createAccountMessageStr="DICO_CONTROLLER_VALIDATION_CONNEXION_COMPTE_MESSAGE";
1733													//Redirection du client vers la bonne page en fonction du tunnel dachat
1734													cartManager.loadCartWaiting().then(
1735										          		function(status){
1736										          			var route = 'common/profil/init';
1737										          			if(cartManager.model.cart.lignes.length > 0){
1738										          				route = 'common/delivery';
1739										          			}
1740
1741															$timeout(function() {
1742															  $rootScope.goPage(undefined,route);
1743															},2000);
1744										          		}
1745										          	);
1746
1747												} else if(success==3){
1748													//autovalidation + mais pas autoconnexion
1749													$rootScope.createAccountMessageStr="DICO_CONTROLLER_VALIDATION_COMPTE_MESSAGE";
1750												} else {
1751													$rootScope.createAccountMessageStr="DICO_CONTROLLER_CREATION_COMPTE_MESSAGE";
1752												}
1753								          		$rootScope.goPage(undefined);
1754			            					}
1755			            				}
1756			            				stopTime = $interval(updateTime, 50);
1757				            		} else {
1758				            			$scope.buttonshow=true;
1759				            		}
1760		    					}
1761	    					);
1762			        	});
1763			        };
1764		        }
1765
1766	            function reloadForm(){
1767
1768	            	//On ajoute les infos alert directement pour cacher au chargement le div alert
1769
1770	            	if(commonConfig.createaccountenabled){
1771						customerManager.getNewUserForm().then(function(userForm){
1772							$scope.newuser = userForm;
1773						});
1774	            	}
1775
1776
1777					var testForm = $rootScope.signin.inProgress && $rootScope.signin.password !==undefined && $rootScope.signin.password != "";
1778
1779					$scope.existuser = customerManager.getExistUserForm(true);
1780					if(testForm){
1781						customerManager.checkSigninFunction($scope.existuser);
1782					}
1783	            }
1784	            commonConfig.openForget = openForget;
1785	            if(openForget !== undefined && openForget){
1786	            	let timeout = 2000;
1787	            	if($rootScope.loadIsEnded){
1788		            	console.log("try show modal");
1789	            		timeout = 200;
1790	            	}
1791	            	$timeout(function() {
1792	            		$rootScope.openModalForget();
1793					},timeout);
1794	            }
1795				$rootScope.tryEndPage();
1796
1797		   },function(error) {
1798	              console.error("Initialisation impossible");
1799	        }
1800		);
1801	})
1802
1803	.controller('profilCtrl', function($rootScope,$scope,commonConfig,TbsWS,formulaireManager,customerManager,cartManager,$location,$timeout,$anchorScroll,wishlistManager, $interval, $window) {
1804		$rootScope.tryInitPage($scope).then(
1805			function(data){
1806				$rootScope.isAuthorized().then(
1807					function(access){
1808						var path = $location.path(),
1809						anchor = path.substr(path.lastIndexOf('/') + 1);
1810
1811						$scope.urlforgotexists = (commonConfig.urlforgotpassword !== undefined?true:false);
1812						$scope.hideInvoices = commonConfig.hideInvoices;
1813						$scope.hideSubscriptions = commonConfig.hideSubscriptions;
1814						$scope.hideProfilAddress = commonConfig.hideProfilAddress;
1815						$scope.displayOffers = commonConfig.displayOffers;
1816						$scope.libHideInvoices = commonConfig.libHideInvoices;
1817						$scope.hideWishList = commonConfig.hideWishList;
1818						$scope.hideDateSubscriptions = commonConfig.hideDateSubscriptions;
1819						$scope.hidePublicationSubscription = commonConfig.hidePublicationSubscription;
1820						$scope.displayBeneficiaries = commonConfig.displayBeneficiaries;
1821						$scope.displayDesignationFormule = commonConfig.displayDesignationFormule;
1822						$scope.temporarySuspension = commonConfig.temporarySuspension;
1823						$scope.reverseProfileWithDelivery = commonConfig.reverseProfileWithDelivery;
1824						$scope.displayTrackingOrder = commonConfig.displayTrackingOrder;
1825						$scope.displayArticles = commonConfig.displayArticles;
1826						$scope.calduenabled = commonConfig.calduenabled;
1827						$scope.libparutionenabled = commonConfig.libparutionenabled;
1828						$scope.displayResiliation = commonConfig.displayResiliation;
1829						$scope.contactResilierSpecifique = commonConfig.contactResilierSpecifique;
1830						$scope.linkContactResilier = commonConfig.linkContactResilier;
1831						$scope.displayOffersOffered = commonConfig.displayOffersOffered;
1832
1833						$scope.suspendre = false;
1834						$scope.motifsSuspension = null;
1835						$scope.suspension_error = null;
1836						$scope.suspension_max_days = null;
1837						$scope.isoPaysRoutage = commonConfig.isoPaysRoutage;
1838						$scope.disabledEditAddress = commonConfig.disabledEditAddress;
1839						$scope.disabledDeliveryAddress = commonConfig.disabledDeliveryAddress;
1840
1841						$rootScope.$watch('preferredLanguage',function(){
1842							reloadProfile();
1843						});
1844
1845						$scope.editcustomer = function(userForm){
1846
1847							var stopTime,
1848							hideModal = false;
1849							$scope.buttonshow=false;
1850							$rootScope.spinnerShow();
1851
1852							customerManager.editCustomerFunction(userForm).then(function(success){
1853								if(success == 'logout'){
1854									$rootScope.spinnerHide().then(
1855										function(){
1856											hideModal = true;
1857											function updateTime(){
1858												if(hideModal){
1859													$interval.cancel(stopTime);
1860													$rootScope.goPage(undefined,'common/logout');
1861												}
1862											}
1863											stopTime = $interval(updateTime, 50);
1864										}
1865									);
1866								} else if(success){
1867									customerManager.getCustomer().then(
1868										function(customer){
1869											$rootScope.spinnerHide().then(
1870												function(){
1871													hideModal = true;
1872													function updateTime(){
1873														if(hideModal){
1874															$interval.cancel(stopTime);
1875															loadCustomer(customer);
1876															$rootScope.temp.validatedtitle = "DICO_CONTROLLER_INFORMATION_VALIDE";
1877															$rootScope.temp.validatedtext = "DICO_CONTROLLER_VOS_INFORMATIONS_ONT_ETE_MODIFIEES";
1878															$('#ValidatedModal').modal('show');
1879														}
1880													}
1881													stopTime = $interval(updateTime, 50);
1882												}
1883											);
1884										}
1885									);
1886								} else {
1887									$rootScope.spinnerHide().then(
1888										function(){
1889											$scope.buttonshow=true;
1890										}
1891									);
1892								}
1893							});
1894						};
1895
1896						$scope.showPassword = function showPassword(event, uniqname) {
1897							if (document.getElementsByName(uniqname).length == 1) {
1898								const type = document.getElementsByName(uniqname)[0].type;
1899								if (type == 'password') {
1900									document.getElementsByName(uniqname)[0].type = 'text';
1901									event.target.className = 'glyphicon glyphicon-eye-close';
1902								} else {
1903									document.getElementsByName(uniqname)[0].type = 'password';
1904									event.target.className = 'glyphicon glyphicon-eye-open';
1905								}
1906							}
1907						};
1908
1909						$scope.createNewAddress = function createNewAddress(){
1910							if(commonConfig.temporaryAddress == false && $scope.customer.adresses.length >= commonConfig.nbadresse){
1911								$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_MAXIMUM_ADRESSE_ATTEINT" );
1912							} else {
1913								$rootScope.openModalAddress(undefined,undefined,false,undefined,false,$scope.customer.adresses, $scope.customer, true, 'profil');
1914							}
1915						};
1916
1917						$scope.editAddress = function editAddress(address, isBeneficiary){
1918							if(isBeneficiary === undefined){
1919								isBeneficiary = false;
1920							}
1921
1922							var adresses = null;
1923							if (!isBeneficiary) {
1924								adresses = $scope.customer.adresses;
1925							}
1926
1927							$rootScope.openModalAddress(address, loadCustomer,false, undefined, isBeneficiary,adresses, $scope.customer, true, 'profil');
1928						};
1929
1930						$scope.duplicateAddress = function duplicateAddress(address){
1931							if(commonConfig.temporaryAddress == false && $scope.customer.adresses.length >= commonConfig.nbadresse){
1932								$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_MAXIMUM_ADRESSE_ATTEINT" );
1933							} else {
1934								var newAddress = Object.assign({}, address);
1935								newAddress.refAdresse = undefined;
1936								newAddress.estPrincipale = false;
1937								newAddress.estLivraison = true;
1938								$rootScope.openModalAddress(newAddress,undefined,false,undefined,false,$scope.customer.adresses,$scope.customer, true, 'profil');
1939							}
1940						}
1941
1942						$scope.deleteAddress = function deleteAddress(address){
1943							function confirmDeleteAdress(){
1944								customerManager.deleteAddressFunction(address).then(
1945									function(result){
1946										if(result){
1947											customerManager.getCustomer().then(
1948												function(customer){
1949													loadCustomer(customer);
1950												}
1951											);
1952										}
1953									}
1954								);
1955							};
1956							function cancelDeleteAdress(){};
1957							$rootScope.openModalYesNo( "DICO_INFORMATION", "DICO_ETES_SUR_DE_VOULOIR_SUPPRIMER", cancelDeleteAdress, confirmDeleteAdress, "DICO_NON", "DICO_OUI");
1958						};
1959
1960						$scope.updateSelectAddress = function updateSelectAddress(){
1961							if($scope.adressSelectForm.value){
1962								customerManager.setDeliveryAdress($scope.adressSelectForm,$scope.customer).then(
1963									function(status){
1964										if(status){
1965											cartManager.loadCart();
1966											$scope.adresse = $scope.adressSelectForm.value;
1967										}
1968									}
1969								);
1970							} else {
1971								$scope.adresse = null;
1972							}
1973						};
1974
1975						function loadCustomer(customer){
1976							$scope.customer = customer;
1977							$scope.displaytype = true;
1978							/*$scope.entete = "#"+customer.codeClient;
1979							if(customer.adressePrincipale.societe){
1980								$scope.entete += " - ";
1981								$scope.entete += (customer.adressePrincipale.societe?customer.adressePrincipale.societe.toUpperCase()+" ":"");
1982							} else if(customer.adressePrincipale.prenom || customer.adressePrincipale.nom){
1983								$scope.entete += " - ";
1984								$scope.entete += (customer.adressePrincipale.prenom?customer.adressePrincipale.prenom+" ":"");
1985								$scope.entete += (customer.adressePrincipale.nom?customer.adressePrincipale.nom.toUpperCase()+" ":"");
1986							}*/
1987
1988							$scope.entete = (customer.adressePrincipale.prenom?customer.adressePrincipale.prenom+" ":"");
1989							$scope.entete += (customer.adressePrincipale.nom?customer.adressePrincipale.nom.toUpperCase()+" ":"");
1990
1991							$scope.adressSelectForm = customerManager.getSelectedDeliveryForm(customer);
1992							$scope.adresse = customerManager.getDeliveryAddress(customer);
1993
1994							$scope.urlcadeau = commonConfig.clientroot+"/img/icon-gift.png";
1995
1996							$scope.beneficiaries = [];
1997							if (customer.beneficiaires != null) {
1998								$scope.beneficiaries = customer.beneficiaires;
1999								for(let i = 0;i<$scope.beneficiaries.length;i++){
2000									let payePar = $scope.beneficiaries[i];
2001									payePar.nomAffiche = (payePar.adressePrincipale.civilite?payePar.adressePrincipale.civilite+' ':'');
2002									payePar.nomAffiche += (payePar.adressePrincipale.prenom?payePar.adressePrincipale.prenom+' ':'');
2003									payePar.nomAffiche += (payePar.adressePrincipale.nom?payePar.adressePrincipale.nom.toUpperCase()+' ':'');
2004									payePar.subscriptions = [];
2005								}
2006
2007								if($scope.beneficiaries.length > 0){
2008									customerManager.getSubscriptionsByBeneficiaries().then(
2009										function(subscriptions){
2010											for(let i = 0;i<$scope.beneficiaries.length;i++){
2011												let payePar = $scope.beneficiaries[i];
2012												if(subscriptions[payePar.codeClient] != null) {
2013													payePar.subscriptions = subscriptions[payePar.codeClient];
2014												}
2015											}
2016										}
2017									);
2018								}
2019							}
2020
2021							customerManager.getEditUserForm(customer,false).then(
2022								function(form){
2023									$scope.customerForm = form;
2024									if(anchor !== undefined){
2025										$timeout(function() {
2026											$anchorScroll(anchor);
2027										},1000);
2028									}
2029								}
2030							);
2031
2032						}
2033
2034						$scope.deleteToWishlist = function deleteToWishlist(product){
2035							function confirmDeleteToWishlist(){
2036								wishlistManager.deleteToWishlist(product).then(
2037									function(status){
2038										if(status){
2039											loadWishlist();
2040										}
2041									}
2042								);
2043							};
2044							function cancelDeleteToWishlist(){};
2045							$rootScope.openModalYesNo( "DICO_INFORMATION", "DICO_ETES_SUR_DE_VOULOIR_SUPPRIMER", cancelDeleteToWishlist, confirmDeleteToWishlist, "DICO_NON", "DICO_OUI");
2046						};
2047
2048						$scope.openModalAddAccesBeneficiaire = function openModalAddAccesBeneficiaire(refAbonnement, acces){
2049							$rootScope.openModalAccesBeneficiaire(refAbonnement, acces, loadSubscriptions);
2050						};
2051
2052						$scope.deleteAccesBeneficiaire = function deleteAccesBeneficiaire(refAbonnement, codeClient){
2053							if (refAbonnement != null && codeClient != null) {
2054								customerManager.deleteAccesBeneficiaire(refAbonnement, codeClient).then(function(success) {
2055									if (success) {
2056										$scope.loadSubscriptions(offset, maxResults);
2057										$timeout(function() {
2058											$('#collapseBeneficiaires' + refAbonnement).collapse("show");
2059										},1000);
2060									}
2061								});
2062							}
2063						};
2064
2065						$scope.downloadInvoice = customerManager.downloadInvoice;
2066
2067						function loadWishlist(){
2068							$scope.wishlistproducts = [];
2069							wishlistManager.getWishlist().then(
2070								function(products){
2071									$scope.wishlistproducts = products;
2072								}
2073							);
2074						}
2075
2076						$scope.invoices = [];
2077						$scope.loadInvoices = function loadInvoices(offset, maxResults){
2078							customerManager.getInvoices(offset, maxResults).then(
2079								function(invoices){
2080									$scope.invoices = $scope.invoices.concat(invoices);
2081								}
2082							);
2083						}
2084
2085						function loadNbInvoices(){
2086							customerManager.getNbInvoices().then(
2087								function(nbInvoices){
2088									$scope.nbInvoices = nbInvoices;
2089								}
2090							);
2091						}
2092
2093						$scope.offers = [];
2094						$scope.loadOffers = function loadOffers(offset, maxResults, reset = false){
2095							customerManager.getOffers(offset, maxResults, null).then(
2096								function(offers){
2097									if (reset === true) {
2098										$scope.offers = [];
2099									}
2100									$scope.offers = $scope.offers.concat(offers);
2101									loadNextTemporarySuspensions();
2102								}
2103							);
2104						}
2105
2106						function loadNbOffers(){
2107							customerManager.getNbOffers().then(
2108								function(nbOffers){
2109									$scope.nbOffers = nbOffers;
2110								}
2111							);
2112						}
2113
2114						$scope.offersoffered = [];
2115						$scope.loadOffersOffered = function loadOffersOffered(offset, maxResults){
2116							customerManager.getOffersOffered(offset, maxResults).then(
2117								function(offers){
2118									$scope.offersoffered = $scope.offersoffered.concat(offers);
2119									$scope.offersoffered.forEach(function(offer) {
2120										customerManager.getCustomerByCodeClient(offer.codeClient).then(
2121											function(client){
2122												offer.client = client;
2123											}
2124										);
2125									});
2126								}
2127							);
2128						}
2129
2130						function loadNbOffersOffered(){
2131							customerManager.getNbOffersOffered().then(
2132								function(nbOffers){
2133									$scope.nbOffersOffered = nbOffers;
2134								}
2135							);
2136						}
2137
2138						$scope.showDetail = function showDetail(offer, isParrain){
2139							$rootScope.openModalDetailOffre('DICO_DETAIL_OFFRE_TITRE', offer, isParrain);
2140						};
2141
2142						$scope.subscriptions = [];
2143						$scope.loadSubscriptions = function loadSubscriptions(offset, maxResults, reset = false){
2144							customerManager.getSubscriptions(offset, maxResults, 0).then(
2145								function(subscriptions){
2146									if (reset === true) {
2147										$scope.subscriptions = [];
2148									}
2149									$scope.subscriptions = $scope.subscriptions.concat(subscriptions);
2150									loadNextTemporarySuspensions();
2151								}
2152							);
2153						}
2154
2155						function loadNbSubscriptions(){
2156							customerManager.getNbSubscriptions().then(
2157								function(nbSubscriptions){
2158									$scope.nbSubscriptions = nbSubscriptions;
2159								}
2160							);
2161						}
2162
2163						$scope.mesarticles = [];
2164						$scope.loadArticles = function loadArticles(offset, maxResults){
2165								customerManager.getArticles(offset, maxResults).then(
2166									function(articles){
2167										$scope.mesarticles = $scope.mesarticles.concat(articles);
2168									}
2169								);
2170						}
2171
2172						function loadNbArticles(){
2173							customerManager.getNbArticles().then(
2174								function(nbArticles){
2175									$scope.nbArticles = nbArticles;
2176								}
2177							);
2178						}
2179
2180						$rootScope.loadBankDetails = function loadBankDetails(){
2181							customerManager.getBankDetails().then(
2182								function(bankdetails){
2183									$scope.bankdetails = bankdetails;
2184								}
2185							);
2186						}
2187
2188						function loadNextTemporarySuspensions() {
2189							customerManager.getSuspensions().then(
2190								function (suspensions) {
2191									var now = new Date();
2192									now.setHours(0, 0, 0, 0);
2193									for (var i = 0; i < suspensions.length; ++i) {
2194										var s = suspensions[i];
2195										for (var j = 0; j < $scope.subscriptions.length; ++j) {
2196											var abo = $scope.subscriptions[j];
2197											if (s.refAbonnements != null && s.refAbonnements.length > 0
2198													&& abo.refAbonnement != null && abo.refAbonnement == s.refAbonnements[0]
2199													&& s.typeSuspension == 3 && (s.dateFin >= now.getTime())
2200													&& (abo.nextTemporarySuspension == null || abo.nextTemporarySuspension.dateDebut > s.dateDebut)) {
2201												abo.nextTemporarySuspension = s;
2202											}
2203										}
2204										for (var j = 0; j < $scope.offers.length; ++j) {
2205											var abo = $scope.offers[j].abonnementMaitre;
2206											if (s.refAbonnements != null && s.refAbonnements.length > 0
2207													&& abo.refAbonnement != null && abo.refAbonnement == s.refAbonnements[0]
2208													&& s.typeSuspension == 3 && (s.dateFin >= now.getTime())
2209													&& (abo.nextTemporarySuspension == null || abo.nextTemporarySuspension.dateDebut > s.dateDebut)) {
2210												abo.nextTemporarySuspension = s;
2211											}
2212										}
2213									}
2214								}
2215							);
2216						}
2217
2218						function reloadProfile(){
2219							$scope.urlminimastercard = commonConfig.paymentimg+"img-card-mastercard.png?v="+commonConfig.forceversion;
2220							$scope.hideBankDetails = commonConfig.hideBankDetails;
2221							$scope.hideBankNumCb = commonConfig.hideBankNumCb;
2222							$scope.maxResult = 5;
2223							$rootScope.$watch('lastAddress',function(){
2224								customerManager.getCustomer(false).then(
2225									function(customer){
2226										if(customer !== null){
2227											loadCustomer(customer);
2228											if (!commonConfig.hideWishList) {
2229												loadWishlist();
2230											}
2231											if (!$scope.hideSubscriptions) {
2232												if (commonConfig.displayOffers) {
2233													$scope.loadOffers(0, $scope.maxResult);
2234													loadNbOffers();
2235												} else {
2236													$scope.loadSubscriptions(0, $scope.maxResult);
2237													loadNbSubscriptions();
2238												}
2239												if (commonConfig.displayOffersOffered) {
2240													$scope.loadOffersOffered(0, $scope.maxResult);
2241													loadNbOffersOffered();
2242												}
2243											}
2244											if (!commonConfig.hideInvoices) {
2245												$scope.loadInvoices(0, $scope.maxResult);
2246												loadNbInvoices();
2247											}
2248											if (commonConfig.displayArticles) {
2249												$scope.loadArticles(0, $scope.maxResult);
2250												loadNbArticles();
2251											}
2252											if(commonConfig.tokenqiota !== undefined && !commonConfig.hideBankDetails
2253												&& ((_.contains(commonConfig.paiementsqiota, "PRELEV_CB"))
2254													|| (_.contains(commonConfig.paiementsqiota, "SLIMPAY_PRELEV_CB"))
2255													|| (_.contains(commonConfig.paiementsqiota, "PAYZEN_CB"))
2256													|| (_.contains(commonConfig.paiementsqiota, "STANCER_PRELEV_CB")))) {
2257												$scope.qiotaCb = true;
2258												$rootScope.loadBankDetails();
2259											}
2260										}
2261									}
2262								);
2263							});
2264						}
2265
2266						$scope.goforgoturl = function goforgoturl(e){
2267							e.preventDefault();
2268							if(commonConfig.urlforgotpassword !== undefined){
2269								$window.open(commonConfig.urlforgotpassword, '_blank');
2270							}
2271						};
2272
2273						$scope.toggleSuspendre = function () {
2274							$scope.suspendre = !$scope.suspendre;
2275							if ($scope.suspendre) {
2276								suspensionForm = {};
2277								suspensionForm.dateDebut = new Date();
2278								suspensionForm.dateFin = new Date();
2279								suspensionForm.refMotif = '';
2280								suspensionForm.refAbonnements = [];
2281								$scope.suspensionForm = suspensionForm;
2282
2283								customerManager.getSuspensionReasonsByReasonType(3).then(
2284									function(motifs) {
2285										$scope.motifsSuspension = motifs;
2286									}
2287								);
2288							}
2289						}
2290
2291						$scope.createSuspension = function (suspensionForm) {
2292							var confirmCreate = function () {
2293								if ($scope.suspendre && suspensionForm.refAbonnements.length > 0) {
2294									customerManager.addSuspension(suspensionForm).then(function(success) {
2295										if (success === true) {
2296											$scope.suspension_error = null;
2297											$scope.suspendre = false;
2298											if (commonConfig.displayOffers) {
2299												$scope.loadOffers(0, $scope.maxResult, true);
2300											} else {
2301												$scope.loadSubscriptions(0, $scope.maxResult, true);
2302											}
2303										} else if(success && success.error) {
2304											if (success.error == 'error_duration') {
2305												$scope.suspension_max_days = success.params[0];
2306											}
2307											$scope.suspension_error = success.error;
2308										}
2309									});
2310								}
2311							}
2312							$rootScope.openModalYesNo( 'DICO_INFORMATION', 'DICO_SUSPENSION_ETES_SUR_DE_VOULOIR_CREER', function () {}, confirmCreate, 'DICO_NON', 'DICO_OUI');
2313						}
2314
2315						$scope.deleteSuspension = function (refSuspension) {
2316							if (refSuspension != null) {
2317								customerManager.deleteSuspension(refSuspension).then(function(success) {
2318									if (success) {
2319										if (commonConfig.displayOffers) {
2320											$scope.loadOffers(0, $scope.maxResult, true);
2321										} else {
2322											$scope.loadSubscriptions(0, $scope.maxResult, true);
2323										}
2324									}
2325								});
2326							}
2327						}
2328
2329						$scope.checkInvalidSuspension = function () {
2330							var form = $scope.suspensionForm;
2331
2332							if (form.refAbonnements.length == 0) {
2333								return true;
2334							} else if (form.dateDebut > form.dateFin) {
2335								return true;
2336							}
2337
2338							return false;
2339						}
2340					},
2341					function(error) {
2342						$rootScope.goPage(undefined,'common/login');
2343					}
2344				);
2345				$rootScope.tryEndPage();
2346			},
2347			function(error) {
2348				console.error("Initialisation impossible");
2349			}
2350		);
2351	})
2352
2353	.controller('deliveryCtrl', function($rootScope,$scope,$filter,commonConfig,TbsWS,customerManager, cartManager,formulaireManager,$interval,$timeout, googleTagManager, pianoManager) {
2354		$rootScope.tryInitPage($scope).then(
2355			function(data){
2356				if($rootScope.loadIsEnded == true){
2357				    $rootScope.spinnerShow();
2358				}
2359				$rootScope.isAuthorized().then(
2360			          function(access){
2361						  googleTagManager.pageCategory = 'checkout';
2362						  googleTagManager.checkoutStep(2);
2363
2364						  cartManager.loadCartWaiting().then(
2365							  function(){
2366								  googleTagManager.checkoutEvent(cartManager.model.cart.lignes, cartManager.model.cart.totalTtc, cartManager.model.cart.id);
2367
2368								  //Surcharge du lien cgv si externe
2369								  $scope.cgvspecifique=false;
2370								  if (commonConfig.surchargePageCgv !== undefined){
2371									  $scope.cgvspecifique=true;
2372									  $scope.linkCgv=commonConfig.surchargePageCgv;
2373								  }
2374
2375								  TbsWS.call('setcustomertocart/' + cartManager.model.cart.id,'private').then(
2376									  function(status){
2377										  $scope.adressSelectForm = {};
2378										  $scope.adressSelectForm.alert = {};
2379										  $scope.adressSelectForm.alert.message = [];
2380										  $scope.adressSelectForm.others = {};
2381
2382										  $scope.isGift=false;
2383										  $scope.cadeauenabled=commonConfig.cadeauenabled;
2384										  $scope.displaydescriptioncourteondeliverypage=commonConfig.displaydescriptioncourteondeliverypage;
2385										  $scope.disabledEditAddress = commonConfig.disabledEditAddress;
2386										  $scope.disabledDeliveryAddress = commonConfig.disabledDeliveryAddress;
2387										  $scope.displayProductImageOnDeliveryPage = commonConfig.displayProductImageOnDeliveryPage;
2388
2389										  $scope.createNewAddress = function createNewAddress(){
2390											  if($scope.customer.adresses.length >= commonConfig.nbadresse){
2391												  $rootScope.openModalInformation( "DICO_INFORMATION", "DICO_MAXIMUM_ADRESSE_ATTEINT" );
2392											  } else {
2393												  $rootScope.openModalAddress(undefined,undefined,false,undefined, undefined, undefined, $scope.customer, true, 'delivery');
2394											  }
2395										  };
2396
2397										  $scope.createNewGiftAddress = function createNewGiftAddress(){
2398											  $scope.isGift=!$scope.isGift;
2399											  if($scope.isGift){
2400												  $rootScope.spinnerShow();
2401												  customerManager.setUseParrainnageAdress().then(
2402													  function(){
2403														  customerManager.getCustomer(true).then(
2404															  function(customer){
2405																  loadCustomer(customer);
2406																  if($scope.adresse.codepostal === ""||$scope.adresse.codepostal === null){
2407																	  $rootScope.spinnerHide().then(
2408																		  function(){
2409																			  $timeout(function() {
2410																				  function _reload(customer){
2411																					  loadCustomer(customer);
2412																					  reloadDelivery();
2413																				  }
2414																				  $rootScope.openModalAddress($scope.adresse,_reload,$scope.isGift, undefined, true, undefined, $scope.customer, true, 'delivery');
2415																			  },100);
2416																		  }
2417																	  );
2418																  } else {
2419																	  reloadDeliveryAndHide();
2420																  }
2421															  });
2422													  }
2423												  );
2424											  } else {
2425												  $rootScope.spinnerShow();
2426												  customerManager.setResetParrainnageAdress().then(
2427													  function(){
2428														  customerManager.getCustomer(true).then(
2429															  function(customer){
2430																  $timeout(function() {
2431																	  loadCustomer(customer);
2432																	  reloadDeliveryAndHide();
2433																  },100);
2434															  });
2435													  }
2436												  );
2437											  }
2438										  };
2439
2440										  $scope.order = function order() {
2441											// piano tracking
2442											pianoManager.sendEvent('click.action', {
2443												click: $filter('translate')('DICO_COMMANDER')
2444											});
2445
2446											  $scope.adressSelectForm.alert.message = [];
2447											  if($scope.adresse == null){
2448												  $scope.adressSelectForm.alert.message.push('DICO_CONTROLLER_SELECTION_ADRESSE_LIVRAISON');
2449												  return;
2450											  }
2451
2452											  let ob = _.findWhere($scope.tabCsPiecesJointes, {uploadIsOk: false});
2453											  if(ob !== undefined){
2454												  $scope.adressSelectForm.alert.message.push('DICO_CONTROLLER_UPLOAD_PIECE_JOINTE');
2455												  return;
2456											  }
2457
2458											  if(formulaireManager.verifForm($scope.adressSelectForm) == false){
2459												  console.log("erreur");
2460												  return;
2461											  }
2462
2463											  // verification du panier
2464											  cartManager.loadCartCheck().then(
2465												  function() {
2466													  //Verification de l adresse
2467													  function _afterVerif(){
2468														  var stopTime,
2469															  hideModal = false;
2470														  $scope.buttonshow=false;
2471														  $rootScope.spinnerShow();
2472														  cartManager.checkDeliveryVsContentOfCart().then(
2473															  function(status){
2474																  $rootScope.spinnerHide().then(
2475																	  function(){
2476																		  hideModal = true;
2477																		  function updateTime(){
2478																			  if(hideModal){
2479																				  $interval.cancel(stopTime);
2480																				  if(status == cartManager.CART_DELIVERY_CONTENT_OK){
2481																					  $rootScope.goPage(undefined,'common/paymentdetails');
2482																				  } else if(status == cartManager.CART_CHECK_ERROR){
2483																					  $scope.adressSelectForm.alert.message.push('DICO_ERREUR_CHECK_CONTENU_PANIER');
2484																				  } else {
2485																					  $rootScope.openModalInformation( "DICO_INFORMATION", status );
2486																				  }
2487																			  }
2488																		  }
2489																		  stopTime = $interval(updateTime, 50);
2490																	  }
2491																  );
2492															  }
2493														  );
2494													  };
2495													  if(commonConfig.forceAskInfoCustomerInfoOnDelivery){
2496														  TbsWS.call('getcustomercart/'+cartManager.model.cart.id,'private').then(
2497															  function(customer){
2498																  let adresse = customerManager.getDeliveryAddress(customer);
2499																  let isGift = false;
2500
2501																  customerManager.checkComplementInfo(customer, adresse, $scope.isGift, 'delivery').then(
2502																	  function(askComplementInfo){
2503																		  if(askComplementInfo) {
2504																			  $rootScope.openModalAddress(adresse, loadCustomer, $scope.isGift, undefined, false, customer.adresses, customer, false, 'delivery', true);
2505																		  } else {
2506																			  _afterVerif();
2507																		  }
2508																	  }
2509																  );
2510															  });
2511													  } else {
2512														  customerManager.verifValiditeAdresse($scope.adresse).then(
2513															  function(formok){
2514																  if(formok){
2515																	  _afterVerif();
2516																  } else {
2517																	  $scope.adressSelectForm.alert.message.push('DICO_CONTROLLER_ADRESSE_LIVRAISON_NON_VALIDE');
2518																  }
2519															  }
2520														  );
2521													  }
2522												  }
2523											  );
2524										  };
2525
2526										  $scope.updateSelectAddress = function updateSelectAddress(){
2527											  if($scope.adressSelectForm.value){
2528												  customerManager.setDeliveryAdress($scope.adressSelectForm).then(
2529													  function(status){
2530														  if(status){
2531															  cartManager.loadCart();
2532															  $scope.adresse = $scope.adressSelectForm.value;
2533														  }
2534													  }
2535												  );
2536											  } else {
2537												  $scope.adresse = null;
2538											  }
2539										  };
2540
2541										  $scope.editAddress = function editAddress(address){
2542											  function _reload(customer){
2543												  loadCustomer(customer);
2544												  reloadDeliveryAndHide();
2545											  }
2546											  $rootScope.openModalAddress(address, _reload, address.estParrainnage, undefined, undefined, undefined, $scope.customer, false, 'delivery');
2547										  };
2548
2549										  function createSelectAdresse(customer){
2550											  var i=0,
2551												  deliveryAdresse=0;
2552											  selectAdresses=[],
2553												  ob={};
2554
2555											  for(i;i<customer.adresses.length;i++){
2556												  ob={};
2557												  ob.value = customer.adresses[i];
2558												  ob.label = customer.adresses[i].titreAdresse;
2559												  if(customer.adresses[i].estLivraison){
2560													  deliveryAdresse = i;
2561												  }
2562												  selectAdresses.push(ob);
2563											  }
2564
2565											  $scope.adressSelectForm = {};
2566											  $scope.adressSelectForm.others = {};
2567											  formulaireManager.createSelect("adresse",$scope.adressSelectForm,"DICO_CHOIX_ADRESSE",selectAdresses,false,deliveryAdresse);
2568
2569											  _addAcceptTerms($scope.adressSelectForm);
2570
2571
2572											  return deliveryAdresse;
2573										  }
2574
2575										  function _addAcceptTerms(adressSelectForm){
2576											  adressSelectForm.others.acceptterms = {};
2577											  adressSelectForm.others.acceptterms.enabled=true;
2578											  adressSelectForm.others.acceptterms.required = true;
2579											  adressSelectForm.others.acceptterms.value = false;
2580											  adressSelectForm.others.acceptterms.error = false;
2581
2582										  }
2583
2584										  function loadCustomer(customer){
2585											  console.log("loadCustomer");
2586											  $scope.customer = customer;
2587											  $scope.adressSelectForm = customerManager.getSelectedDeliveryForm(customer);
2588											  _addAcceptTerms($scope.adressSelectForm);
2589											  $scope.adresse = customerManager.getDeliveryAddress(customer);
2590											  $scope.isGift = $scope.adresse.estParrainnage;
2591										  }
2592
2593										  let _askInfo = function _askInfo(){
2594											  console.log("_askInfo");
2595											  customerManager.checkComplementInfo($scope.customer, $scope.adresse, $scope.isGift, 'delivery').then(
2596												  function(askComplementInfo){
2597													  if(askComplementInfo) {
2598														  $rootScope.openModalAddress($scope.adresse, loadCustomer, $scope.isGift, undefined, false, $scope.customer.adresses, $scope.customer, false, 'delivery', true);
2599													  }
2600												  }
2601											  );
2602										  }
2603
2604										  $rootScope.$watch('preferredLanguage',function(){
2605											  reloadDelivery(_askInfo);
2606										  });
2607
2608										  function reloadDelivery(_askInfo){
2609											  console.log("reloadDelivery");
2610											  $rootScope.spinnerShow();
2611											  reloadDeliveryAndHide(_askInfo);
2612										  }
2613
2614										  function reloadDeliveryAndHide(fAfterHide){
2615											  console.log("reloadDeliveryAndHide");
2616											  cartManager.loadCartWaiting().then(
2617												  function(){
2618													  $scope.cart = cartManager.model.cart;
2619													  $scope.tabCsPiecesJointes = [];
2620													  for(let i = 0; i < $scope.cart.lignes.length; i++) {
2621														  let ligne = $scope.cart.lignes[i];
2622														  if(ligne  !== undefined && ligne.produit !== undefined && ligne.produit.tarif !== undefined && ligne.produit.tarif.csPieceJointe != null) {
2623															  let ob = _.findWhere($scope.tabCsPiecesJointes, {refCs: ligne.produit.tarif.csPieceJointe.refCs});
2624															  if(ob === undefined){
2625																  $scope.tabCsPiecesJointes.push(ligne.produit.tarif.csPieceJointe);
2626															  }
2627														  }
2628													  }
2629													  $rootScope.spinnerHide().then(
2630														  function(){
2631															  if(fAfterHide !== undefined){
2632																  fAfterHide();
2633															  }
2634														  }
2635													  );
2636												  }
2637											  );
2638										  }
2639
2640										  $scope.uploadFile = function uploadFile(cs){
2641											  $scope.adressSelectForm.alert.message = [];
2642											  var file = document.getElementById('fichier-'+cs.refCs).files[0];
2643											  if(file !== undefined) {
2644												  if(file.size !== undefined && cs.tailleMax !== undefined && cs.tailleMax !== null && file.size > cs.tailleMax){
2645													  $scope.adressSelectForm.alert.message.push("DICO_ERREUR_TAILLE_MAXIMUM_PIECE_JOINTE_ATTEINTE#PARAM# "+(cs.tailleMax / 1000000)+"Mo");
2646													  return;
2647												  }
2648
2649												  if(file.type !== undefined && cs.typeMimeAuthorized !== undefined && cs.typeMimeAuthorized !== null && cs.typeMimeAuthorized.length > 0 && _.contains(cs.typeMimeAuthorized,file.type) == false){
2650													  $scope.adressSelectForm.alert.message.push("DICO_ERREUR_TYPE_PIECE_JOINTE");
2651													  return
2652												  }
2653												  $rootScope.spinnerShow();
2654												  const lecture = new FileReader();
2655												  lecture.onload = function(evenement){
2656													  let data = {};
2657													  data.uri = lecture.result.toString();
2658													  cartManager.uploadFileToCart(data, cs.refCs).then(
2659														  function(){
2660															  reloadDeliveryAndHide();
2661														  },
2662														  function(dico){
2663															  $scope.adressSelectForm.alert.message.push(dico);
2664															  $timeout(function() {
2665																  $rootScope.spinnerHide();
2666															  },100);
2667														  }
2668													  );
2669												  }
2670												  lecture.readAsDataURL(file);
2671											  }
2672										  }
2673
2674										  $rootScope.$watch('lastAddress',function(){
2675											  TbsWS.call('getcustomercart/'+cartManager.model.cart.id,'private').then(
2676												  function(customer){
2677													  loadCustomer(customer);
2678												  });
2679										  });
2680									  }
2681									  ,function(error) {
2682										  console.error('Affectation du client a son panier impossible');
2683									  }
2684								  );
2685
2686							  });
2687			          }
2688			          ,function(error) {
2689			              $rootScope.goPage(undefined,$rootScope.pageunauthorized);
2690			        }
2691			    );
2692				$rootScope.tryEndPage();
2693
2694		   },function(error) {
2695	              console.error("Initialisation impossible");
2696	        }
2697		);
2698	})
2699
2700	.controller('paymentCtrl', function($rootScope,$scope,commonConfig,TbsWS,cartManager,formulaireManager,customerManager,$timeout ) {
2701		$rootScope.tryInitPage($scope).then(
2702			function(data){
2703				if($rootScope.loadIsEnded == true){
2704				    $rootScope.spinnerShow();
2705				}
2706				$rootScope.isAuthorized().then(
2707			          function(access){
2708		          		$rootScope.$watch('preferredLanguage',function(){
2709			            	reloadPaiement();
2710			            });
2711
2712			            $scope.codepromoenabled = commonConfig.codepromoenabled;
2713			            $scope.deletePromotion = cartManager.deletePromotion;
2714				        $scope.applyPromoCodeClient = function applyPromoCodeClient(promoForm){
2715				        	cartManager.applyPromoCodeClient(promoForm).then(
2716				        		function(){
2717				        			$timeout(function() {
2718				        				if(promoForm.alert.message.length > 0){
2719				        					promoForm.alert.message = [];
2720				        				}
2721				        				if(promoForm.success.message.length > 0){
2722				        					promoForm.success.message = [];
2723				        				}
2724									},5000);
2725				        	});
2726				        };
2727
2728				        $scope.promocode = cartManager.getPromoCodeField();
2729
2730		            	function loadCustomer(customer){
2731			        		$scope.customer = customer;
2732			            }
2733
2734			            function reloadPaiement(){
2735					        $rootScope.spinnerShow();
2736							cartManager.loadCartWaiting().then(
2737								function(){
2738									$scope.cart = cartManager.model.cart;
2739									$timeout(function() {
2740										$rootScope.spinnerHide();
2741									},100);
2742								}
2743							);
2744			            }
2745
2746	          			customerManager.getCustomer(false).then(
2747				        	function(customer){
2748				        		if(customer !== null){
2749					        		loadCustomer(customer);
2750				        		}
2751				        });
2752			          }
2753			          ,function(error) {
2754			              $rootScope.goPage(undefined,$rootScope.pageunauthorized);
2755			        }
2756			    );
2757				$rootScope.tryEndPage();
2758
2759		   },function(error) {
2760	              console.error("Initialisation impossible");
2761	        }
2762		);
2763	})
2764
2765	.controller('paymentdetailsCtrl', function($rootScope,$scope,$filter,commonConfig,TbsWS,cartManager,formulaireManager,customerManager,paymentManager,$interval,$timeout,$location,googleTagManager,pianoManager ) {
2766		$rootScope.tryInitPage($scope).then(
2767			function(data){
2768				if($rootScope.loadIsEnded == true){
2769				    $rootScope.spinnerShow();
2770				}
2771
2772				$rootScope.isAuthorized().then(
2773			          function(access){
2774						googleTagManager.pageCategory = 'checkout';
2775						googleTagManager.checkoutStep(3);
2776						googleTagManager.checkoutEvent(cartManager.model.cart.lignes, cartManager.model.cart.totalTtc, cartManager.model.cart.id);
2777
2778		          		$rootScope.$watch('preferredLanguage',function(){
2779			            	reloadPaiementDetails();
2780			            });
2781						/* AJOUT GC - a enlever quand PAYPAL CANARDPC OK*/
2782						$scope.paypalindispo = commonConfig.paypalindispo;
2783						$scope.payboxIndispo = commonConfig.payboxIndispo;
2784						$scope.slimpayinfos = commonConfig.slimpayinfos;
2785			            $scope.buttonshow=true;
2786			            $scope.paiementsqiota = commonConfig.paiementsqiota;
2787			            $scope.tokenqiota = commonConfig.tokenqiota;
2788			            $scope.urlcbqiota = commonConfig.urlcbqiota;
2789			            $scope.validPayment = function validPayment(){
2790							cartManager.loadCartCheck().then(
2791								function() {
2792									// piano tracking — envoyé au clic, avant l'appel de paiement
2793									pianoManager.sendEvent('click.action', {
2794										click: $filter('translate')('DICO_PAYER_MA_COMMANDE'),
2795										click_chapter1: $scope.paymentForm.others.selectedcard.value,
2796										purchase_amount: parseFloat(cartManager.model.cart.totalAvecLivraisonTtc.replace(',','.')),
2797										goal_type: 'Achat'
2798									});
2799
2800					            	$scope.buttonshow=false;
2801					            	$rootScope.spinnerShow();
2802					            	var cOrderId = cartManager.model.cart.id;
2803					            	paymentManager.validPayment($scope.paymentForm).then(
2804					            		function(retour){
2805					            			$rootScope.spinnerHide().then(
2806						    					function(){
2807						    						if(retour.success){
2808						    							$location.search('status', retour.status);
2809						    							$location.search('orderId', cOrderId);
2810										        		$rootScope.goPage(undefined,'common/paymentstatus');
2811							            			} else {
2812							            				$scope.buttonshow=true;
2813							            			}
2814						    					}
2815					    					);
2816					            		});
2817								}
2818							);
2819			            };
2820			            $scope.doPaymentPaybox = function doPaymentPaybox(){
2821							cartManager.loadCartCheck().then(
2822								function() {
2823		            				paymentManager.doPaymentPaybox($scope.paymentForm);
2824								}
2825							);
2826			            };
2827
2828			            $scope.codepromoenabled = commonConfig.codepromoenabled;
2829
2830			            $scope.deletePromotion = function deletePromotion(typeCodePromo){
2831			            	cartManager.deletePromotion(typeCodePromo).then(
2832			  			          function(){
2833			  			        	reloadPaiementDetails();
2834			  			          }
2835			  			          ,function(error) {
2836			  			        }
2837			  			    );
2838
2839			            }
2840
2841				        $scope.applyPromoCodeClient = function applyPromoCodeClient(promoForm){
2842				        	cartManager.applyPromoCodeClient(promoForm).then(
2843				        		function(){
2844				        			if(promoForm.success.message.length > 0){
2845				        				reloadPaiementDetails();
2846				        			}
2847				        			$timeout(function() {
2848				        				if(promoForm.alert.message.length > 0){
2849				        					promoForm.alert.message = [];
2850				        				}
2851				        				if(promoForm.success.message.length > 0){
2852				        					promoForm.success.message = [];
2853				        				}
2854									},5000);
2855				        	});
2856				        };
2857
2858				        $scope.promocode = cartManager.getPromoCodeField();
2859				        $scope.reloadPaimentInProgress = false;
2860				        $scope.refreshCart = true;
2861
2862				        $scope.$watch("cart",function(newval, oldval,scope){
2863				          if($scope !== undefined && $scope.reloadPaimentInProgress == false && $scope.refreshCart == true){
2864				        	reloadPaiementDetails();
2865				          }
2866				          if($scope.refreshCart == false) {
2867				        	$scope.refreshCart == true;
2868				          }
2869			        	}, true);
2870
2871			            function reloadPaiementDetails(){
2872				        	$scope.reloadPaimentInProgress = true;
2873							$scope.messageErreur = "";
2874
2875			            	$rootScope.spinnerShow();
2876							cartManager.loadCartWaiting().then(
2877								function(){
2878									$scope.paymentForm = {};
2879									$scope.cart = cartManager.model.cart;
2880
2881									paymentManager.getListPayment().then(
2882							        	function(listForm){
2883							        		$scope.changeTypePayment = function changeTypePayment(typePaiement){
2884							        			paymentManager.getPaymentForm(typePaiement,$scope.paymentForm);
2885							        			$scope.refreshCart = false;
2886							        			cartManager.setOffersPayment(typePaiement);
2887							        		};
2888							        		$scope.listForm = listForm;
2889							        		if (listForm.fields[0] !== undefined) {
2890												$scope.changeTypePayment(listForm.fields[0]);
2891											} else {
2892												$rootScope.openModalInformation('DICO_INFORMATION', 'DICO_INFORMATION_AUCUN_MOYEN_DE_PAIEMENT_COMPATIBLE');
2893											}
2894											$timeout(function() {
2895												$rootScope.spinnerHide();
2896												$scope.reloadPaimentInProgress = false;
2897											},100);
2898							        },function(message){
2899										$scope.paymentForm = {};
2900										$scope.listForm = {};
2901										$scope.messageErreur = message;
2902										$rootScope.spinnerHide();
2903										$scope.reloadPaimentInProgress = false;
2904							        });
2905								}
2906							);
2907			            }
2908			          }
2909			          ,function(error) {
2910			        	  $rootScope.goPage(undefined,'common/login');
2911			        }
2912			    );
2913				$rootScope.tryEndPage();
2914
2915		   },function(error) {
2916	              console.error("Initialisation impossible");
2917	        }
2918		);
2919	})
2920
2921	.controller('shopcloseCtrl', function($rootScope) {
2922        $rootScope.appisclose = true;
2923        $rootScope.appisready = false;
2924	})
2925
2926	.controller('homewaitCtrl', function($rootScope, $scope, $location, TbsWS, $timeout, $window) {
2927		if($rootScope.authorizeUrlRedirect) {
2928			$window.location.href = $rootScope.authorizeUrlRedirect;
2929			$rootScope.authorizeUrlRedirect = undefined;
2930		} else {
2931			console.log('homewaitCtrl');
2932			let ignoreAuthorize = true;
2933			$rootScope.tryInitPage($scope,ignoreAuthorize).then(
2934				function(data){
2935					$timeout(function() {
2936						console.log("initialisation controller");
2937						$rootScope.initWaitControllerOk=true;
2938						$rootScope.initAfterRunning();
2939					},10);
2940				},function(error) {
2941					console.error("Initialisation impossible");
2942				}
2943			);
2944		}
2945	})
2946
2947	.controller('homeCtrl', function($rootScope, $scope, Auth, $interval, commonConfig, $location, categoriesManager, utils, TbsWS, googleTagManager) {
2948		$rootScope.tryInitPage($scope).then(
2949			function(data){
2950				TbsWS.canAccess().then(
2951					function(){
2952						googleTagManager.pageCategory = 'home';
2953
2954						delete $rootScope.categoryBreadcrumb;
2955						var protocol = $location.protocol();
2956						$scope.adsenable = false;
2957						if(protocol == 'http'){
2958							$scope.adsenable = true;
2959						}
2960
2961						$scope.sliderone = commonConfig.sliderone;
2962						$scope.slidertwo = commonConfig.slidertwo;
2963						$scope.banniere = commonConfig.banniere;
2964						$scope.sliderTop = commonConfig.sliderTop;
2965						$scope.sliderBottom = commonConfig.sliderBottom;
2966						$scope.categorieshomeselect = commonConfig.categorieshomeselect;
2967						$scope.categorieshomelink =commonConfig.categorieshomelink;
2968						$scope.categorieshomeparent = commonConfig.categorieshomeparent;
2969						$scope.hideWishList = commonConfig.hideWishList;
2970						$scope.displayHomeCategoriesListBottom = commonConfig.displayHomeCategoriesListBottom;
2971						$scope.hideFiltersCategoriesButton = commonConfig.hideFiltersCategoriesButton;
2972
2973						$scope.categorieslist = [];
2974
2975						$scope.categorieshome = false;
2976
2977						$rootScope.$watch('preferredLanguage',function(){
2978							_reloadCategories();
2979						});
2980
2981						function _reloadCategories(){
2982
2983							if(commonConfig.headerconf.block.categorieshome){
2984								categoriesManager.buildCategoriesList('structure/filtrecategories.json').then(
2985									function(data){
2986										$scope.categoriesbutton = data.categoriesbutton;
2987										$scope.categorieslist = data.categories;
2988										$scope.allsorts = data.allsorts;
2989										$scope.categorieshome = true;
2990									}
2991									,function(error) {
2992										console.error(error);
2993									}
2994								);
2995							}
2996						}
2997						_reloadCategories();
2998
2999						$scope.framehref = "../../common/content/frame/pub.html?v="+commonConfig.forceversion;
3000
3001						if(commonConfig.privateshop == false){
3002							Auth.displayMessageIfWasConnecte();
3003						}
3004
3005						if($rootScope.createAccountMessage){
3006							$rootScope.createAccountMessage=false;
3007							function updateTime(){
3008		    					if (typeof $rootScope.openModalInformation === 'function') {
3009									$rootScope.openModalInformation( "DICO_CONTROLLER_CREATION_COMPTE_TITRE", $rootScope.createAccountMessageStr);
3010									$interval.cancel(stopTime);
3011								}
3012		    				}
3013		    				var stopTime = $interval(updateTime, 50);
3014						}
3015					}
3016					,function(error) {
3017		        	  $rootScope.goPage(undefined,'common/login');
3018					}
3019			    );
3020				$rootScope.tryEndPage();
3021		   },function(error) {
3022	              console.error("Initialisation impossible");
3023	        }
3024		);
3025	})
3026
3027	.controller('logingetemailpwdCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter) {
3028		$rootScope.tryInitPage($scope).then(
3029			function(data){
3030				$scope.newEmailForm = customerManager.getSetEmailPasswordForm();
3031
3032				$scope.titrePage = "";
3033	          	$scope.contentPage = "";
3034				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/logingetemailpwd','public').then(
3035			          function(data){
3036			          	if(data && data !== ""){
3037			          		$scope.titrePage = data.titrePage;
3038				          	$scope.contentPage = data.contentPage;
3039			          	} else {
3040			          		$scope.titrePage = $filter('translate')("Unvailable content");
3041			          	}
3042			          }
3043			          ,function(error) {
3044			          	console.error(error);
3045			        }
3046			    );
3047
3048				var goToLogin = function goToLogin(){
3049					$rootScope.goPage(undefined,'common/login');
3050				};
3051				$scope.hideeditbutton=false;
3052				$scope.updatelogin = function(newEmailForm){
3053					$rootScope.spinnerShow();
3054					customerManager.updateLogin(newEmailForm).then(
3055						function(status){
3056	            			$rootScope.spinnerHide().then(
3057		    					function(){
3058		    						if(status){
3059		    							$scope.hideeditbutton=true;
3060										$rootScope.openModalYesNo( "DICO_INFORMATION", "DICO_GETEMAIL_CONNEXION_POSSIBLE", undefined, goToLogin, "", "DICO_OK");
3061									}
3062		    					}
3063	    					);
3064						}
3065					);
3066				};
3067				$rootScope.tryEndPage();
3068
3069
3070		   },function(error) {
3071	              console.error("Initialisation impossible");
3072	        }
3073		);
3074	})
3075
3076	.controller('logingetemailCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter) {
3077		$rootScope.tryInitPage($scope).then(
3078			function(data){
3079				$scope.newEmailForm = customerManager.getSetEmailForm();
3080
3081				$scope.titrePage = "";
3082	          	$scope.contentPage = "";
3083				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/logingetemail','public').then(
3084			          function(data){
3085			          	if(data && data !== ""){
3086			          		$scope.titrePage = data.titrePage;
3087				          	$scope.contentPage = data.contentPage;
3088			          	} else {
3089			          		$scope.titrePage = $filter('translate')("Unvailable content");
3090			          	}
3091			          }
3092			          ,function(error) {
3093			          	console.error(error);
3094			        }
3095			    );
3096
3097				var goToLogin = function goToLogin(){
3098					$rootScope.goPage(undefined,'common/login');
3099				};
3100				$scope.hideeditbutton=false;
3101				$scope.updatelogin = function(newEmailForm){
3102					$rootScope.spinnerShow();
3103					customerManager.updateLogin(newEmailForm).then(
3104						function(status){
3105	            			$rootScope.spinnerHide().then(
3106		    					function(){
3107		    						if(status){
3108		    							$scope.hideeditbutton=true;
3109										$rootScope.openModalYesNo( "DICO_INFORMATION", "DICO_GETEMAIL_CONNEXION_POSSIBLE", undefined, goToLogin, "", "DICO_OK");
3110									}
3111		    					}
3112	    					);
3113						}
3114					);
3115				};
3116				$rootScope.tryEndPage();
3117
3118
3119		   },function(error) {
3120	              console.error("Initialisation impossible");
3121	        }
3122		);
3123	})
3124
3125	.controller('logingetpasswordCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter) {
3126		$rootScope.tryInitPage($scope).then(
3127			function(data){
3128				$scope.newEmailForm = customerManager.getSendEmailForm();
3129
3130				$scope.titrePage = "";
3131	          	$scope.contentPage = "";
3132				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/logingetpassword','public').then(
3133			          function(data){
3134			          	if(data && data !== ""){
3135			          		$scope.titrePage = data.titrePage;
3136				          	$scope.contentPage = data.contentPage;
3137			          	} else {
3138			          		$scope.titrePage = $filter('translate')("Unvailable content");
3139			          	}
3140			          }
3141			          ,function(error) {
3142			          	console.error(error);
3143			        }
3144			    );
3145
3146				var goToLogin = function goToLogin(){
3147					$rootScope.goPage(undefined,'common/login');
3148				};
3149				$scope.hideeditbutton=false;
3150				$scope.sendEmaillogin = function(newEmailForm){
3151					$rootScope.spinnerShow();
3152					customerManager.askPassword(newEmailForm).then(
3153						function(status){
3154	            			$rootScope.spinnerHide().then(
3155		    					function(){
3156		    						if(status){
3157		    							$scope.hideeditbutton=true;
3158		    							$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_DIRECTIVE_MAIL_ENVOYE", 4000 );
3159									}
3160		    					}
3161	    					);
3162						}
3163					);
3164				};
3165
3166				$scope.showPassword = function showPassword(event, uniqname) {
3167					if (document.getElementsByName(uniqname).length == 1) {
3168						const type = document.getElementsByName(uniqname)[0].type;
3169						if (type == 'password') {
3170							document.getElementsByName(uniqname)[0].type = 'text';
3171							event.target.className = 'glyphicon glyphicon-eye-close';
3172						} else {
3173							document.getElementsByName(uniqname)[0].type = 'password';
3174							event.target.className = 'glyphicon glyphicon-eye-open';
3175						}
3176					}
3177				};
3178				$rootScope.tryEndPage();
3179
3180
3181		   },function(error) {
3182	              console.error("Initialisation impossible");
3183	        }
3184		);
3185	})
3186
3187	.controller('passwordnonconformeCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter, formulaireManager) {
3188		$rootScope.tryInitPage($scope).then(
3189			function(data){
3190				$scope.newEmailForm = customerManager.getSendEmailForm(false, true);
3191
3192				$scope.titrePage = "";
3193				$scope.contentPage = "";
3194				//$scope.directivePage = "test";
3195
3196				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/passwordnonconforme','public').then(
3197					function(data){
3198						if(data && data !== ""){
3199							$scope.titrePage = data.titrePage;
3200							$scope.contentPage = data.contentPage;
3201						} else {
3202							$scope.titrePage = $filter('translate')("Unvailable content");
3203						}
3204					}
3205					,function(error) {
3206						console.error(error);
3207					}
3208				);
3209
3210				$scope.hideeditbutton=false;
3211				$scope.sendEmailRenewPassword = function(){
3212					$rootScope.spinnerShow();
3213					customerManager.sendEmailLinkRenewPassword($scope.newEmailForm).then(
3214						function(status){
3215							$rootScope.spinnerHide().then(
3216								function(){
3217									if(status){
3218										$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_DIRECTIVE_MAIL_ENVOYE", 4000 );
3219									}
3220								}
3221							);
3222						}
3223					);
3224				};
3225
3226				$scope.showPassword = function showPassword(event, uniqname) {
3227					if (document.getElementsByName(uniqname).length == 1) {
3228						const type = document.getElementsByName(uniqname)[0].type;
3229						if (type == 'password') {
3230							document.getElementsByName(uniqname)[0].type = 'text';
3231							event.target.className = 'glyphicon glyphicon-eye-close';
3232						} else {
3233							document.getElementsByName(uniqname)[0].type = 'password';
3234							event.target.className = 'glyphicon glyphicon-eye-open';
3235						}
3236					}
3237				};
3238				$rootScope.tryEndPage();
3239
3240
3241			},function(error) {
3242				console.error("Initialisation impossible");
3243			}
3244		);
3245	})
3246
3247	.controller('passwordexpiredCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter, formulaireManager) {
3248		$rootScope.tryInitPage($scope).then(
3249			function(data){
3250				$scope.newEmailForm = customerManager.getSendEmailForm(false, true);
3251
3252				$scope.titrePage = "";
3253				$scope.contentPage = "";
3254				//$scope.directivePage = "test";
3255
3256				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/passwordexpired','public').then(
3257					function(data){
3258						if(data && data !== ""){
3259							$scope.titrePage = data.titrePage;
3260							$scope.contentPage = data.contentPage;
3261						} else {
3262							$scope.titrePage = $filter('translate')("Unvailable content");
3263						}
3264					}
3265					,function(error) {
3266						console.error(error);
3267					}
3268				);
3269
3270				$scope.hideeditbutton=false;
3271				$scope.sendEmailRenewPassword = function(){
3272					$rootScope.spinnerShow();
3273					customerManager.sendEmailLinkRenewPassword($scope.newEmailForm).then(
3274						function(status){
3275							$rootScope.spinnerHide().then(
3276								function(){
3277									if(status){
3278										$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_DIRECTIVE_MAIL_ENVOYE", 4000 );
3279									}
3280								}
3281							);
3282						}
3283					);
3284				};
3285				$rootScope.tryEndPage();
3286
3287
3288			},function(error) {
3289				console.error("Initialisation impossible");
3290			}
3291		);
3292	})
3293
3294	.controller('updatepasswordCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter, $stateParams) {
3295		$rootScope.tryInitPage($scope).then(
3296			function(data){
3297				let jeton = $stateParams.JETON;
3298				TbsWS.canAccessJeton(jeton).then(
3299					function(result){
3300						$scope.sendEmailRenewPassword = function(){
3301							$rootScope.spinnerShow();
3302							customerManager.sendmEmailLinkRenewPassword($scope.newEmailForm).then(
3303								function(status){
3304									$rootScope.spinnerHide().then(
3305										function(){
3306											if(status){
3307												$rootScope.openModalInformation( "DICO_INFORMATION", "DICO_DIRECTIVE_MAIL_ENVOYE", 4000 );
3308											}
3309										}
3310									);
3311								}
3312							);
3313						};
3314
3315						let processError = function processError(result) {
3316							console.log(result);
3317							$scope.newEmailForm = customerManager.getSendEmailForm(false, true);
3318							if(result.data === customerManager.LIEN_EXPIRE) {
3319								$scope.errorMessage = "DICO_UPDATE_PWD_LIEN_EXPIRE"
3320							} else {
3321								$scope.errorMessage = "DICO_UPDATE_PWD_ERROR"
3322							}
3323						};
3324
3325						$scope.titrePage = "";
3326						$scope.contentPage = "";
3327						$scope.directivePage = "";
3328
3329						TbsWS.call('getpage/' + $rootScope.preferredLanguage + '/updatepassword', 'public').then(
3330							function (data) {
3331								if (data && data !== "") {
3332									$scope.titrePage = data.titrePage;
3333									$scope.contentPage = data.contentPage;
3334								} else {
3335									$scope.titrePage = $filter('translate')("Unvailable content");
3336								}
3337							}
3338							, function (error) {
3339								console.error(error);
3340							}
3341						);
3342
3343						if(result && result.error) {
3344							processError(result);
3345						} else {
3346							$scope.newEmailForm = customerManager.getModifyPasswordForm(result.data, jeton);
3347							TbsWS.call('infopassword/' + $rootScope.preferredLanguage, 'public').then(
3348								function (data) {
3349									if (data && data.message && data.message !== "") {
3350										$scope.directivePage = data.message;
3351									}
3352								}
3353								, function (error) {
3354									console.error(error);
3355								}
3356							);
3357							let goToLogin = function goToLogin(){
3358								$rootScope.goPage(undefined,'common/login');
3359							};
3360							$scope.updatelogin = function (newEmailForm) {
3361								$rootScope.spinnerShow();
3362								customerManager.updateLogin(newEmailForm).then(
3363									function (status) {
3364										if (!status) {
3365											let result = {};
3366											if(newEmailForm.alert.message.length == 1 && newEmailForm.alert.message[0] === customerManager.LIEN_EXPIRE) {
3367												result.data = newEmailForm.alert.message[0];
3368												processError(result);
3369											}
3370										}
3371										$rootScope.spinnerHide().then(
3372											function () {
3373												if (status) {
3374													$scope.hideeditbutton=true;
3375													$rootScope.openModalYesNo("DICO_INFORMATION", "DICO_GETEMAIL_CONNEXION_POSSIBLE", undefined, goToLogin, "", "DICO_OK");
3376												}
3377											}
3378										);
3379									}
3380								);
3381							};
3382						}
3383					}
3384				);
3385				$rootScope.tryEndPage();
3386
3387			},function(error) {
3388				console.error("Initialisation impossible");
3389			}
3390		);
3391	})
3392
3393	.controller('logingetpasswordcpCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter) {
3394		$rootScope.tryInitPage($scope).then(
3395			function(data){
3396				$scope.newEmailForm = customerManager.getSetPasswordForm();
3397
3398				$scope.titrePage = "";
3399	          	$scope.contentPage = "";
3400				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/logingetpasswordcp','public').then(
3401			          function(data){
3402			          	if(data && data !== ""){
3403			          		$scope.titrePage = data.titrePage;
3404				          	$scope.contentPage = data.contentPage;
3405			          	} else {
3406			          		$scope.titrePage = $filter('translate')("Unvailable content");
3407			          	}
3408			          }
3409			          ,function(error) {
3410			          	console.error(error);
3411			        }
3412			    );
3413
3414				var goToLogin = function goToLogin(){
3415					$rootScope.goPage(undefined,'common/login');
3416				};
3417				$scope.hideeditbutton=false;
3418				$scope.updatelogin = function(newEmailForm){
3419					$rootScope.spinnerShow();
3420					customerManager.updateLogin(newEmailForm).then(
3421						function(status){
3422	            			$rootScope.spinnerHide().then(
3423		    					function(){
3424		    						if(status){
3425		    							$scope.hideeditbutton=true;
3426										$rootScope.openModalYesNo( "DICO_INFORMATION", "DICO_GETEMAIL_CONNEXION_POSSIBLE", undefined, goToLogin, "", "DICO_OK");
3427									}
3428		    					}
3429	    					);
3430						}
3431					);
3432				};
3433				$rootScope.tryEndPage();
3434
3435
3436		   },function(error) {
3437	              console.error("Initialisation impossible");
3438	        }
3439		);
3440	})
3441
3442	.controller('logininfoCtrl', function($rootScope, $scope, customerManager, TbsWS, $filter) {
3443		$rootScope.tryInitPage($scope).then(
3444			function(data){
3445				$scope.newEmailForm = customerManager.getEmailForm();
3446
3447				$scope.titrePage = "";
3448	          	$scope.contentPage = "";
3449				TbsWS.call('getpage/'+ $rootScope.preferredLanguage +'/logininfo','public').then(
3450			          function(data){
3451			          	if(data && data !== ""){
3452			          		$scope.titrePage = data.titrePage;
3453				          	$scope.contentPage = data.contentPage;
3454			          	} else {
3455			          		$scope.titrePage = $filter('translate')("Unvailable content");
3456			          	}
3457			          }
3458			          ,function(error) {
3459			          	console.error(error);
3460			        }
3461			    );
3462				$rootScope.tryEndPage();
3463
3464
3465		   },function(error) {
3466	              console.error("Initialisation impossible");
3467	        }
3468		);
3469	})
3470
3471	.controller('404Ctrl', function($state, $stateParams, $rootScope, $scope, $localStorageGlobal, commonConfig, $timeout, TbsWS) {
3472		$("div[ui-view='error']").show();
3473		$rootScope.displaymessage=true;
3474		$rootScope.display404=true;
3475
3476		$rootScope.preferredLanguage = $localStorageGlobal.preferredLanguage || commonConfig.currentInstance.langue;
3477
3478		TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
3479       .then(function(dico){
3480        	$('title').html("404 | "+ dico["title"]["title"]);
3481
3482			$scope.thispagenotexists = dico["404"]["thispagenotexists"];
3483			$scope.sorry = dico["404"]["sorry"];
3484			$scope.gohome = dico["404"]["gohome"];
3485			$scope.logoimg = $rootScope.logoimg;
3486        });
3487	})
3488
3489	.contr
3489oller('adminCtrl', function($state, $stateParams, $rootScope, $scope, $localStorageGlobal, commonConfig, $timeout, TbsWS) {
3490		$("div[ui-view='error']").show();
3491		$rootScope.displaymessage=true;
3492		$rootScope.display404=false;
3493		$rootScope.preferredLanguage = $localStorageGlobal.preferredLanguage || commonConfig.currentInstance.langue;
3494
3495
3496		TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
3497       .then(function(dico){
3498        	$('title').html(dico["admin"]["title"]+" | "+ dico["title"]["title"]);
3499
3500			$scope.thispagenotexists = dico["404"]["thispagenotexists"];
3501			$scope.admin = dico["admin"]["admin"];
3502			$scope.sorry = dico["admin"]["sorry"];
3503			$scope.gohome = dico["admin"]["gohome"];
3504			$scope.logoimg = $rootScope.logoimg;
3505
3506			$scope.linkGohomeSpecifique=false;
3507			if (commonConfig.linkGohomeMaintenance !== undefined){
3508				$scope.linkGohomeSpecifique=true;
3509				$scope.linkGohome=commonConfig.linkGohomeMaintenance;
3510			}
3511
3512        });
3513	})
3514
3515	.controller('errorCtrl', function($state, $stateParams, $rootScope, $scope, $localStorageGlobal, commonConfig, $timeout, TbsWS) {
3516		$("div[ui-view='error']").show();
3517		$rootScope.display404=false;
3518		$scope.showdetail=false;
3519		$rootScope.preferredLanguage = $localStorageGlobal.preferredLanguage || commonConfig.currentInstance.langue;
3520
3521		TbsWS.getJson("dico/"+$rootScope.preferredLanguage+'.json')
3522       .then(function(dico){
3523        	$('title').html(dico["error"]["title"]+" | "+ dico["title"]["title"]);
3524
3525			$scope.thispagenotexists = dico["404"]["thispagenotexists"];
3526			$scope.admin = dico["error"]["admin"];
3527			$scope.sorry = dico["error"]["sorry"];
3528			$scope.gohome = dico["error"]["gohome"];
3529			$scope.logoimg = $rootScope.logoimg;
3530			$scope.showdetail=false;
3531        });
3532	})
3533
3534	.controller('sitemapCtrl', function($state, $stateParams, $rootScope, $scope, $localStorageGlobal, commonConfig, $timeout, TbsWS) {
3535		$rootScope.displaysitemap=true;
3536	})
3537
3538    // config speciale pour faire du loading de controller a la demande
3539    .config(function($controllerProvider, $compileProvider, $filterProvider, $provide)
3540    {
3541        AboShopApp.controllerProvider = $controllerProvider;
3542        AboShopApp.compileProvider    = $compileProvider;
3543
3544        AboShopApp.filterProvider     = $filterProvider;
3545        AboShopApp.provide            = $provide;
3546
3547    })
3548
3549
3550    // Module de Traduction
3551    .config(function ($translateProvider) {
3552      $translateProvider.translations('fr', {
3553        TITLE: 'Salut',
3554        VARIANTS: 'Variantes',
3555        FOO: 'Ceci est un paragraphe.',
3556        BUTTON_LANG_FR: 'français',
3557        BUTTON_LANG_EN: 'anglais',
3558        BUTTON_LANG_DE: 'allemand',
3559        SEULEMENTFR: 'Ceci est une phrase uniquement en Français'
3560      });
3561      $translateProvider.translations('en', {
3562        TITLE: 'Hello',
3563        VARIANTS: 'Variants',
3564        FOO: 'This is a paragraph.',
3565        BUTTON_LANG_FR: 'french',
3566        BUTTON_LANG_EN: 'english',
3567        BUTTON_LANG_DE: 'german',
3568      });
3569      $translateProvider.translations('de', {
3570        TITLE: 'Hallo',
3571        VARIANTS: 'Varianten',
3572        FOO: 'Dies ist ein Paragraph.',
3573        BUTTON_LANG_FR: 'französisch',
3574        BUTTON_LANG_EN: 'englisch',
3575        BUTTON_LANG_DE: 'deutsch'
3576      });
3577      $translateProvider.preferredLanguage('fr');
3578      $translateProvider.fallbackLanguage('fr');
3579      $translateProvider.useMissingTranslationHandlerLog();
3580    })
3581
3582    .config(function ($localStorageProvider, $sessionStorageProvider) {
3583    		$localStorageProvider.setPrefix('aboshop');
3584		    $sessionStorageProvider.setPrefix('aboshop');
3585	})
3586
3587
3588    .directive('cfcroxn', function() {
3589        return {
3590          restrict: 'E',
3591          templateUrl: 'directives/cronbuttons.html'
3592        };
3593    })
3594
3595	.directive('popbox', ['$parse', function($parse) {
3596		return {
3597		  restrict: 'A',
3598		  link : function(scope, el, attrs){
3599			var $el = $(el);
3600			var cls;
3601			var direction = attrs.popboxDirection || 'down';
3602
3603			var updateElement = function(value) {
3604			  cls.setText(value);
3605			};
3606
3607			$el.popbox({
3608			  direction: direction
3609			});
3610			cls = $el.data('popbox');
3611
3612			attrs.$observe('popbox', function(newValue) {
3613			  updateElement(newValue);
3614			});
3615
3616			if (attrs.popboxClick) {
3617			  var clickedFn = $parse(attrs.popboxClick);
3618			  $el.on('popboxClick', function() {
3619				scope.$apply(function() {
3620				  clickedFn(scope, {});
3621				});
3622			  });
3623			}
3624
3625
3626			var destroyDirective = function(){
3627			  if (cls){
3628				cls.destroy();
3629				cls = null;
3630			  }
3631			};
3632
3633			scope.$on('$destroy', destroyDirective);
3634			el.one('$destroy', destroyDirective);
3635		  }
3636		};
3637	}])
3638	.config(["$provide", function ($provide) {
3639		$provide.decorator("$exceptionHandler", $exceptionHandler);
3640		$exceptionHandler.$inject = ['$delegate', '$injector'];
3641
3642		function $exceptionHandler($delegate, $injector) {
3643			return function(exception, cause) {
3644				$delegate(exception, cause);
3645				let TbsWS = $injector.get('TbsWS');
3646				TbsWS.addError(exception);
3647			};
3648		}
3649	}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.