From c69ebd101e8dd5a4b4bb36bdf2803633bb3ef8fe Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 11 May 2012 08:20:02 +0000 Subject: [PATCH 01/21] Ajout librairie Qtip --- public/libs/qtip/jquery.qtip.css | 1 + public/libs/qtip/jquery.qtip.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 public/libs/qtip/jquery.qtip.css create mode 100644 public/libs/qtip/jquery.qtip.js diff --git a/public/libs/qtip/jquery.qtip.css b/public/libs/qtip/jquery.qtip.css new file mode 100644 index 00000000..947c8f9d --- /dev/null +++ b/public/libs/qtip/jquery.qtip.css @@ -0,0 +1 @@ +.ui-tooltip,.qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;}.ui-tooltip-fluid{display:block;visibility:hidden;position:static!important;float:left!important;}.ui-tooltip-content{position:relative;padding:5px 9px;overflow:hidden;border:1px solid #000001;text-align:left;word-wrap:break-word;overflow:hidden;}.ui-tooltip-titlebar{position:relative;min-height:14px;padding:5px 35px 5px 10px;overflow:hidden;border:1px solid #000001;border-width:1px 1px 0;font-weight:bold;}.ui-tooltip-titlebar+.ui-tooltip-content{border-top-width:0!important;}/*!Default close button class */ .ui-tooltip-titlebar .ui-state-default{position:absolute;right:4px;top:50%;margin-top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;}* html .ui-tooltip-titlebar .ui-state-default{top:16px;}.ui-tooltip-titlebar .ui-icon,.ui-tooltip-icon .ui-icon{display:block;text-indent:-1000em;}.ui-tooltip-icon,.ui-tooltip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;}.ui-tooltip-icon .ui-icon{width:18px;height:14px;text-align:center;text-indent:0;font:normal bold 10px/13px Tahoma,sans-serif;color:inherit;background:transparent none no-repeat -100em -100em;}/*!Default tooltip style */ .ui-tooltip-default .ui-tooltip-titlebar,.ui-tooltip-default .ui-tooltip-content{border-color:#F1D031;background-color:#FFFFA3;color:#555;}.ui-tooltip-default .ui-tooltip-titlebar{background-color:#FFEF93;}.ui-tooltip-default .ui-tooltip-icon{border-color:#CCC;background:#F1F1F1;color:#777;}.ui-tooltip-default .ui-tooltip-titlebar .ui-state-hover{border-color:#AAA;color:#111;}.ui-tooltip .ui-tooltip-tip{margin:0 auto;overflow:hidden;z-index:10;}.ui-tooltip .ui-tooltip-tip,.ui-tooltip .ui-tooltip-tip *{position:absolute;line-height:.1px!important;font-size:.1px!important;color:#123456;background:transparent;border:0 dashed transparent;}.ui-tooltip .ui-tooltip-tip canvas{top:0;left:0;}#qtip-overlay{position:fixed;left:-10000em;top:-10000em;}#qtip-overlay.blurs{cursor:pointer;}#qtip-overlay div{position:absolute;left:0;top:0;width:100%;height:100%;background-color:black;opacity:.7;filter:alpha(opacity=70);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";}/*!Light tooltip style */ .ui-tooltip-light .ui-tooltip-titlebar,.ui-tooltip-light .ui-tooltip-content{border-color:#E2E2E2;color:#454545;}.ui-tooltip-light .ui-tooltip-content{background-color:white;}.ui-tooltip-light .ui-tooltip-titlebar{background-color:#f1f1f1;}/*!Dark tooltip style */ .ui-tooltip-dark .ui-tooltip-titlebar,.ui-tooltip-dark .ui-tooltip-content{border-color:#303030;color:#f3f3f3;}.ui-tooltip-dark .ui-tooltip-content{background-color:#505050;}.ui-tooltip-dark .ui-tooltip-titlebar{background-color:#404040;}.ui-tooltip-dark .ui-tooltip-icon{border-color:#444;}.ui-tooltip-dark .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}/*!Cream tooltip style */ .ui-tooltip-cream .ui-tooltip-titlebar,.ui-tooltip-cream .ui-tooltip-content{border-color:#F9E98E;color:#A27D35;}.ui-tooltip-cream .ui-tooltip-content{background-color:#FBF7AA;}.ui-tooltip-cream .ui-tooltip-titlebar{background-color:#F0DE7D;}.ui-tooltip-cream .ui-state-default .ui-tooltip-icon{background-position:-82px 0;}/*!Red tooltip style */ .ui-tooltip-red .ui-tooltip-titlebar,.ui-tooltip-red .ui-tooltip-content{border-color:#D95252;color:#912323;}.ui-tooltip-red .ui-tooltip-content{background-color:#F78B83;}.ui-tooltip-red .ui-tooltip-titlebar{background-color:#F06D65;}.ui-tooltip-red .ui-state-default .ui-tooltip-icon{background-position:-102px 0;}.ui-tooltip-red .ui-tooltip-icon{border-color:#D95252;}.ui-tooltip-red .ui-tooltip-titlebar .ui-state-hover{border-color:#D95252;}/*!Green tooltip style */ .ui-tooltip-green .ui-tooltip-titlebar,.ui-tooltip-green .ui-tooltip-content{border-color:#90D93F;color:#3F6219;}.ui-tooltip-green .ui-tooltip-content{background-color:#CAED9E;}.ui-tooltip-green .ui-tooltip-titlebar{background-color:#B0DE78;}.ui-tooltip-green .ui-state-default .ui-tooltip-icon{background-position:-42px 0;}/*!Blue tooltip style */ .ui-tooltip-blue .ui-tooltip-titlebar,.ui-tooltip-blue .ui-tooltip-content{border-color:#ADD9ED;color:#5E99BD;}.ui-tooltip-blue .ui-tooltip-content{background-color:#E5F6FE;}.ui-tooltip-blue .ui-tooltip-titlebar{background-color:#D0E9F5;}.ui-tooltip-blue .ui-state-default .ui-tooltip-icon{background-position:-2px 0;}/*!Add shadows to your tooltips in:FF3+,Chrome 2+,Opera 10.6+,IE6+,Safari 2+*/ .ui-tooltip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);}.ui-tooltip-shadow .ui-tooltip-titlebar,.ui-tooltip-shadow .ui-tooltip-content{filter:progid:DXImageTransform.Microsoft.Shadow(Color='gray',Direction=135,Strength=3);-ms-filter:"progid:DXImageTransform.Microsoft.Shadow(Color='gray',Direction=135,Strength=3)";_margin-bottom:-3px;.margin-bottom:-3px;}/*!Add rounded corners to your tooltips in:FF3+,Chrome 2+,Opera 10.6+,IE9+,Safari 2+*/ .ui-tooltip-rounded,.ui-tooltip-rounded .ui-tooltip-content,.ui-tooltip-tipsy,.ui-tooltip-tipsy .ui-tooltip-content,.ui-tooltip-youtube,.ui-tooltip-youtube .ui-tooltip-content{-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;}.ui-tooltip-rounded .ui-tooltip-titlebar,.ui-tooltip-tipsy .ui-tooltip-titlebar,.ui-tooltip-youtube .ui-tooltip-titlebar{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0;}.ui-tooltip-rounded .ui-tooltip-titlebar+.ui-tooltip-content,.ui-tooltip-tipsy .ui-tooltip-titlebar+.ui-tooltip-content,.ui-tooltip-youtube .ui-tooltip-titlebar+.ui-tooltip-content{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px;}/*!Youtube tooltip style */ .ui-tooltip-youtube{-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;}.ui-tooltip-youtube .ui-tooltip-titlebar,.ui-tooltip-youtube .ui-tooltip-content{_margin-bottom:0;.margin-bottom:0;background:transparent;background:rgba(0,0,0,0.85);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000)";color:white;border-color:#CCC;}.ui-tooltip-youtube .ui-tooltip-icon{border-color:#222;}.ui-tooltip-youtube .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}.ui-tooltip-jtools{background:#232323;background:rgba(0,0,0,0.7);background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333;}.ui-tooltip-jtools .ui-tooltip-titlebar{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171,endColorstr=#4A4A4A)";}.ui-tooltip-jtools .ui-tooltip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A,endColorstr=#232323)";}.ui-tooltip-jtools .ui-tooltip-titlebar,.ui-tooltip-jtools .ui-tooltip-content{background:transparent;color:white;border:0 dashed transparent;}.ui-tooltip-jtools .ui-tooltip-icon{border-color:#555;}.ui-tooltip-jtools .ui-tooltip-titlebar .ui-state-hover{border-color:#333;}.ui-tooltip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,0.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,0.4);box-shadow:4px 4px 5px rgba(0,0,0,0.4);}.ui-tooltip-cluetip .ui-tooltip-titlebar{background-color:#87876A;color:white;border:0 dashed transparent;}.ui-tooltip-cluetip .ui-tooltip-content{background-color:#D9D9C2;color:#111;border:0 dashed transparent;}.ui-tooltip-cluetip .ui-tooltip-icon{border-color:#808064;}.ui-tooltip-cluetip .ui-tooltip-titlebar .ui-state-hover{border-color:#696952;color:#696952;}.ui-tooltip-tipsy{border:0;}.ui-tooltip-tipsy .ui-tooltip-titlebar,.ui-tooltip-tipsy .ui-tooltip-content{_margin-bottom:0;.margin-bottom:0;background:transparent;background:rgba(0,0,0,.87);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#D9000000,endColorstr=#D9000000)";color:white;border:0 transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:bold;line-height:16px;text-shadow:0 1px black;}.ui-tooltip-tipsy .ui-tooltip-titlebar{padding:6px 35px 0 10;}.ui-tooltip-tipsy .ui-tooltip-content{padding:6px 10;}.ui-tooltip-tipsy .ui-tooltip-icon{border-color:#222;text-shadow:none;}.ui-tooltip-tipsy .ui-tooltip-titlebar .ui-state-hover{border-color:#303030;}.ui-tooltip-tipped .ui-tooltip-titlebar,.ui-tooltip-tipped .ui-tooltip-content{border:3px solid #959FA9;filter:none;-ms-filter:none;}.ui-tooltip-tipped .ui-tooltip-titlebar{background:#3A79B8;background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8,endColorstr=#2E629D)";color:white;font-weight:normal;font-family:serif;border-bottom-width:0;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;}.ui-tooltip-tipped .ui-tooltip-content{background-color:#F9F9F9;color:#454545;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;}.ui-tooltip-tipped .ui-tooltip-icon{border:2px solid #285589;background:#285589;}.ui-tooltip-tipped .ui-tooltip-icon .ui-icon{background-color:#FBFBFB;color:#555;}.ui-tooltip:not(.ie9haxors) div.ui-tooltip-content,.ui-tooltip:not(.ie9haxors) div.ui-tooltip-titlebar{filter:none;-ms-filter:none;} \ No newline at end of file diff --git a/public/libs/qtip/jquery.qtip.js b/public/libs/qtip/jquery.qtip.js new file mode 100644 index 00000000..0cf6c9ff --- /dev/null +++ b/public/libs/qtip/jquery.qtip.js @@ -0,0 +1,13 @@ +/* +* qTip2 - Pretty powerful tooltips +* http://craigsworks.com/projects/qtip2/ +* +* Version: nightly +* Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com +* +* Dual licensed under MIT or GPLv2 licenses +* http://en.wikipedia.org/wiki/MIT_License +* http://en.wikipedia.org/wiki/GNU_General_Public_License +* +* Date: Wed May 9 16:55:09.0000000000 2012 +*//*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true *//*global window: false, jQuery: false, console: false, define: false */(function(a){typeof define==="function"&&define.amd?define(["jquery"],a):a(jQuery)})(function(a){function D(b){var c=this,d=b.elements,e=d.tooltip,f=".bgiframe-"+b.id;a.extend(c,{init:function(){d.bgiframe=a(''),d.bgiframe.appendTo(e),e.bind("tooltipmove"+f,c.adjust)},adjust:function(){var a=b.get("dimensions"),c=b.plugins.tip,f=d.tip,g,h;h=parseInt(e.css("border-left-width"),10)||0,h={left:-h,top:-h},c&&f&&(g=c.corner.precedance==="x"?["width","left"]:["height","top"],h[g[1]]-=f[g[0]]()),d.bgiframe.css(h).css(a)},destroy:function(){d.bgiframe.remove(),e.unbind(f)}}),c.init()}function C(d){var e=this,f=d.options.show.modal,h=d.elements,i=h.tooltip,j="#qtip-overlay",k=".qtipmodal",l=k+d.id,n="is-modal-qtip",p=a(document.body),q;d.checks.modal={"^show.modal.(on|blur)$":function(){e.init(),h.overlay.toggle(i.is(":visible"))}},a.extend(e,{init:function(){if(!f.on)return e;q=e.create(),i.attr(n,b).css("z-index",g.modal.zindex+a(m+"["+n+"]").length).unbind(k).unbind(l).bind("tooltipshow"+k+" tooltiphide"+k,function(b,c,d){var f=b.originalEvent;if(b.target===i[0])if(f&&b.type==="tooltiphide"&&/mouse(leave|enter)/.test(f.type)&&a(f.relatedTarget).closest(q[0]).length)try{b.preventDefault()}catch(g){}else(!f||f&&!f.solo)&&e[b.type.replace("tooltip","")](b,d)}).bind("tooltipfocus"+k,function(b){if(!b.isDefaultPrevented()&&b.target===i[0]){var c=a(m).filter("["+n+"]"),d=g.modal.zindex+c.length,e=parseInt(i[0].style.zIndex,10);q[0].style.zIndex=d-1,c.each(function(){this.style.zIndex>e&&(this.style.zIndex-=1)}),c.end().filter("."+o).qtip("blur",b.originalEvent),i.addClass(o)[0].style.zIndex=d;try{b.preventDefault()}catch(f){}}}).bind("tooltiphide"+k,function(b){b.target===i[0]&&a("["+n+"]").filter(":visible").not(i).last().qtip("focus",b)}),f.escape&&a(window).unbind(l).bind("keydown"+l,function(a){a.keyCode===27&&i.hasClass(o)&&d.hide(a)}),f.blur&&h.overlay.unbind(l).bind("click"+l,function(a){i.hasClass(o)&&d.hide(a)});return e},create:function(){function d(){q.css({height:a(window).height(),width:a(window).width()})}var b=a(j);if(b.length)return h.overlay=b.insertAfter(a(m).last());q=h.overlay=a("
",{id:j.substr(1),html:"
",mousedown:function(){return c}}).insertAfter(a(m).last()),a(window).unbind(k).bind("resize"+k,d),d();return q},toggle:function(d,g,h){if(d&&d.isDefaultPrevented())return e;var j=f.effect,k=g?"show":"hide",o=q.is(":visible"),r=a("["+n+"]").filter(":visible").not(i),s;q||(q=e.create());if(q.is(":animated")&&o===g||!g&&r.length)return e;g?(q.css({left:0,top:0}),q.toggleClass("blurs",f.blur),p.bind("focusin"+l,function(b){var d=a(b.target),e=d.closest(".qtip"),f=e.length<1?c:parseInt(e[0].style.zIndex,10)>parseInt(i[0].style.zIndex,10);!f&&a(b.target).closest(m)[0]!==i[0]&&i.find("input:visible").filter(":first").focus()})):p.undelegate("*","focusin"+l),q.stop(b,c),a.isFunction(j)?j.call(q,g):j===c?q[k]():q.fadeTo(parseInt(h,10)||90,g?1:0,function(){g||a(this).hide()}),g||q.queue(function(a){q.css({left:"",top:""}),a()});return e},show:function(a,c){return e.toggle(a,b,c)},hide:function(a,b){return e.toggle(a,c,b)},destroy:function(){var b=q;b&&(b=a("["+n+"]").not(i).length<1,b?(h.overlay.remove(),a(window).unbind(k)):h.overlay.unbind(k+d.id),p.undelegate("*","focusin"+l));return i.removeAttr(n).unbind(k)}}),e.init()}function B(f,h){function y(a){var b=a.precedance==="y",c=n[b?"width":"height"],d=n[b?"height":"width"],e=a.string().indexOf("center")>-1,f=c*(e?.5:1),g=Math.pow,h=Math.round,i,j,k,l=Math.sqrt(g(f,2)+g(d,2)),m=[p/f*l,p/d*l];m[2]=Math.sqrt(g(m[0],2)-g(p,2)),m[3]=Math.sqrt(g(m[1],2)-g(p,2)),i=l+m[2]+m[3]+(e?0:m[0]),j=i/l,k=[h(j*d),h(j*c)];return{height:k[b?0:1],width:k[b?1:0]}}function x(b){var c=k.titlebar&&b.y==="top",d=c?k.titlebar:k.content,e=a.browser.mozilla,f=e?"-moz-":a.browser.webkit?"-webkit-":"",g=b.y+(e?"":"-")+b.x,h=f+(e?"border-radius-"+g:"border-"+g+"-radius");return parseInt(d.css(h),10)||parseInt(l.css(h),10)||0}function w(a,b,c){b=b?b:a[a.precedance];var d=l.hasClass(q),e=k.titlebar&&a.y==="top",f=e?k.titlebar:k.content,g="border-"+b+"-width",h;l.addClass(q),h=parseInt(f.css(g),10),h=(c?h||parseInt(l.css(g),10):h)||0,l.toggleClass(q,d);return h}function v(a,d,g,h){if(k.tip){var l=i.corner.clone(),n=g.adjusted,o=f.options.position.adjust.method.split(" "),p=o[0],q=o[1]||o[0],r={left:c,top:c,x:0,y:0},s,t={},u;i.corner.fixed!==b&&(p==="shift"&&l.precedance==="x"&&n.left&&l.y!=="center"?l.precedance=l.precedance==="x"?"y":"x":p!=="shift"&&n.left&&(l.x=l.x==="center"?n.left>0?"left":"right":l.x==="left"?"right":"left"),q==="shift"&&l.precedance==="y"&&n.top&&l.x!=="center"?l.precedance=l.precedance==="y"?"x":"y":q!=="shift"&&n.top&&(l.y=l.y==="center"?n.top>0?"top":"bottom":l.y==="top"?"bottom":"top"),l.string()!==m.corner.string()&&(m.top!==n.top||m.left!==n.left)&&i.update(l,c)),s=i.position(l,n),s.right!==e&&(s.left=-s.right),s.bottom!==e&&(s.top=-s.bottom),s.user=Math.max(0,j.offset);if(r.left=p==="shift"&&!!n.left)l.x==="center"?t["margin-left"]=r.x=s["margin-left"]-n.left:(u=s.right!==e?[n.left,-s.left]:[-n.left,s.left],(r.x=Math.max(u[0],u[1]))>u[0]&&(g.left-=n.left,r.left=c),t[s.right!==e?"right":"left"]=r.x);if(r.top=q==="shift"&&!!n.top)l.y==="center"?t["margin-top"]=r.y=s["margin-top"]-n.top:(u=s.bottom!==e?[n.top,-s.top]:[-n.top,s.top],(r.y=Math.max(u[0],u[1]))>u[0]&&(g.top-=n.top,r.top=c),t[s.bottom!==e?"bottom":"top"]=r.y);k.tip.css(t).toggle(!(r.x&&r.y||l.x==="center"&&r.y||l.y==="center"&&r.x)),g.left-=s.left.charAt?s.user:p!=="shift"||r.top||!r.left&&!r.top?s.left:0,g.top-=s.top.charAt?s.user:q!=="shift"||r.left||!r.left&&!r.top?s.top:0,m.left=n.left,m.top=n.top,m.corner=l.clone()}}function u(){n.width=j.width,n.height=j.height}function t(){var a=n.width;n.width=n.height,n.height=a}var i=this,j=f.options.style.tip,k=f.elements,l=k.tooltip,m={top:0,left:0},n={width:j.width,height:j.height},o={},p=j.border||0,r=".qtip-tip",s=!!(a("")[0]||{}).getContext;i.mimic=i.corner=d,i.border=p,i.offset=j.offset,i.size=n,f.checks.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){i.init()||i.destroy(),f.reposition()},"^style.tip.(height|width)$":function(){n={width:j.width,height:j.height},i.create(),i.update(),f.reposition()},"^content.title.text|style.(classes|widget)$":function(){k.tip&&k.tip.length&&i.update()}},a.extend(i,{init:function(){var b=i.detectCorner()&&(s||a.browser.msie);b&&(i.create(),i.update(),l.unbind(r).bind("tooltipmove"+r,v));return b},detectCorner:function(){var a=j.corner,d=f.options.position,e=d.at,h=d.my.string?d.my.string():d.my;if(a===c||h===c&&e===c)return c;a===b?i.corner=new g.Corner(h):a.string||(i.corner=new g.Corner(a),i.corner.fixed=b),m.corner=new g.Corner(i.corner.string());return i.corner.string()!=="centercenter"},detectColours:function(b){var c,d,e,g=k.tip.css("cssText",""),h=b||i.corner,m=h[h.precedance],p="border-"+m+"-color",r="border"+m.charAt(0)+m.substr(1)+"Color",s=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,t="background-color",u="transparent",v=" !important",w=a(document.body).css("color"),x=f.elements.content.css("color"),y=k.titlebar&&(h.y==="top"||h.y==="center"&&g.position().top+n.height/2+j.offset",{"class":"ui-tooltip-tip"}).css({width:b,height:c}).prependTo(l),s?a("").appendTo(k.tip)[0].getContext("2d").save():(d='',k.tip.html(d+d),a("*",k.tip).bind("click mousedown",function(a){a.stopPropagation()}))},update:function(e,f){var h=k.tip,l=h.children(),q=n.width,r=n.height,v="px solid ",x="px dashed transparent",z=j.mimic,B=Math.round,C,D,E,F,G;e||(e=m.corner||i.corner),z===c?z=e:(z=new g.Corner(z),z.precedance=e.precedance,z.x==="inherit"?z.x=e.x:z.y==="inherit"?z.y=e.y:z.x===z.y&&(z[e.precedance]=e[e.precedance])),C=z.precedance,e.precedance==="x"?t():u(),k.tip.css({width:q=n.width,height:r=n.height}),i.detectColours(e),o.border!=="transparent"&&o.border!=="#123456"?(p=w(e,d,b),j.border===0&&p>0&&(o.fill=o.border),i.border=p=j.border!==b?j.border:p):i.border=p=0,E=A(z,q,r),i.size=G=y(e),h.css(G),e.precedance==="y"?F=[B(z.x==="left"?p:z.x==="right"?G.width-q-p:(G.width-q)/2),B(z.y==="top"?G.height-r:0)]:F=[B(z.x==="left"?G.width-q:0),B(z.y==="top"?p:z.y==="bottom"?G.height-r-p:(G.height-r)/2)],s?(l.attr(G),D=l[0].getContext("2d"),D.restore(),D.save(),D.clearRect(0,0,3e3,3e3),D.translate(F[0],F[1]),D.beginPath(),D.moveTo(E[0][0],E[0][1]),D.lineTo(E[1][0],E[1][1]),D.lineTo(E[2][0],E[2][1]),D.closePath(),D.fillStyle=o.fill,D.strokeStyle=o.border,D.lineWidth=p*2,D.lineJoin="miter",D.miterLimit=100,p&&D.stroke(),D.fill()):(E="m"+E[0][0]+","+E[0][1]+" l"+E[1][0]+","+E[1][1]+" "+E[2][0]+","+E[2][1]+" xe",F[2]=p&&/^(r|b)/i.test(e.string())?parseFloat(a.browser.version,10)===8?2:1:0,l.css({antialias:""+(z.string().indexOf("center")>-1),left:F[0]-F[2]*Number(C==="x"),top:F[1]-F[2]*Number(C==="y"),width:q+p,height:r+p}).each(function(b){var c=a(this);c[c.prop?"prop":"attr"]({coordsize:q+p+" "+(r+p),path:E,fillcolor:o.fill,filled:!!b,stroked:!b}).css({display:p||b?"block":"none"}),!b&&c.html()===""&&c.html('')})),f!==c&&i.position(e)},position:function(d){var e=k.tip,f={},g=Math.max(0,j.offset),h,l,m;if(j.corner===c||!e)return c;d=d||i.corner,h=d.precedance,l=y(d),m=[d.x,d.y],h==="x"&&m.reverse(),a.each(m,function(a,c){var e,i;c==="center"?(e=h==="y"?"left":"top",f[e]="50%",f["margin-"+e]=-Math.round(l[h==="y"?"width":"height"]/2)+g):(e=w(d,c,b),i=x(d),f[c]=a?p?w(d,c):0:g+(i>e?i:0))}),f[d[h]]-=l[h==="x"?"width":"height"],e.css({top:"",bottom:"",left:"",right:"",margin:""}).css(f);return f},destroy:function(){k.tip&&k.tip.remove(),k.tip=!1,l.unbind(r)}}),i.init()}function A(a,b,c){var d=Math.ceil(b/2),e=Math.ceil(c/2),f={bottomright:[[0,0],[b,c],[b,0]],bottomleft:[[0,0],[b,0],[0,c]],topright:[[0,c],[b,0],[b,c]],topleft:[[0,0],[0,c],[b,c]],topcenter:[[0,c],[d,0],[b,c]],bottomcenter:[[0,0],[b,0],[d,c]],rightcenter:[[0,0],[b,e],[0,c]],leftcenter:[[b,0],[b,c],[0,e]]};f.lefttop=f.bottomright,f.righttop=f.bottomleft,f.leftbottom=f.topright,f.rightbottom=f.topleft;return f[a.string()]}function z(d){var e=this,g=d.elements.tooltip,h=d.options.content.ajax,i=f.defaults.content.ajax,j=".qtip-ajax",k=/)<[^<]*)*<\/script>/gi,l=b,m=c,n;d.checks.ajax={"^content.ajax":function(a,b,c){b==="ajax"&&(h=c),b==="once"?e.init():h&&h.url?e.load():g.unbind(j)}},a.extend(e,{init:function(){h&&h.url&&g.unbind(j)[h.once?"one":"bind"]("tooltipshow"+j,e.load);return e},load:function(f){function t(a,b,c){!d.destroyed&&a.status!==0&&d.set("content.text",b+": "+c)}function s(b,c,e){var f;d.destroyed||(o&&(b=a("
").append(b.replace(k,"")).find(o)),(f=i.success||h.success)&&a.isFunction(f)?f.call(h.context||d,b,c,e):d.set("content.text",b))}function r(){var e;d.destroyed||(l=c,p&&(m=b,d.show(f.originalEvent)),(e=i.complete||h.complete)&&a.isFunction(e)&&e.apply(h.context||d,arguments))}if(m)m=c;else{var g=h.url.indexOf(" "),j=h.url,o,p=!h.loading&&l;if(p)try{f.preventDefault()}catch(q){}else if(f&&f.isDefaultPrevented())return e;n&&n.abort&&n.abort(),g>-1&&(o=j.substr(g),j=j.substr(0,g)),n=a.ajax(a.extend({error:i.error||t,context:d},h,{url:j,success:s,complete:r}))}},destroy:function(){n&&n.abort&&n.abort(),d.destroyed=b}}),e.init()}function y(e,h){var i,j,k,l,m,n=a(this),o=a(document.body),p=this===document?o:n,q=n.metadata?n.metadata(h.metadata):d,r=h.metadata.type==="html5"&&q?q[h.metadata.name]:d,s=n.data(h.metadata.name||"qtipopts");try{s=typeof s==="string"?(new Function("return "+s))():s}catch(u){v("Unable to parse HTML5 attribute data: "+s)}l=a.extend(b,{},f.defaults,h,typeof s==="object"?w(s):d,w(r||q)),j=l.position,l.id=e;if("boolean"===typeof l.content.text){k=n.attr(l.content.attr);if(l.content.attr!==c&&k)l.content.text=k;else{v("Unable to locate content for tooltip! Aborting render of tooltip on element: ",n);return c}}j.container.length||(j.container=o),j.target===c&&(j.target=p),l.show.target===c&&(l.show.target=p),l.show.solo===b&&(l.show.solo=j.container.closest("body")),l.hide.target===c&&(l.hide.target=p),l.position.viewport===b&&(l.position.viewport=j.container),j.container=j.container.eq(0),j.at=new g.Corner(j.at),j.my=new g.Corner(j.my);if(a.data(this,"qtip"))if(l.overwrite)n.qtip("destroy");else if(l.overwrite===c)return c;l.suppress&&(m=a.attr(this,"title"))&&a(this).removeAttr("title").attr(t,m),i=new x(n,l,e,!!k),a.data(this,"qtip",i),n.bind("remove.qtip-"+e+" removeqtip.qtip-"+e,function(){i.destroy()});return i}function x(r,s,v,x){function Q(){var b=[s.show.target[0],s.hide.target[0],y.rendered&&F.tooltip[0],s.position.container[0],s.position.viewport[0],window,document];y.rendered?a([]).pushStack(a.grep(b,function(a){return typeof a==="object"})).unbind(E):s.show.target.unbind(E+"-create")}function P(){function o(a){y.rendered&&D[0].offsetWidth>0&&y.reposition(a)}function n(a){if(D.hasClass(l))return c;clearTimeout(y.timers.inactive),y.timers.inactive=setTimeout(function(){y.hide(a)},s.hide.inactive)}function k(b){if(D.hasClass(l)||B||C)return c;var f=a(b.relatedTarget||b.target),g=f.closest(m)[0]===D[0],h=f[0]===e.show[0];clearTimeout(y.timers.show),clearTimeout(y.timers.hide);if(d.target==="mouse"&&g||s.hide.fixed&&(/mouse(out|leave|move)/.test(b.type)&&(g||h)))try{b.preventDefault(),b.stopImmediatePropagation()}catch(i){}else s.hide.delay>0?y.timers.hide=setTimeout(function(){y.hide(b)},s.hide.delay):y.hide(b)}function j(a){if(D.hasClass(l))return c;clearTimeout(y.timers.show),clearTimeout(y.timers.hide);var d=function(){y.toggle(b,a)};s.show.delay>0?y.timers.show=setTimeout(d,s.show.delay):d()}var d=s.position,e={show:s.show.target,hide:s.hide.target,viewport:a(d.viewport),document:a(document),body:a(document.body),window:a(window)},g={show:a.trim(""+s.show.event).split(" "),hide:a.trim(""+s.hide.event).split(" ")},i=a.browser.msie&&parseInt(a.browser.version,10)===6;D.bind("mouseenter"+E+" mouseleave"+E,function(a){var b=a.type==="mouseenter";b&&y.focus(a),D.toggleClass(p,b)}),s.hide.fixed&&(e.hide=e.hide.add(D),D.bind("mouseover"+E,function(){D.hasClass(l)||clearTimeout(y.timers.hide)})),/mouse(out|leave)/i.test(s.hide.event)?s.hide.leave==="window"&&e.window.bind("mouseout"+E+" blur"+E,function(a){/select|option/.test(a.target)&&!a.relatedTarget&&y.hide(a)}):/mouse(over|enter)/i.test(s.show.event)&&e.hide.bind("mouseleave"+E,function(a){clearTimeout(y.timers.show)}),(""+s.hide.event).indexOf("unfocus")>-1&&d.container.closest("html").bind("mousedown"+E,function(b){var c=a(b.target),d=y.rendered&&!D.hasClass(l)&&D[0].offsetWidth>0,e=c.parents(m).filter(D[0]).length>0;c[0]!==r[0]&&c[0]!==D[0]&&!e&&!r.has(c[0]).length&&!c.attr("disabled")&&y.hide(b)}),"number"===typeof s.hide.inactive&&(e.show.bind("qtip-"+v+"-inactive",n),a.each(f.inactiveEvents,function(a,b){e.hide.add(F.tooltip).bind(b+E+"-inactive",n)})),a.each(g.hide,function(b,c){var d=a.inArray(c,g.show),f=a(e.hide);d>-1&&f.add(e.show).length===f.length||c==="unfocus"?(e.show.bind(c+E,function(a){D[0].offsetWidth>0?k(a):j(a)}),delete g.show[d]):e.hide.bind(c+E,k)}),a.each(g.show,function(a,b){e.show.bind(b+E,j)}),"number"===typeof s.hide.distance&&e.show.add(D).bind("mousemove"+E,function(a){var b=G.origin||{},c=s.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&y.hide(a)}),d.target==="mouse"&&(e.show.bind("mousemove"+E,function(a){h={pageX:a.pageX,pageY:a.pageY,type:"mousemove"}}),d.adjust.mouse&&(s.hide.event&&(D.bind("mouseleave"+E,function(a){(a.relatedTarget||a.target)!==e.show[0]&&y.hide(a)}),F.target.bind("mouseenter"+E+" mouseleave"+E,function(a){G.onTarget=a.type==="mouseenter"})),e.document.bind("mousemove"+E,function(a){y.rendered&&G.onTarget&&!D.hasClass(l)&&D[0].offsetWidth>0&&y.reposition(a||h)}))),(d.adjust.resize||e.viewport.length)&&(a.event.special.resize?e.viewport:e.window).bind("resize"+E,o),(e.viewport.length||i&&D.css("position")==="fixed")&&e.viewport.bind("scroll"+E,o)}function O(b,d){function g(b){function i(e){e&&(delete h[e.src],clearTimeout(y.timers.img[e.src]),a(e).unbind(E)),a.isEmptyObject(h)&&(y.redraw(),d!==c&&y.reposition(G.event),b())}var g,h={};if((g=f.find("img[src]:not([height]):not([width])")).length===0)return i();g.each(function(b,c){if(h[c.src]===e){var d=0,f=3;(function g(){if(c.height||c.width||d>f)return i(c);d+=1,y.timers.img[c.src]=setTimeout(g,700)})(),a(c).bind("error"+E+" load"+E,function(){i(this)}),h[c.src]=c}})}var f=F.content;if(!y.rendered||!b)return c;a.isFunction(b)&&(b=b.call(r,G.event,y)||""),b.jquery&&b.length>0?f.empty().append(b.css({display:"block"})):f.html(b),y.rendered<0?D.queue("fx",g):(C=0,g(a.noop));return y}function N(b,d){var e=F.title;if(!y.rendered||!b)return c;a.isFunction(b)&&(b=b.call(r,G.event,y));if(b===c||!b&&b!=="")return J(c);b.jquery&&b.length>0?e.empty().append(b.css({display:"block"})):e.html(b),y.redraw(),d!==c&&y.rendered&&D[0].offsetWidth>0&&y.reposition(G.event)}function M(a){var b=F.button,d=F.title;if(!y.rendered)return c;a?(d||L(),K()):b.remove()}function L(){var c=A+"-title";F.titlebar&&J(),F.titlebar=a("
",{"class":j+"-titlebar "+(s.style.widget?"ui-widget-header":"")}).append(F.title=a("
",{id:c,"class":j+"-title","aria-atomic":b})).insertBefore(F.content).delegate(".ui-tooltip-close","mousedown keydown mouseup keyup mouseout",function(b){a(this).toggleClass("ui-state-active ui-state-focus",b.type.substr(-4)==="down")}).delegate(".ui-tooltip-close","mouseover mouseout",function(b){a(this).toggleClass("ui-state-hover",b.type==="mouseover")}),s.content.title.button?K():y.rendered&&y.redraw()}function K(){var b=s.content.title.button,d=typeof b==="string",e=d?b:"Close tooltip";F.button&&F.button.remove(),b.jquery?F.button=b:F.button=a("",{"class":"ui-state-default ui-tooltip-close "+(s.style.widget?"":j+"-icon"),title:e,"aria-label":e}).prepend(a("",{"class":"ui-icon ui-icon-close",html:"×"})),F.button.appendTo(F.titlebar).attr("role","button").click(function(a){D.hasClass(l)||y.hide(a);return c}),y.redraw()}function J(a){F.title&&(F.titlebar.remove(),F.titlebar=F.title=F.button=d,a!==c&&y.reposition())}function I(){var a=s.style.widget;D.toggleClass(k,a).toggleClass(n,s.style.def&&!a),F.content.toggleClass(k+"-content",a),F.titlebar&&F.titlebar.toggleClass(k+"-header",a),F.button&&F.button.toggleClass(j+"-icon",!a)}function H(a){var b=0,c,d=s,e=a.split(".");while(d=d[e[b++]])b0&&!a("#"+i).length&&(D[0].id=i,F.content[0].id=i+"-content",F.title[0].id=i+"-title")},"^content.text$":function(a,b,c){O(c)},"^content.title.text$":function(a,b,c){if(!c)return J();!F.title&&c&&L(),N(c)},"^content.title.button$":function(a,b,c){M(c)},"^position.(my|at)$":function(a,b,c){"string"===typeof c&&(a[b]=new g.Corner(c))},"^position.container$":function(a,b,c){y.rendered&&D.appendTo(c)},"^show.ready$":function(){y.rendered?y.toggle(b):y.render(1)},"^style.classes$":function(a,b,c){D.attr("class",j+" qtip ui-helper-reset "+c)},"^style.widget|content.title":I,"^events.(render|show|move|hide|focus|blur)$":function(b,c,d){D[(a.isFunction(d)?"":"un")+"bind"]("tooltip"+c,d)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){var a=s.position;D.attr("tracking",a.target==="mouse"&&a.adjust.mouse),Q(),P()}},a.extend(y,{render:function(d){if(y.rendered)return y;var e=s.content.text,f=s.content.title.text,h=s.position,i=a.Event("tooltiprender");a.attr(r[0],"aria-describedby",A),D=F.tooltip=a("
",{id:A,"class":j+" qtip ui-helper-reset "+n+" "+s.style.classes+" "+j+"-pos-"+s.position.my.abbrev(),width:s.style.width||"",height:s.style.height||"",tracking:h.target==="mouse"&&h.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":c,"aria-describedby":A+"-content","aria-hidden":b}).toggleClass(l,G.disabled).data("qtip",y).appendTo(s.position.container).append(F.content=a("
",{"class":j+"-content",id:A+"-content","aria-atomic":b})),y.rendered=-1,B=C=1,f&&(L(),a.isFunction(f)||N(f,c)),a.isFunction(e)||O(e,c),y.rendered=b,I(),a.each(s.events,function(b,c){a.isFunction(c)&&D.bind(b==="toggle"?"tooltipshow tooltiphide":"tooltip"+b,c)}),a.each(g,function(){this.initialize==="render"&&this(y)}),P(),D.queue("fx",function(a){i.originalEvent=G.event,D.trigger(i,[y]),B=C=0,y.redraw(),(s.show.ready||d)&&y.toggle(b,G.event,c),a()});return y},get:function(a){var b,c;switch(a.toLowerCase()){case"dimensions":b={height:D.outerHeight(),width:D.outerWidth()};break;case"offset":b=g.offset(D,s.position.container);break;default:c=H(a.toLowerCase()),b=c[0][c[1]],b=b.precedance?b.string():b}return b},set:function(e,f){function m(a,b){var c,d,e;for(c in k)for(d in k[c])if(e=(new RegExp(d,"i")).exec(a))b.push(e),k[c][d].apply(y,b)}var g=/^position\.(my|at|adjust|target|container)|style|content|show\.ready/i,h=/^content\.(title|attr)|style/i,i=c,j=c,k=y.checks,l;"string"===typeof e?(l=e,e={},e[l]=f):e=a.extend(b,{},e),a.each(e,function(b,c){var d=H(b.toLowerCase()),f;f=d[0][d[1]],d[0][d[1]]="object"===typeof c&&c.nodeType?a(c):c,e[b]=[d[0],d[1],c,f],i=g.test(b)||i,j=h.test(b)||j}),w(s),B=C=1,a.each(e,m),B=C=0,y.rendered&&D[0].offsetWidth>0&&(i&&y.reposition(s.position.target==="mouse"?d:G.event),j&&y.redraw());return y},toggle:function(e,f){function t(){e?(a.browser.msie&&D[0].style.removeAttribute("filter"),D.css("overflow",""),"string"===typeof i.autofocus&&a(i.autofocus,D).focus(),i.target.trigger("qtip-"+v+"-inactive")):D.css({display:"",visibility:"",opacity:"",left:"",top:""}),r=a.Event("tooltip"+(e?"visible":"hidden")),r.originalEvent=f?G.event:d,D.trigger(r,[y])}if(!y.rendered)return e?y.render(1):y;var g=e?"show":"hide",i=s[g],j=s[e?"hide":"show"],k=s.position,l=s.content,n=D[0].offsetWidth>0,o=e||i.target.length===1,p=!f||i.target.length<2||G.target[0]===f.target,q,r;(typeof e).search("boolean|number")&&(e=!n);if(!D.is(":animated")&&n===e&&p)return y;if(f){if(/over|enter/.test(f.type)&&/out|leave/.test(G.event.type)&&s.show.target.add(f.target).length===s.show.target.length&&D.has(f.relatedTarget).length)return y;G.event=a.extend({},f)}r=a.Event("tooltip"+g),r.originalEvent=f?G.event:d,D.trigger(r,[y,90]);if(r.isDefaultPrevented())return y;a.attr(D[0],"aria-hidden",!e),e?(G.origin=a.extend({},h),y.focus(f),a.isFunction(l.text)&&O(l.text,c),a.isFunction(l.title.text)&&N(l.title.text,c),!u&&k.target==="mouse"&&k.adjust.mouse&&(a(document).bind("mousemove.qtip",function(a){h={pageX:a.pageX,pageY:a.pageY,type:"mousemove"}}),u=b),y.reposition(f,arguments[2]),(r.solo=!!i.solo)&&a(m,i.solo).not(D).qtip("hide",r)):(clearTimeout(y.timers.show),delete G.origin,u&&!a(m+'[tracking="true"]:visible',i.solo).not(D).length&&(a(document).unbind("mousemove.qtip"),u=c),y.blur(f)),i.effect===c||o===c?(D[g](),t.call(D)):a.isFunction(i.effect)?(D.stop(1,1),i.effect.call(D,y),D.queue("fx",function(a){t(),a()})):D.fadeTo(90,e?1:0,t),e&&i.target.trigger("qtip-"+v+"-inactive");return y},show:function(a){return y.toggle(b,a)},hide:function(a){return y.toggle(c,a)},focus:function(b){if(!y.rendered)return y;var c=a(m),d=parseInt(D[0].style.zIndex,10),e=f.zindex+c.length,g=a.extend({},b),h,i;D.hasClass(o)||(i=a.Event("tooltipfocus"),i.originalEvent=g,D.trigger(i,[y,e]),i.isDefaultPrevented()||(d!==e&&(c.each(function(){this.style.zIndex>d&&(this.style.zIndex=this.style.zIndex-1)}),c.filter("."+o).qtip("blur",g)),D.addClass(o)[0].style.zIndex=e));return y},blur:function(b){var c=a.extend({},b),d;D.removeClass(o),d=a.Event("tooltipblur"),d.originalEvent=c,D.trigger(d,[y]);return y},reposition:function(b,d){if(!y.rendered||B)return y;B=1;var e=s.position.target,f=s.position,i=f.my,k=f.at,l=f.adjust,m=l.method.split(" "),n=D.outerWidth(),o=D.outerHeight(),p=0,q=0,r=a.Event("tooltipmove"),t=D.css("position")==="fixed",u=f.viewport,v={left:0,top:0},w=f.container,x=c,A=y.plugins.tip,C=D[0].offsetWidth>0,E={horizontal:m[0],vertical:m[1]=m[1]||m[0],enabled:u.jquery&&e[0]!==window&&e[0]!==z&&l.method!=="none",left:function(a){var b=E.horizontal==="shift",c=l.x*(E.horizontal.substr(-6)==="invert"?2:0),d=-w.offset.left+u.offset.left+u.scrollLeft,e=i.x==="left"?n:i.x==="right"?-n:-n/2,f=k.x==="left"?p:k.x==="right"?-p:-p/2,g=A&&A.size?A.size.width||0:0,h=A&&A.corner&&A.corner.precedance==="x"&&!b?g:0,j=d-a+h,m=a+n-u.width-d+h,o=e-(i.precedance==="x"||i.x===i.y?f:0)-(k.x==="center"?p/2:0),q=i.x==="center";b?(h=A&&A.corner&&A.corner.precedance==="y"?g:0,o=(i.x==="left"?1:-1)*e-h,v.left+=j>0?j:m>0?-m:0,v.left=Math.max(-w.offset.left+u.offset.left+(h&&A.corner.x==="center"?A.offset:0),a-o,Math.min(Math.max(-w.offset.left+u.offset.left+u.width,a+o),v.left))):(j>0&&(i.x!=="left"||m>0)?v.left-=o+c:m>0&&(i.x!=="right"||j>0)&&(v.left-=(q?-o:o)+c),v.leftm&&(v.left=a));return v.left-a},top:function(a){var b=E.vertical==="shift",c=l.y*(E.vertical.substr(-6)==="invert"?2:0),d=-w.offset.top+u.offset.top+u.scrollTop,e=i.y==="top"?o:i.y==="bottom"?-o:-o/2,f=k.y==="top"?q:k.y==="bottom"?-q:-q/2,g=A&&A.size?A.size.height||0:0,h=A&&A.corner&&A.corner.precedance==="y"&&!b?g:0,j=d-a+h,m=a+o-u.height-d+h,n=e-(i.precedance==="y"||i.x===i.y?f:0)-(k.y==="center"?q/2:0),p=i.y==="center";b?(h=A&&A.corner&&A.corner.precedance==="x"?g:0,n=(i.y==="top"?1:-1)*e-h,v.top+=j>0?j:m>0?-m:0,v.top=Math.max(-w.offset.top+u.offset.top+(h&&A.corner.x==="center"?A.offset:0),a-n,Math.min(Math.max(-w.offset.top+u.offset.top+u.height,a+n),v.top))):(j>0&&(i.y!=="top"||m>0)?v.top-=n+c:m>0&&(i.y!=="bottom"||j>0)&&(v.top-=(p?-n:n)+c),v.top<0&&-v.top>m&&(v.top=a));return v.top-a}},H;if(a.isArray(e)&&e.length===2)k={x:"left",y:"top"},v={left:e[0],top:e[1]};else if(e==="mouse"&&(b&&b.pageX||G.event.pageX))k={x:"left",y:"top"},b=(b&&(b.type==="resize"||b.type==="scroll")?G.event:b&&b.pageX&&b.type==="mousemove"?b:h&&h.pageX&&(l.mouse||!b||!b.pageX)?{pageX:h.pageX,pageY:h.pageY}:!l.mouse&&G.origin&&G.origin.pageX&&s.show.distance?G.origin:b)||b||G.event||h||{},v={top:b.pageY,left:b.pageX};else{e==="event"?b&&b.target&&b.type!=="scroll"&&b.type!=="resize"?e=G.target=a(b.target):e=G.target:e=G.target=a(e.jquery?e:F.target),e=a(e).eq(0);if(e.length===0)return y;e[0]===document||e[0]===window?(p=g.iOS?window.innerWidth:e.width(),q=g.iOS?window.innerHeight:e.height(),e[0]===window&&(v={top:(u||e).scrollTop(),left:(u||e).scrollLeft()})):e.is("area")&&g.imagemap?v=g.imagemap(e,k,E.enabled?m:c):e[0].namespaceURI==="http://www.w3.org/2000/svg"&&g.svg?v=g.svg(e,k):(p=e.outerWidth(),q=e.outerHeight(),v=g.offset(e,w)),v.offset&&(p=v.width,q=v.height,x=v.flipoffset,v=v.offset);if(g.iOS<4.1&&g.iOS>3.1||g.iOS==4.3||!g.iOS&&t)H=a(window),v.left-=H.scrollLeft(),v.top-=H.scrollTop();v.left+=k.x==="right"?p:k.x==="center"?p/2:0,v.top+=k.y==="bottom"?q:k.y==="center"?q/2:0}v.left+=l.x+(i.x==="right"?-n:i.x==="center"?-n/2:0),v.top+=l.y+(i.y==="bottom"?-o:i.y==="center"?-o/2:0),E.enabled?(u={elem:u,height:u[(u[0]===window?"h":"outerH")+"eight"](),width:u[(u[0]===window?"w":"outerW")+"idth"](),scrollLeft:t?0:u.scrollLeft(),scrollTop:t?0:u.scrollTop(),offset:u.offset()||{left:0,top:0}},w={elem:w,scrollLeft:w.scrollLeft(),scrollTop:w.scrollTop(),offset:w.offset()||{left:0,top:0}},v.adjusted={left:E.horizontal!=="none"?E.left(v.left):0,top:E.vertical!=="none"?E.top(v.top):0},v.adjusted.left+v.adjusted.top&&D.attr("class",D[0].className.replace(/ui-tooltip-pos-\w+/i,j+"-pos-"+i.abbrev())),x&&v.adjusted.left&&(v.left+=x.left),x&&v.adjusted.top&&(v.top+=x.top)):v.adjusted={left:0,top:0},r.originalEvent=a.extend({},b),D.trigger(r,[y,v,u.elem||u]);if(r.isDefaultPrevented())return y;delete v.adjusted,d===c||!C||isNaN(v.left)||isNaN(v.top)||e==="mouse"||!a.isFunction(f.effect)?D.css(v):a.isFunction(f.effect)&&(f.effect.call(D,y,a.extend({},v)),D.queue(function(b){a(this).css({opacity:"",height:""}),a.browser.msie&&this.style.removeAttribute("filter"),b()})),B=0;return y},redraw:function(){if(y.rendered<1||C)return y;var a=s.position.container,b,c,d,e;C=1,s.style.height&&D.css("height",s.style.height),s.style.width?D.css("width",s.style.width):(D.css("width","").addClass(q),c=D.width()+1,d=D.css("max-width")||"",e=D.css("min-width")||"",b=(d+e).indexOf("%")>-1?a.width()/100:0,d=(d.indexOf("%")>-1?b:1)*parseInt(d,10)||c,e=(e.indexOf("%")>-1?b:1)*parseInt(e,10)||0,c=d+e?Math.min(Math.max(c,e),d):c,D.css("width",Math.round(c)).removeClass(q)),C=0;return y},disable:function(b){"boolean"!==typeof b&&(b=!D.hasClass(l)&&!G.disabled),y.rendered?(D.toggleClass(l,b),a.attr(D[0],"aria-disabled",b)):G.disabled=!!b;return y},enable:function(){return y.disable(c)},destroy:function(){var c=r[0],d=a.attr(c,t),e=r.data("qtip");y.destroyed=b,y.rendered&&(D.stop(1,0).remove(),a.each(y.plugins,function(){this.destroy&&this.destroy()})),clearTimeout(y.timers.show),clearTimeout(y.timers.hide),Q();if(!e||y===e)a.removeData(c,"qtip"),s.suppress&&d&&(a.attr(c,"title",d),r.removeAttr(t)),r.removeAttr("aria-describedby");r.unbind(".qtip-"+v),delete i[y.id];return r}})}function w(b){var e;if(!b||"object"!==typeof b)return c;if(b.metadata===d||"object"!==typeof b.metadata)b.metadata={type:b.metadata};if("content"in b){if(b.content===d||"object"!==typeof b.content||b.content.jquery)b.content={text:b.content};e=b.content.text||c,!a.isFunction(e)&&(!e&&!e.attr||e.length<1||"object"===typeof e&&!e.jquery)&&(b.content.text=c);if("title"in b.content){if(b.content.title===d||"object"!==typeof b.content.title)b.content.title={text:b.content.title};e=b.content.title.text||c,!a.isFunction(e)&&(!e&&!e.attr||e.length<1||"object"===typeof e&&!e.jquery)&&(b.content.title.text=c)}}if("position"in b)if(b.position===d||"object"!==typeof b.position)b.position={my:b.position,at:b.position};if("show"in b)if(b.show===d||"object"!==typeof b.show)b.show.jquery?b.show={target:b.show}:b.show={event:b.show};if("hide"in b)if(b.hide===d||"object"!==typeof b.hide)b.hide.jquery?b.hide={target:b.hide}:b.hide={event:b.hide};if("style"in b)if(b.style===d||"object"!==typeof b.style)b.style={classes:b.style};a.each(g,function(){this.sanitize&&this.sanitize(b)});return b}function v(){v.history=v.history||[],v.history.push(arguments);if("object"===typeof console){var a=console[console.warn?"warn":"log"],b=Array.prototype.slice.call(arguments),c;typeof arguments[0]==="string"&&(b[0]="qTip2: "+b[0]),c=a.apply?a.apply(console,b):a(b)}}"use strict";var b=!0,c=!1,d=null,e,f,g,h,i={},j="ui-tooltip",k="ui-widget",l="ui-state-disabled",m="div.qtip."+j,n=j+"-default",o=j+"-focus",p=j+"-hover",q=j+"-fluid",r="-31000px",s="_replacedByqTip",t="oldtitle",u;f=a.fn.qtip=function(g,h,i){var j=(""+g).toLowerCase(),k=d,l=a.makeArray(arguments).slice(1),m=l[l.length-1],n=this[0]?a.data(this[0],"qtip"):d;if(!arguments.length&&n||j==="api")return n;if("string"===typeof g){this.each(function(){var d=a.data(this,"qtip");if(!d)return b;m&&m.timeStamp&&(d.cache.event=m);if(j!=="option"&&j!=="options"||!h)d[j]&&d[j].apply(d[j],l);else if(a.isPlainObject(h)||i!==e)d.set(h,i);else{k=d.get(h);return c}});return k!==d?k:this}if("object"===typeof g||!arguments.length){n=w(a.extend(b,{},g));return f.bind.call(this,n,m)}},f.bind=function(d,j){return this.each(function(k){function r(b){function d(){p.render(typeof b==="object"||l.show.ready),m.show.add(m.hide).unbind(o)}if(p.cache.disabled)return c;p.cache.event=a.extend({},b),p.cache.target=b?a(b.target):[e],l.show.delay>0?(clearTimeout(p.timers.show),p.timers.show=setTimeout(d,l.show.delay),n.show!==n.hide&&m.hide.bind(n.hide,function(){clearTimeout(p.timers.show)})):d()}var l,m,n,o,p,q;q=a.isArray(d.id)?d.id[k]:d.id,q=!q||q===c||q.length<1||i[q]?f.nextid++:i[q]=q,o=".qtip-"+q+"-create",p=y.call(this,q,d);if(p===c)return b;l=p.options,a.each(g,function(){this.initialize==="initialize"&&this(p)}),m={show:l.show.target,hide:l.hide.target},n={show:a.trim(""+l.show.event).replace(/ /g,o+" ")+o,hide:a.trim(""+l.hide.event).replace(/ /g,o+" ")+o},/mouse(over|enter)/i.test(n.show)&&!/mouse(out|leave)/i.test(n.hide)&&(n.hide+=" mouseleave"+o),m.show.bind("mousemove"+o,function(a){h={pageX:a.pageX,pageY:a.pageY,type:"mousemove"},p.cache.onTarget=b}),m.show.bind(n.show,r),(l.show.ready||l.prerender)&&r(j)})},g=f.plugins={Corner:function(a){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,"center").toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase();var b=a.charAt(0);this.precedance=b==="t"||b==="b"?"y":"x",this.string=function(){return this.precedance==="y"?this.y+this.x:this.x+this.y},this.abbrev=function(){var a=this.x.substr(0,1),b=this.y.substr(0,1);return a===b?a:a==="c"||a!=="c"&&b!=="c"?b+a:a+b},this.clone=function(){return{x:this.x,y:this.y,precedance:this.precedance,string:this.string,abbrev:this.abbrev,clone:this.clone}}},offset:function(b,c){function j(a,b){d.left+=b*a.scrollLeft(),d.top+=b*a.scrollTop()}var d=b.offset(),e=b.closest("body")[0],f=c,g,h,i;if(f){do f.css("position")!=="static"&&(h=f.position(),d.left-=h.left+(parseInt(f.css("borderLeftWidth"),10)||0)+(parseInt(f.css("marginLeft"),10)||0),d.top-=h.top+(parseInt(f.css("borderTopWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0),!g&&(i=f.css("overflow"))!=="hidden"&&i!=="visible"&&(g=f));while((f=a(f[0].offsetParent)).length);g&&g[0]!==e&&j(g,1)}return d},iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,3})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_","."))||c,fn:{attr:function(b,c){if(this.length){var d=this[0],e="title",f=a.data(d,"qtip");if(b===e&&f&&"object"===typeof f&&f.options.suppress){if(arguments.length<2)return a.attr(d,t);f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",c);return this.attr(t,c)}}return a.fn["attr"+s].apply(this,arguments)},clone:function(b){var c=a([]),d="title",e=a.fn["clone"+s].apply(this,arguments);b||e.filter("["+t+"]").attr("title",function(){return a.attr(this,t)}).removeAttr(t);return e}}},a.each(g.fn,function(c,d){if(!d||a.fn[c+s])return b;var e=a.fn[c+s]=a.fn[c];a.fn[c]=function(){return d.apply(this,arguments)||e.apply(this,arguments)}}),a.ui||(a["cleanData"+s]=a.cleanData,a.cleanData=function(b){for(var c=0,d;(d=b[c])!==e;c++)try{a(d).triggerHandler("removeqtip")}catch(f){}a["cleanData"+s](b)}),f.version="nightly",f.nextid=0,f.inactiveEvents="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),f.zindex=15e3,f.defaults={prerender:c,id:c,overwrite:b,suppress:b,content:{text:b,attr:"title",title:{text:c,button:c}},position:{my:"top left",at:"bottom right",target:c,container:c,viewport:c,adjust:{x:0,y:0,mouse:b,resize:b,method:"flip flip"},effect:function(b,d,e){a(this).animate(d,{duration:200,queue:c})}},show:{target:c,event:"mouseenter",effect:b,delay:90,solo:c,ready:c,autofocus:c},hide:{target:c,event:"mouseleave",effect:b,delay:0,fixed:c,inactive:c,leave:"window",distance:c},style:{classes:"",widget:c,width:c,height:c,def:b},events:{render:d,move:d,show:d,hide:d,toggle:d,visible:d,hidden:d,focus:d,blur:d}},g.ajax=function(a){var b=a.plugins.ajax;return"object"===typeof b?b:a.plugins.ajax=new z(a)},g.ajax.initialize="render",g.ajax.sanitize=function(a){var b=a.content,c;b&&"ajax"in b&&(c=b.ajax,typeof c!=="object"&&(c=a.content.ajax={url:c}),"boolean"!==typeof c.once&&c.once&&(c.once=!!c.once))},a.extend(b,f.defaults,{content:{ajax:{loading:b,once:b}}}),g.imagemap=function(b,c,d){function n(a,b,c){var d=0,e=1,f=1,g=0,h=0,i=a.width,j=a.height;while(i>0&&j>0&&e>0&&f>0){i=Math.floor(i/2),j=Math.floor(j/2),c.x==="left"?e=i:c.x==="right"?e=a.width-i:e+=Math.floor(i/2),c.y==="top"?f=j:c.y==="bottom"?f=a.height-j:f+=Math.floor(j/2),d=b.length;while(d--){if(b.length<2)break;g=b[d][0]-a.offset.left,h=b[d][1]-a.offset.top,(c.x==="left"&&g>=e||c.x==="right"&&g<=e||c.x==="center"&&(ga.width-e)||c.y==="top"&&h>=f||c.y==="bottom"&&h<=f||c.y==="center"&&(ha.height-f))&&b.splice(d,1)}}return{left:b[0][0],top:b[0][1]}}b.jquery||(b=a(b));var e=(b[0].shape||b.attr("shape")).toLowerCase(),f=(b[0].coords||b.attr("coords")).split(","),g=[],h=a('img[usemap="#'+b.parent("map").attr("name")+'"]'),i=h.offset(),j={width:0,height:0,offset:{top:1e10,right:0,bottom:0,left:1e10}},k=0,l=0,m;i.left+=Math.ceil((h.outerWidth()-h.width())/2),i.top+=Math.ceil((h.outerHeight()-h.height())/2);if(e==="poly"){k=f.length;while(k--)l=[parseInt(f[--k],10),parseInt(f[k+1],10)],l[0]>j.offset.right&&(j.offset.right=l[0]),l[0]j.offset.bottom&&(j.offset.bottom=l[1]),l[1] Date: Fri, 11 May 2012 09:38:07 +0000 Subject: [PATCH 02/21] =?UTF-8?q?Am=C3=A9lioration=20du=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/themes/default/styles/main.css | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/public/themes/default/styles/main.css b/public/themes/default/styles/main.css index 84b87b74..8624cb8a 100644 --- a/public/themes/default/styles/main.css +++ b/public/themes/default/styles/main.css @@ -377,15 +377,10 @@ table.ciblage td { text-decoration: none; } - - - - - #economique { font-size:13px; - text-shadow: 1px 1px 1px white; + } #economique select { @@ -393,7 +388,6 @@ table.ciblage td { } #economique li { - height:20px; padding:5px; border:1px solid silver; margin-top:2px; @@ -438,13 +432,11 @@ table.ciblage td { margin-top:12px; margin-left:5px; color:red; - text-shadow: 1px 1px white; } #entreprise { font-size:13px; - text-shadow: 1px 1px 1px white; } #entreprise select { @@ -492,7 +484,6 @@ table.ciblage td { #financiere { font-size:13px; - text-shadow: 1px 1px 1px white; } #financiere select { @@ -500,7 +491,6 @@ table.ciblage td { } #financiere li { - height:20px; padding:5px; border:1px solid silver; margin-top:2px; @@ -534,7 +524,6 @@ table.ciblage td { #geographique { font-size:13px; - text-shadow: 1px 1px 1px white; } #geographique select { @@ -542,7 +531,6 @@ table.ciblage td { } #geographique li { - height:20px; padding:5px; border:1px solid silver; margin-top:2px; @@ -569,7 +557,6 @@ table.ciblage td { } #juridique li { - height:20px; padding:5px; border:1px solid silver; margin-top:2px; From daabfd826a75980a8ab1ca29b60cc506960581b2 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 11 May 2012 12:26:16 +0000 Subject: [PATCH 03/21] =?UTF-8?q?Modification=20structure=20des=20d=C3=A9f?= =?UTF-8?q?initions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/ComptageController.php | 3 +- .../controllers/EconomiqueController.php | 3 +- .../controllers/EntrepriseController.php | 3 +- .../controllers/FinancierController.php | 3 +- .../controllers/GeographiqueController.php | 3 +- application/controllers/IndexController.php | 6 +- .../controllers/JuridiqueController.php | 3 +- application/views/default/helpers/Field.php | 275 ++-- .../default/scripts/economique/index.phtml | 50 +- .../default/scripts/entreprise/index.phtml | 32 +- .../default/scripts/financier/index.phtml | 64 +- .../default/scripts/geographique/index.phtml | 41 +- .../default/scripts/index/criteres.phtml | 1 + .../default/scripts/juridique/index.phtml | 19 +- .../Controller/Plugin/Comptage.php | 3 +- library/Scores/Ciblage.php | 125 +- library/Scores/Field.php | 1151 ----------------- library/Scores/Fields.php | 1055 +++++++++++++++ library/Scores/SessionCiblage.php | 144 --- public/themes/default/scripts/fields.js | 2 + 20 files changed, 1382 insertions(+), 1604 deletions(-) delete mode 100644 library/Scores/Field.php create mode 100644 library/Scores/Fields.php delete mode 100644 library/Scores/SessionCiblage.php diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 163a9012..ef58e41e 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -65,8 +65,7 @@ class ComptageController extends Zend_Controller_Action $criteres = $criteresRow->current(); $structure = json_decode($criteres->criteres, true); - require_once 'Scores/Field.php'; - $field = new Fields(); + $field = new Scores_Fields(); $values = $field->getValues($structure); //Comptage diff --git a/application/controllers/EconomiqueController.php b/application/controllers/EconomiqueController.php index fc004134..907707fb 100644 --- a/application/controllers/EconomiqueController.php +++ b/application/controllers/EconomiqueController.php @@ -8,8 +8,7 @@ class EconomiqueController extends Zend_Controller_Action public function indexAction() { - require_once('Scores/Field.php'); - $field = new Fields(); + $field = new Scores_Fields(); $this->view->fields = $field; } diff --git a/application/controllers/EntrepriseController.php b/application/controllers/EntrepriseController.php index cbad1276..c44bf424 100644 --- a/application/controllers/EntrepriseController.php +++ b/application/controllers/EntrepriseController.php @@ -8,8 +8,7 @@ class EntrepriseController extends Zend_Controller_Action public function indexAction() { - require_once('Scores/Field.php'); - $field = new Fields(); + $field = new Scores_Fields(); $this->view->fields = $field; } diff --git a/application/controllers/FinancierController.php b/application/controllers/FinancierController.php index 3f7760e5..410e7fb4 100644 --- a/application/controllers/FinancierController.php +++ b/application/controllers/FinancierController.php @@ -9,10 +9,9 @@ class FinancierController extends Zend_Controller_Action public function indexAction() { - require_once('Scores/Field.php'); $auth = Zend_Auth::getInstance(); $user = $auth->getIdentity(); - $field = new Fields(); + $field = new Scores_Fields(); $this->view->fields = $field; } diff --git a/application/controllers/GeographiqueController.php b/application/controllers/GeographiqueController.php index 1e7f9b88..c3738e82 100644 --- a/application/controllers/GeographiqueController.php +++ b/application/controllers/GeographiqueController.php @@ -9,10 +9,9 @@ class GeographiqueController extends Zend_Controller_Action public function indexAction() { - require_once('Scores/Field.php'); $auth = Zend_Auth::getInstance(); $user = $auth->getIdentity(); - $field = new Fields(); + $field = new Scores_Fields(); $this->view->fields = $field; } diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index a44d987a..fad839da 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -24,11 +24,9 @@ Class IndexController extends Zend_Controller_Action if($ajax) $this->_helper->layout()->disableLayout(); - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); + $session = new Scores_Fields(); - require_once 'Scores/Field.php'; - $this->view->field = new Fields(); + $this->view->field = $session; $this->view->criteres = $session->getCriteres(); } diff --git a/application/controllers/JuridiqueController.php b/application/controllers/JuridiqueController.php index ad37a041..22b8328d 100644 --- a/application/controllers/JuridiqueController.php +++ b/application/controllers/JuridiqueController.php @@ -9,8 +9,7 @@ class JuridiqueController extends Zend_Controller_Action public function indexAction() { - require_once('Scores/Field.php'); - $field = new Fields(); + $field = new Scores_Fields(); $this->view->fields = $field; } diff --git a/application/views/default/helpers/Field.php b/application/views/default/helpers/Field.php index 71352277..c4774388 100644 --- a/application/views/default/helpers/Field.php +++ b/application/views/default/helpers/Field.php @@ -1,85 +1,146 @@ name = $name; + + //Read the dico + $fields = new Scores_Fields(); + $params = $fields->get($name); + $html = ''; - if($field != null) { - $html.= '
'; - if($type == null) - $type = $field['type']; - switch($type) + + $label = $labelG = $fields->getLibelle($name); + + //How many type of fields is defined + $nbFields = count($params['fields']); + + $this->display = true; + + //If more than one field exist we need to make a special display + if ( $nbFields > 1) { + $html.= '
'; + $html.= $this->structureLabel($label); + $html.= '
'; + foreach ( $params['fields'] as $type => $options ) { - case 'select': - $html.= $this->structureHTML( - $field['label'], - $this->selectHTML($name, $field)); - break; - case 'selectMultiple': - $html.= $this->structureHTML( - $field['label'], - $this->selectMultipleHTML($name, $field)); - break; - case 'intervalSelect': - $html.= $this->structureHTML( - $field['label'], - $this->intervalSelectHTML($name, $field)); - break; - case 'interval': - $html.= $this->structureHTML( - $field['label'], - $this->intervalHTML($name, $field)); - break; - case 'date': - $html.= $this->structureHTML( - $field['label'], - $this->dateHTML($name, $field)); - break; - case 'text': - switch($name) { - case 'reg': - $label = 'Régions'; - break; - case 'vil': - case 'adr_com': - $label = 'Villes'; - break; - case 'dep': - $label = 'Départements'; - break; - default: - $label = $field['label']; - } - $html.= $this->structureHTML( - $label, - $this->textHTML($name, $field, $name), $field['help'][ucfirst($name)]); - break; - case 'textarea': - $html.= $this->structureHTML( - $field['label'], - $this->textareaHTML($name, $field)); - break; - case 'radio': - $html.= $this->structureHTML( - $field['label'], - $this->radioHTML($name, $field)); - break; - case 'file': - $html.= $this->structureHTML( - $field['label'], - $this->fileuploadHtml($name, $field)); - break; + switch ($type) { + case 'tree': + $href = $this->view->url(array('controller' => 'arborescence', 'action' => $options['action'], 'key' => $name)); + $html.= ''; + $html.= ''; + $html.= ''; + break; + case 'text': + $html.= ''; + break; + } + $html.= ' '; } $html.= '
'; + $html.= '
'; + //Masquer les champs + $this->display = false; + } + + //Draw fields + foreach ( $params['fields'] as $type => $options ) + { + $label = $labelG; + if ( array_key_exists('label', $options) ) { + $label = $options['label']; + } + + switch($type) + { + case 'select': + $html.= $this->structureHTML( + $label, + $this->selectHTML($name, $options) + ); + break; + case 'selectMultiple': + $html.= $this->structureHTML( + $label, + $this->selectMultipleHTML($name, $options) + ); + break; + case 'intervalSelect': + $html.= $this->structureHTML( + $label, + $this->intervalSelectHTML($name, $options) + ); + break; + case 'interval': + $html.= $this->structureHTML( + $label, + $this->intervalHTML($name, $field) + ); + break; + case 'date': + $html.= $this->structureHTML( + $field['label'], + $this->dateHTML($name, $field)); + break; + case 'text': + switch($name) { + case 'reg': + $label = 'Régions'; + break; + case 'dep': + $label = 'Départements'; + break; + } + $html.= $this->structureHTML( + $label, + $this->textHTML($name, $options) + ); + break; + case 'textarea': + $html.= $this->structureHTML( + $field['label'], + $this->textareaHTML($name, $field)); + break; + case 'radio': + $html.= $this->structureHTML( + $field['label'], + $this->radioHTML($name, $field)); + break; + case 'file': + $html.= $this->structureHTML( + $field['label'], + $this->fileuploadHtml($name, $field)); + break; + case 'tree': + //Do nothing + break; + default: + $html.= $this->structureHTML($label, ''); + break; + + } } return $html; } - private function structureHTML($label, $html, $help = null) + private function structureHTML($label, $html) { $out = ''; - $out.= $this->structureLabel($label, $help); + + $style = ''; + $class = ' class="fieldgrp"'; + if ( $this->display===false ) { + $style = ' style="display:none;"'; + $class = ' class="fieldgrp '.$this->name.'"'; + } + $out.= '
'; + $out.= $this->structureLabel($label); $out.= '
'.$html.'
'; + $out.= '
'; return $out; } @@ -87,33 +148,31 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract * Définition du label * @param unknown_type $label */ - private function structureLabel($label, $help) + private function structureLabel($label) { $return = ''; - if($help) - $return .= '

'.$help.'

'; - - - return ($return); + return $return; } protected function getMinMax($name, $valeur) { if(!empty($name)) { - $default = Fields::getMinMax($name); + $default = Scores_Fields::getMinMax($name); if(empty($valeur[0])){$valeur[0] = $default[0]['min'];} if(empty($valeur[1])){$valeur[1] = $default[0]['max'];} } return ($valeur); } - private function intervalSelectHTML($name, $field) + private function intervalSelectHTML($name, $options) { - $session = new SessionCiblage(); + $session = new Scores_Fields(); $sessionValeur = explode(',', $session->getCritere($name)); + $minMax = $this->getMinMax($name, array(0,0)); + $return = ' à '; $return .= ''; - $return .= ''; - foreach($field['fields'][$field['type']]['value'] as $value => $label) { + + $return = ''; - return ($return); + return $return; } /* Select Multiple */ - private function selectHTML($name, $field) + private function selectHTML($name, $options) { - $session = new SessionCiblage(); - + $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); + if(is_array($sessionValeur)) $sessionValeur = implode(',', $sessionValeur); - $return = ''; $return .= ''; - foreach($field['fields'][$field['type']]['value'] as $value => $label) { + + foreach($options['value'] as $value => $label) { $selected = ""; - if(($sessionValeur != null) and $sessionValeur == $value and $sessionValeur != "-") + if( $sessionValeur!==null && $sessionValeur==$value && $sessionValeur != "-") $selected = " selected"; $return .= ''.$label.''; } $return .= ''; - return ($return); + + return $return; } /* Interval */ private function intervalHTML($name, $field) { - $session = new SessionCiblage(); + $session = new Scores_Fields(); $valeur = $session->getCritere($name); $valeur = explode(',', $valeur); @@ -187,13 +250,13 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $return .= ' Valider'; $return .= '
'; - return ($return); + return $return; } /* Dates */ private function dateHTML($name, $field) { - $session = new SessionCiblage(); + $session = new Scores_Fields(); $return = '
'; $return .= ' a '; @@ -204,9 +267,9 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract } /* Textes */ - private function textHTML($name, $field, $name) + private function textHTML($name, $options) { - $session = new SessionCiblage(); + $session = new Scores_Fields(); switch($name) { case 'ape_entrep': case 'ape_etab': @@ -230,10 +293,10 @@ Class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $type= $name; break; } - /* Modifier les données */ - $return = ''; - $return .= 'Valider Aide'; - return ($return); + $return = ''; + $return .= 'Sélectionner'; + $return .= ' Exclure'; + return $return; } /* Textarea */ diff --git a/application/views/default/scripts/economique/index.phtml b/application/views/default/scripts/economique/index.phtml index fd846ad3..9b6e08cf 100644 --- a/application/views/default/scripts/economique/index.phtml +++ b/application/views/default/scripts/economique/index.phtml @@ -1,46 +1,26 @@
    -
  • Field('capital', $this->fields->get('capital'));?>
  • -
  • Field('ape_etab', $this->fields->get('ape_etab'));?>
  • - - -
  • Field('age_etab', $this->fields->get('age_etab'));?>
  • -
  • Field('teff_etab', $this->fields->get('teff_etab'));?>
  • -
  • Field('teff_etabM', $this->fields->get('teff_etabM'));?>
  • -
  • Field('eff_etab', $this->fields->get('eff_etab'));?>
  • -
-
- +
  • Field('capital')?>
  • +
  • Field('ape_etab')?>
  • +
  • Field('age_etab')?>
  • +
  • Field('teff_etab')?>
  • +
  • Field('teff_etabM')?>
  • +
  • Field('eff_etab')?>
  • + +

    +
    Réinitialiser les critères economiques diff --git a/application/views/default/scripts/entreprise/index.phtml b/application/views/default/scripts/entreprise/index.phtml index 68179e55..f09bbae7 100644 --- a/application/views/default/scripts/entreprise/index.phtml +++ b/application/views/default/scripts/entreprise/index.phtml @@ -4,26 +4,26 @@
      -
    • Field('siege', $this->fields->get('siege'));?>
    • -
    • Field('sirenGrp', $this->fields->get('sirenGrp'));?>
    • -
    • Field('tel', $this->fields->get('tel'));?>
    • -
    • Field('fax', $this->fields->get('fax'));?>
    • -
    • Field('web', $this->fields->get('web'));?>
    • -
    • Field('mail', $this->fields->get('mail'));?>
    • -
    • Field('present cs', $this->fields->get('presentRcs'));?>
    • -
    • Field('adrDom', $this->fields->get('adrDom'));?>
    • -
    • Field('dirNom', $this->fields->get('dirNom'));?>
    • -
    • Field('dateCrea_etab', $this->fields->get('dateCrea_etab'));?>
    • -
    • Field('part', $this->fields->get('part'));?>
    • +
    • Field('siege');?>
    • +
    • Field('sirenGrp');?>
    • +
    • Field('tel');?>
    • +
    • Field('fax');?>
    • +
    • Field('web');?>
    • +
    • Field('mail');?>
    • +
    • Field('presentRcs');?>
    • +
    • Field('adrDom');?>
    • +
    • Field('dirNom');?>
    • +
    • Field('dateCrea_etab');?>
    • +
    • Field('part');?>

    diff --git a/application/views/default/scripts/financier/index.phtml b/application/views/default/scripts/financier/index.phtml index 0a8f1f43..a3b4b88e 100644 --- a/application/views/default/scripts/financier/index.phtml +++ b/application/views/default/scripts/financier/index.phtml @@ -1,53 +1,29 @@

    -
      -
    • - -
      - Field('bilType', $this->fields->get('bilType'));?> -
      - Valeurs exclusions : -
    • -
    • - -
      - Field('avisCs', $this->fields->get('avisCs'));?> -
      - Valeurs exclusions : -
    • -
    • Field('bilAnnee', $this->fields->get('bilAnnee'));?>
    • -
    • Field('bilCloture', $this->fields->get('bilCloture'));?>
    • -
    • Field('bilDuree', $this->fields->get('bilDuree'));?>
    • -
    • - -
      - Field('bilTca', $this->fields->get('bilTca'));?> -
      - Valeurs exclusions : -
    • -
    • Field('bilFL', $this->fields->get('bilFL'));?>
    • +
        +
      • Field('bilType')?>
      • +
      • Field('avisCs')?>
      • +
      • Field('bilAnnee')?>
      • +
      • Field('bilCloture')?>
      • +
      • Field('bilDuree')?>
      • +
      • Field('bilTca')?>
      • +
      • Field('bilFL')?>

    diff --git a/application/views/default/scripts/geographique/index.phtml b/application/views/default/scripts/geographique/index.phtml index 628114bb..75955e8e 100644 --- a/application/views/default/scripts/geographique/index.phtml +++ b/application/views/default/scripts/geographique/index.phtml @@ -1,36 +1,17 @@

      -
    • Field('adr_com', $this->fields->get('adr_com'));?>
    • -
    • + Field('adr_com')?> + Exclure DOM-TOM
      + Exclure Etranger
      + Exclure Corse
    • - -
    • - Exclure DOM-TOM
      - Exclure Etranger
      - Exclure Corse
      -
    • -
    • Field('zus', $this->fields->get('zus'), 'select');?>
    • -
    • Field('zru', $this->fields->get('zru'), 'select');?>
    • -
    • Field('zfu', $this->fields->get('zfu'), 'select');?>
    • -
    • Field('cucs', $this->fields->get('cucs'), 'select');?>
    • -
    • Field('zrr', $this->fields->get('zrr'), 'select');?>
    • -
    • Field('zafr', $this->fields->get('zafr'), 'select');?>
    • +
    • Field('zus')?>
    • +
    • Field('zru')?>
    • +
    • Field('zfu')?>
    • +
    • Field('cucs')?>
    • +
    • Field('zrr')?>
    • +
    • Field('zafr')?>
    diff --git a/application/views/default/scripts/index/criteres.phtml b/application/views/default/scripts/index/criteres.phtml index da2d4256..6ec3eea4 100644 --- a/application/views/default/scripts/index/criteres.phtml +++ b/application/views/default/scripts/index/criteres.phtml @@ -4,6 +4,7 @@ } #criteres { border: 1px solid; + padding:10px 0; } #criteres tr td { diff --git a/application/views/default/scripts/juridique/index.phtml b/application/views/default/scripts/juridique/index.phtml index d82e61ab..0df79166 100644 --- a/application/views/default/scripts/juridique/index.phtml +++ b/application/views/default/scripts/juridique/index.phtml @@ -1,24 +1,15 @@
      -
    • Field('cj', $this->fields->get('cj'));?>
    • - -
    • Field('actifEco', $this->fields->get('actifEco'));?>
    • -
    • Field('procolHisto', $this->fields->get('procolHisto'));?>
    • -
    • Field('dateImmat', $this->fields->get('dateImmat'));?>
    • +
    • Field('cj');?>
    • +
    • Field('actifEco', $this->fields->get('actifEco'));?>
    • +
    • Field('procolHisto', $this->fields->get('procolHisto'));?>
    • +
    • Field('dateImmat', $this->fields->get('dateImmat'));?>

    diff --git a/library/Application/Controller/Plugin/Comptage.php b/library/Application/Controller/Plugin/Comptage.php index 17d2a20d..380227ae 100644 --- a/library/Application/Controller/Plugin/Comptage.php +++ b/library/Application/Controller/Plugin/Comptage.php @@ -9,8 +9,7 @@ class Application_Controller_Plugin_Comptage extends Zend_Controller_Plugin_Abst $action = $request->getActionName(); if ($controller == 'index' && $action == 'index') { - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); + $session = new Scores_Fields(); $view = $layout->getView(); $auth = Zend_Auth::getInstance(); diff --git a/library/Scores/Ciblage.php b/library/Scores/Ciblage.php index 4e2897ce..fe8bbf45 100644 --- a/library/Scores/Ciblage.php +++ b/library/Scores/Ciblage.php @@ -1,55 +1,86 @@ need) {*/ - if(!empty($name)) { - $default = Fields::getMinMax($name); + /** + * Construct request + * @var string + */ + protected $alpha = ''; + protected $presentRcs = 0; - if(empty($valeur[0])){$valeur[0] = $default[0]['min'];} - if(empty($valeur[1])){$valeur[1] = $default[0]['max'];} - } - return ($valeur); - /*}*/ - return ($valeur); - } + /** + * + * @param array $structure + * @param boolean $need + */ public function __construct($structure, $need = false) { + /* + * First of all we need to load the Sphinx API + * @todo : Make a test and load the right version of API + */ + require_once 'sphinxapi/sphinxapi-2.0.4.php'; + $this->need = true; + + //Load configuration from registry $configuration = Zend_Registry::get('configuration'); - //Instantiation Sphinx + //Sphinx init $this->sphinx = new SphinxClient(); $this->sphinx->SetServer($configuration->sphinx->host, intval($configuration->sphinx->port)); $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2); $this->sphinx->ResetFilters(); + + // foreach($structure as $key => $valeur) { if (method_exists($this, $key)) { if(is_array($valeur)) { if(isset($valeur[0])) { - if($valeur[0] != "" and $valeur[0] != 'tous') + if($valeur[0] != "" and $valeur[0] != '-') $this->$key($valeur); } } else { - if($valeur != 'tous' and $valeur != "") + if($valeur != '-' and $valeur != "") $this->$key($valeur); } } } } + + protected function setMinMax($name, $valeur) + { + if(!empty($name)) { + $default = Fields::getMinMax($name); + + if(empty($valeur[0])){ + $valeur[0] = $default[0]['min']; + } + if(empty($valeur[1])){ + $valeur[1] = $default[0]['max']; + } + } + return ($valeur); + } + public function extract() { $resultats = $this->execute(true); @@ -64,12 +95,17 @@ Class Ciblage ); return $total; } + public function calculRedevanceInsee() { $this->sphinx->SetFilter('presentrcs', array(0)); $resSphinx = $this->sphinx->Query($this->alpha, $this->index); return ($resSphinx['total_found']); } + + + + protected function getSiret($structure) { $siret = array(); @@ -84,6 +120,7 @@ Class Ciblage public function execute($need = false, $limitD = false) { Zend_Registry::get('firebug')->info("Sphinx : "); + Zend_Registry::get('firebug')->info($this->alpha); if($need) { $return = array(); $limit = 0; @@ -101,15 +138,18 @@ Class Ciblage } Zend_Registry::get('firebug')->info($resSphinx); - return ($resSphinx['total_found']); + return $resSphinx['total_found']; } - protected function setFilter($name, $valeur, $ex = false) { + + protected function setFilter($name, $valeur, $ex = false) + { if(!is_array($valeur)) { - $this->sphinx->SetFilter($name, array(intval($valeur)),($ex)?true:false); + $this->sphinx->SetFilter($name, array(intval($valeur)), $ex); }else { - $this->sphinx->SetFilter($name, $this->transformIntval($valeur), ($ex)?true:false); + $this->sphinx->SetFilter($name, $this->transformIntval($valeur), $ex); } } + protected function setFilterRange($name, $valeur) { $this->sphinx->SetFilterRange($name, intval($valeur[0]), intval($valeur[1])); } @@ -126,26 +166,19 @@ Class Ciblage return ($depts); } protected function writeRequest($name, $valeur, $ex, $or = false) { - if(in_array($name, array('adr_com_ex', 'adr_dept_ex', 'bilType_ex', 'ape_etab_ex', 'ape_entrep_ex'))) { - if(!strstr($this->alpha, 'adr_dept') or - !strstr($this->alpha, 'ape_etab') or + if(in_array($name, array('bilType_ex', 'ape_etab_ex', 'ape_entrep_ex'))) { + if(!strstr($this->alpha, 'ape_etab') or !strstr($this->alpha, 'bilType') or !strstr($this->alpha, 'ape_entrep')) { $this->alpha .= ' @exclu (ex) '; } switch($name) { - case 'adr_com_ex': - $name = 'adr_com'; - break; case 'ape_entrep_ex': $name = 'ape_entrep'; break; case 'ape_etab_ex': $name = 'ape_etab'; break; - case 'adr_dept_ex': - $name = 'adr_dept'; - break; case 'bilType_ex': $name = 'bilType'; break; @@ -168,7 +201,7 @@ Class Ciblage } protected function setAlpha($name, $valeur, $ex = false) { - $or = array('adr_com', 'adr_dept', 'adr_com_ex', 'adr_dept_ex'); + $or = array('adr_com', 'adr_dep', 'adr_com_ex', 'adr_dep_ex'); $and = array('bilType', 'ape_etab_ex', 'ape_etab','ape_entrep', 'ape_entrep_ex', 'NaceEntrep', 'NaceEtab', 'bilType_ex'); if(!empty($this->alpha)) $this->alpha .= ' '; @@ -200,29 +233,29 @@ Class Ciblage protected function ex_domtom($valeur) { if($valeur == 1) { - $this->setAlpha('adr_dept_ex', array(971, 972, 973, 974, 976), true); + $this->setFilter('adr_dep', array(971, 972, 973, 974, 976), true); } } protected function ex_entr($valeur) { if($valeur == 1) { - $this->setAlpha('adr_dept_ex', array(986, 987, 988), true); + $this->setFilter('adr_dep', array(986, 987, 988), true); } } protected function ex_corse($valeur) { if($valeur == 1) { - $this->setAlpha('adr_dept_ex', array(200), true); + $this->setFilter('adr_dep', array(201, 202), true); } } protected function adr_com_ex($valeur) { $this->setAlpha('adr_com_ex', $valeur, true); } - protected function adr_dept($valeur) { - $this->setAlpha('adr_dept', $valeur); + protected function adr_dep($valeur) { + $this->setAlpha('adr_dep', $valeur); } - protected function adr_dept_ex($valeur) { - $this->setAlpha('adr_dept_ex', $valeur, true); + protected function adr_dep_ex($valeur) { + $this->setAlpha('adr_dep_ex', $valeur, true); } protected function action($valeur) { $this->setFilter('action', $valeur); diff --git a/library/Scores/Field.php b/library/Scores/Field.php deleted file mode 100644 index 205225f3..00000000 --- a/library/Scores/Field.php +++ /dev/null @@ -1,1151 +0,0 @@ - array( - * label => - * fields => array( - * select => array() - * ... - * ) - * famille => - * activated => - * type => - * - * export => array( //Si présent paramètres pour l'enrichissement - * 'label' => Libellé pour affichage dans l'enrichissement - * 'valuedesc' => array( / valeur => libellé / ) - * ) - * ) - */ -Class Fields -{ - protected $fields = array - ( - 'siege' => array( - 'label' => 'Type d\'établissement', - 'fields' => array( - 'select' => array('value' => array('1' => 'Sièges', '0' => 'Secondaires')), - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - ), - 'sirenGrp' => array( - 'label' => 'Présence d\'un groupe', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select' - ), - 'tel' => array( - 'label' => 'Téléphone renseigné', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select' - ), - 'fax' => array( - 'label' => 'Télécopie renseignée', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'web' => array( - 'label' => 'Site Web renseigné', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'mail' => array( - 'label' => 'Email de contact renseigné', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'presentRcs' => array( - 'label' => 'Etablissement présent au RNCS', - 'fields' => array( - 'select' => array('value' => array('1' => 'Etablissement présent au RNCS', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'adrDom' => array( - 'label' => 'Adresse de domiciliation', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'dirNom' => array( - 'label' => 'Nom du principal dirigeant', - 'fields' => array( - 'select' => array('value' => array('1' => 'Principal dirigeant renseigné', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'lieuAct' => array( - 'label' => 'Lieu d\'activté', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')), - 'textarea' => array('value' => null) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'textarea', - 'class' => null - ), - 'nbMPubli' => array( - 'label' => 'Marchés publiques remportés', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'dateCrea_ent' => array( - 'label' => 'Date de création de l\'entreprise', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'interval', - 'class' => 'datepicker' - ), - 'dateCrea_etab' => array( - 'label' => 'Date de création de l\'établissement', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'interval', - 'class' => 'datepicker' - ), - 'action' => array( - 'label' => 'Présence d\'actionnaires', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'nbActio' => array( - 'label' => 'Nombre d\'actionnaires connus', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'part' => array( - 'label' => 'Nombre de participations connues', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'nbPart' => array( - 'label' => 'Nombre de participations connues', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'entreprise', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - // economique - 'ape_etab' => array( - 'label' => 'Activité de l\'établissement (Code NAF)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'naf', - 'title' => 'Selection des codes NAF etablissement' - ), - 'ape_etab_ex' => array( - 'label' => 'Activité de l\'établissement (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'naf', - 'title' => 'Selection des codes NAF etablissement' - ), - 'ape_entrep' => array( - 'label' => 'Activité de l\'entreprise (Code NAF)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'naf', - 'title' => 'Selection des codes NAF entreprise' - ), - 'ape_entrep_ex' => array( - 'label' => 'Activité de l\'entreprise (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'naf', - 'title' => 'Selection des codes NAF entreprise' - ), - 'NaceEtab' => array( - 'label' => 'Code NACE de l\'établissement', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null - ), - 'NaceEntrep' => array( - 'label' => 'Code NACE de l\'entreprise', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null - ), - 'age_etab' => array( - 'label' => 'Age de l\'entreprise', - 'fields' => array( - 'interval' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'age_entrep' => array( - 'label' => 'Age de l\'établissement', - 'fields' => array( - 'interval' => array('value' => null) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'teff_entrep' => array( - 'label' => 'Tranche d\'effectif de l\'Entreprise', - 'fields' => array( - 'intervalSelect' => array('value' => array( - array('0', '1 ou 2'), - array('1', '3 ou 5'), - array('2', '3'), - array('3', '11'), - array('11', '12'), - array('12', '21'), - array('21', '22'), - array('22', '31'), - array('31', '32'), - array('32', '41'), - array('41', '42'), - array('42', '51'), - array('51', '52'), - array('52', '53'), - array('53', '0') - )) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'intervalSelect', - 'class' => null, - ), - 'teff_etab' => array( - 'label' => 'Tranche d\'effectif de l\'établissement', - 'fields' => array( - 'intervalSelect' => array( - 'value' => array( - array('0', '1'), - array('1', '2'), - array('2', '3'), - array('3', '11'), - array('11', '12'), - array('12', '21'), - array('21', '22'), - array('22', '31'), - array('31', '32'), - array('32', '41'), - array('41', '42'), - array('42', '51'), - array('51', '52'), - array('52', '53'), - array('53', '0') - ) - ) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'intervalSelect', - 'class' => null - ), - 'teff_etabM' => array( - 'label' => 'Tranche d\'effectif de l\'établissement M', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'teff_entrepM' => array( - 'label' => 'Tranche d\'effectif de l\'entreprise M', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'nbEtab' => array( - 'label' => 'Nombre d\'établissements', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'eff_entrep' => array( - 'label' => 'Effectif réel de l\'entreprise', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'eff_etab' => array( - 'label' => 'Effectif réel de l\'établissement', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'capital' => array( - 'label' => 'Capital de l\'entreprise', - 'fields' => array( - 'intervalSelect' => array( - 'value' => array( - array(0, 15000), - array(15000, 30000), - array(30000, 75000), - array(75000, 150000), - array(150000, 750000), - array(750000, 0), - ) - ) - ), - 'famille' => 'economique', - 'activated' => true, - 'type' => 'intervalSelect', - 'class' => null - ), - //geographique - 'adr_com' => array( - 'label' => 'Localisation géographique', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'adr_com_ex' => array( - 'label' => 'Localisation Villes (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'adr_dept' => array( - 'label' => 'Liste départements', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'adr_dept_ex' => array( - 'label' => 'Liste départements (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'ex_domtom' => array( - 'label' => 'Exclusion des Dom-Tom', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - 'class' => null, - 'action' => '', - 'title' => 'Localisation' - ), - 'ex_entr' => array( - 'label' => 'Exclusion départements étrangés', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - 'class' => null, - 'action' => '', - 'title' => 'Localisation' - ), - 'ex_corse' => array( - 'label' => 'Exclusion corse', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - 'class' => null, - 'action' => '', - 'title' => 'Localisation' - ), - 'adr_reg' => array( - 'label' => 'Liste code région', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'adr_reg_ex' => array( - 'label' => 'Liste code région (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), - 'zus' => array( - 'label' => 'Zones urbaines sensibles', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - 'zru' => array( - 'label' => 'Zones de redynamisation urbaine', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - 'zfu' => array( - 'label' => 'zones franches urbaines', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - 'cucs' => array( - 'label' => 'Contrats urbains de cohésion sociale', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - 'zrr' => array( - 'label' => 'Zone de revitalisation rurale', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - 'zafr' => array( - 'label' => 'Zones Aide à finalité régionale', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'select', - ), - //juridique - 'cj' => array( - 'label' => 'Forme Juridique', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'juridique', - 'title' => 'Forme Juridique' - ), - 'cj_ex' => array( - 'label' => 'Forme Juridique (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'juridique', - 'title' => 'Forme Juridique' - ), - 'actifEco' => array( - 'label' => 'Établissement économiquement actif', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'procolHisto' => array( - 'label' => 'Présence procédure collective dans histo', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'tvaIntraValide' => array( - 'label' => 'Numéro de TVA intracommunautaire valide', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'select', - 'class' => null - ), - 'dateImmat' => array( - 'label' => 'Date d\'immatriculation', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'juridique', - 'activated' => true, - 'type' => 'interval', - 'class' => 'datepicker' - ), - //financier - 'bilType' => array( - 'label' => 'Type du dernier bilan', - 'fields' => array( - 'selectMultiple' => array('value' => array( - 'I' => 'Inconnue', - 'R' => 'Réel', - 'E' => 'Estimé') - ), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'bilType_ex' => array( - 'label' => 'Type du dernier bilan (Exclure)', - 'fields' => array( - 'selectMultiple' => array('value' => array( - 'I' => 'Inconnue', - 'R' => 'Réel', - 'E' => 'Estimé') - ), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'avisCs' => array( - 'label' => 'Informations de paiements', - 'fields' => array( - 'selectMultiple' => array('value' => array( - '' => 'Risque indéterminé', - '00' => 'Aucun risque resencé', - '10' => 'Présence d\'impayé(s)', - '15' => 'Présence de privilèges', - '23-29-39-43' => 'Risque moyen', - '21-26-28' => 'Risque important', - '31-50' => 'Risque très important', - '24' => 'Risque dans le groupe') - ), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'avisCs_ex' => array( - 'label' => 'Informations de paiements (Exclure)', - 'fields' => array( - 'selectMultiple' => array('value' => array( - '' => 'Risque indéterminé', - '00' => 'Aucun risque resencé', - '10' => 'Présence d\'impayé(s)', - '15' => 'Présence de privilèges', - '23-29-39-43' => 'Risque moyen', - '21-26-28' => 'Risque important', - '31-50' => 'Risque très important', - '24' => 'Risque dans le groupe') - ), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'bilDuree' => array( - 'label' => 'Durée du dernier bilan en mois', - 'fields' => array( - 'intervalSelect' => array( - 'value' => array( - array(0, 5), - array(5, 10), - array(10, 15), - array(20, 23), - array(23, 0) - ) - ) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'intervalSelect', - 'class' => null - ), - 'bilTca' => array( - 'label' => 'Tranche de CA issue du bilan', - 'fields' => array( - 'selectMultiple' => array('value' => array( - '0' => 'Non déterminée', - '1' => 'de 500K€ à1M€', - '2' => 'de 1 à 2 ME', - '3' => 'de 2 à 5 ME', - '4' => 'de 5 à 10 ME', - '5' => 'de 10 à 20 ME', - '6' => 'de 20 à 50 ME', - '7' => '50 à 100 ME', - '8' => 'de 100 à 200 ME', - '9' => '+ de 200 ME' - )), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'bilTca_ex' => array( - 'label' => 'Tranche de CA issue du bilan (Exclure)', - 'fields' => array( - 'selectMultiple' => array('value' => array( - '0' => 'Non déterminée', - '1' => 'de 500K€ à1M€', - '2' => 'de 1 à 2 ME', - '3' => 'de 2 à 5 ME', - '4' => 'de 5 à 10 ME', - '5' => 'de 10 à 20 ME', - '6' => 'de 20 à 50 ME', - '7' => '50 à 100 ME', - '8' => 'de 100 à 200 ME', - '9' => '+ de 200 ME' - )), - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'selectMultiple', - 'class' => null - ), - 'bilAnnee' => array( - 'label' => 'Dernière année de bilan', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilCloture' => array( - 'label' => 'Dernière date de clôture du bilan', - 'fields' => array( - 'interval' => array('value' => array('0', '1000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => 'datepicker' - ), - 'bilEE' => array( - 'label' => 'Total bilan (EE)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilFL' => array( - 'label' => 'CA total (FL)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilFK' => array( - 'label' => 'Chiffre d\'affaires Export (FK)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilFR' => array( - 'label' => 'Produits d\'Exploitation (FR)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilGF' => array( - 'label' => 'Charges d\'Exploitation (GF)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilGP' => array( - 'label' => 'Charges Financières (GP)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilGW' => array( - 'label' => 'R.C.A.I - Résultat courant av. impôt (GW)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilHD' => array( - 'label' => 'Produits Exceptionnels (HD)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilHH' => array( - 'label' => 'Charges Exceptionnels (HH)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilHL' => array( - 'label' => 'Total des Produits (HL)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilHM' => array( - 'label' => 'Total des Charges (HM)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilHN' => array( - 'label' => 'Résultat (HN)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ), - 'bilYP' => array( - 'label' => 'Effectif salarié (YP)', - 'fields' => array( - 'interval' => array('value' => array('0', '10000000')) - ), - 'famille' => 'financier', - 'activated' => true, - 'type' => 'interval', - 'class' => null - ) - ); - protected $requeteSql = array('cj'); - - public function getValues($val = null) - { - if ( $val === null ) { - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); - $val = $session->getCriteres(); - } - $values = array(); - foreach($val as $key => $item) - { - if($item != '') { - if( $this->fields[$key]['type'] == 'interval' or - $this->fields[$key]['type'] == 'intervalSelect' or - $this->fields[$key]['type'] == 'textarea' and - empty($this->fields[$key]['action'])) - { - $values[$key] = explode(',', $item); - } else if (!empty($this->fields[$key]['action'])) { - if(!empty($values[$key])) { - $values[$key] = array_merge($this->selectArbo($key, $item), $values[$key]); - } - else { - if($key == 'adr_reg') { - if(!empty($values['adr_dept'])) - $values['adr_dept'] = array_merge($this->selectArbo($key, $item), $values['adr_dept']); - else - $values['adr_dept'] = $this->selectArbo($key, $item); - }else { - $values[$key] = $this->selectArbo($key, $item); - } - } - } else { - $values[$key] = $item; - } - } - } - return ($values); - } - - public function selectArbo($name, $valeur) - { - $values = array(); - switch($name) - { - case 'ape_etab' : - case 'ape_entrep' : - case 'ape_etab_ex': - case 'ape_entrep_ex': - $nafs = explode(',', $valeur); - foreach($nafs as $naf) { - if($naf != ' ') { - $values = array_merge($values, $this->nafArbo($name, $naf)); - } - } - break; - case 'adr_dept': - case 'adr_reg': - case 'adr_com': - case 'adr_com_ex': - case 'adr_dept_ex': - $valeurs = explode(',', $valeur); - foreach($valeurs as $element) { - if(!empty($element)) { - $val = explode(':', $element); - if(count($val)>1) { - $diff = $this->localisationArbo($val[0], $val[1]); - if(!empty($diff)) - $array = array_diff($diff, $values); - } else if(!empty($element)) { - $diff = $this->localisationArbo($name, $element); - if(!empty($diff)) - $array = array_diff($diff, $values); - } - if(!empty($array)) { - $values = array_merge($values, $array); - } - } - } - break; - case 'cj': - case 'cj_ex': - $valeurs = explode(',', $valeur); - foreach($valeurs as $valeur) { - if($valeur != ' ' and !empty($valeur)) - $values = array_merge($values, $this->fj($name, trim($valeur))); - } - } - return ($values); - } - - protected function fj($name, $valeur) - { - require_once APPLICATION_PATH . '/models/FormeJuridique.php'; - $table = new Application_Model_FormJuridique(); - - if(strlen($valeur) < 5) { - $sql = $table->select('formejuridique', array('fjCode')) - ->where('fjCode LIKE "'.$valeur.'%"'); - } else { - $sql = $table->select('formejuridique', array('fjCode')) - ->where('fjCode = "'.$valeur.'"'); - } - $result = $table->fetchAll($sql)->toArray(); - foreach ($result as $code) { - if(strlen($code['fjCode']) > 2) { - $return[] = $code['fjCode']; - } - } - return ($return); - } - - protected function localisationArbo($name, $valeur) - { - if(strlen($valeur) == 2) { - switch($name) { - case 'adr_reg': - $table = new Application_Model_Departements(); - $sql = $table->select() - ->from('departements') - ->where('codeRegionInsee ='.$valeur) - ->setIntegrityCheck(false); - $result = $table->fetchAll($sql)->toArray(); - foreach ($result as $res) { - $return[] = trim($res['numdep']); - } - break; - case 'adr_dept': - case 'adr_dept_ex': - return (array($valeur)); - break; - } - } else - return (array($valeur)); - return ($return); - } - - protected function nafArbo($key, $valeur) - { - $value = array(); - $table = new Application_Model_Naf(); - $valeur = trim($valeur); - - if(strlen($valeur) == 1) - { - $sql = $table->select()->where('parent = ?', $valeur); - $result =$table->fetchAll($sql)->toArray(); - foreach($result as $code) $where .= " code LIKE '".trim($code['code'])."%' and niveau = 5 or "; - $where = substr($where, 0, (strlen($where)) - 3); - $sql = $table->select()->where($where); - $result = $table->fetchAll($sql)->toArray(); - foreach($result as $code) $value[] = $code['code']; - } else if(strlen($valeur) < 5){ - $sql = $table->select()->where('code LIKE "'.trim($valeur).'%" and niveau = 5'); - $result = $table->fetchAll($sql)->toArray(); - foreach($result as $code) $value[] = $code['code']; - } else if(strlen($valeur) == 5) { - $value[] = $valeur; - } - return ($value); - } - - public function __construct($batch = false) - { - if(!$batch) { - foreach($this->fields as $name => $valeur) { - if($this->fields[$name]['type'] == 'interval') { - $minmax = $this->getMinMax($name); - if(!empty($minmax)) { - $this->fields[$name]['fields'][$this->fields[$name]['type']]['value'] - = array($minmax[0]['min'], $minmax[0]['max']); - } - } - } - } - } - - static public function getMinMax($name) - { - $tab = array('dateCrea_ent','dateCrea_etab'); - if(!in_array($name, $tab)) { - $table = new Application_Model_MinMax(); - return ($table->fetchAll($table->select()->where('cle = ?', $name))->toArray()); - } - return (array()); - } - - public function getFields() { - return ($this->fields); - } - - public function get($name) { - if($this->fields[$name]['activated'] == true) - return ($this->fields[$name]); - return (null); - } - - public function getByFamille($famille) - { - $section = array(); - - foreach($this->fields as $name => $item) { - if($item['famille'] == $famille) { - $section[$name] = $item; - } - } - return ($section); - } - - public function getNotActivated($fields) - { - foreach($fields as $name => $field) - { - if(!$field['activated']) { - $desactivated[$name] = ""; - } else if ($field['activated']){ - - } - } - return (json_encode($desactivated)); - } - - public function getLibelle($name) - { - return ($this->fields[$name]['label']); - } -} \ No newline at end of file diff --git a/library/Scores/Fields.php b/library/Scores/Fields.php new file mode 100644 index 00000000..558ad7ee --- /dev/null +++ b/library/Scores/Fields.php @@ -0,0 +1,1055 @@ + array( + * label => + * fields => array( + * type => array() + * ... + * ) + * famille => + * activated => + * type => + * ) + * ) + * + * name : the key to retrieve parameters of field + * label : the string to display as title + * famille : the key to identify what familly the field belongs to + * activated : true or false + * + * fields : define all different fields for the same element + * => type : which type of element (select, text, tree, ...), it's the key for array + * => values : + * => label (optional) : + * => class : + * @var array + */ + protected $fields = array + ( + 'siege' => array( + 'label' => "Type d'établissement", + 'fields' => array( + 'select' => array('value' => array('1' => 'Sièges', '0' => 'Secondaires')), + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'sirenGrp' => array( + 'label' => "Présence d'un groupe", + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'tel' => array( + 'label' => 'Téléphone renseigné', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'fax' => array( + 'label' => 'Télécopie renseignée', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'web' => array( + 'label' => 'Site Web renseigné', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'mail' => array( + 'label' => 'Email de contact renseigné', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'presentRcs' => array( + 'label' => 'Etablissement présent au RNCS', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'adrDom' => array( + 'label' => 'Adresse de domiciliation', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'dirNom' => array( + 'label' => 'Nom du principal dirigeant présent', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + + /* What is this ? */ + 'lieuAct' => array( + 'label' => "Lieu d\'activté", + 'fields' => array( + 'interval' => array('value' => array('0', '1000')), + 'textarea' => array('value' => null) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + + 'nbMPubli' => array( + 'label' => 'Marchés publiques remportés', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'dateCrea_ent' => array( + 'label' => 'Date de création de l\'entreprise', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + + 'dateCrea_etab' => array( + 'label' => "Date de création de l'établissement", + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + + 'action' => array( + 'label' => 'Présence d\'actionnaires', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'nbActio' => array( + 'label' => 'Nombre d\'actionnaires connus', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'part' => array( + 'label' => "Présence de participations", + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'nbPart' => array( + 'label' => 'Nombre de participations connues', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'entreprise', + 'activated' => true, + ), + 'ape_etab' => array( + 'label' => "Activité de l'établissement (Code NAF)", + 'fields' => array( + 'tree' => array('value' => null, 'action' => 'naf', 'title' => "Arborescence de code NAF etablissement"), + 'text' => array('value' => null, 'label' => "Recherche de code NAF", 'title'=>"Selection de code NAF etablissement"), + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'ape_entrep' => array( + 'label' => 'Activité de l\'entreprise (Code NAF)', + 'fields' => array( + 'text' => array('value' => null), + 'textarea' => array('value' => null) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'NaceEtab' => array( + 'label' => 'Code NACE de l\'établissement', + 'fields' => array( + 'text' => array('value' => null), + 'textarea' => array('value' => null) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'NaceEntrep' => array( + 'label' => 'Code NACE de l\'entreprise', + 'fields' => array( + 'text' => array('value' => null), + 'textarea' => array('value' => null) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'age_etab' => array( + 'label' => 'Age de l\'entreprise', + 'fields' => array( + 'interval' => array('value' => null) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'age_entrep' => array( + 'label' => 'Age de l\'établissement', + 'fields' => array( + 'interval' => array('value' => null) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'teff_entrep' => array( + 'label' => 'Tranche d\'effectif de l\'Entreprise', + 'fields' => array( + 'intervalSelect' => array('value' => array( + array('0', '1 ou 2'), + array('1', '3 ou 5'), + array('2', '3'), + array('3', '11'), + array('11', '12'), + array('12', '21'), + array('21', '22'), + array('22', '31'), + array('31', '32'), + array('32', '41'), + array('41', '42'), + array('42', '51'), + array('51', '52'), + array('52', '53'), + array('53', '0') + )) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'teff_etab' => array( + 'label' => 'Tranche d\'effectif de l\'établissement', + 'fields' => array( + 'intervalSelect' => array( + 'value' => array( + array('0', '1'), + array('1', '2'), + array('2', '3'), + array('3', '11'), + array('11', '12'), + array('12', '21'), + array('21', '22'), + array('22', '31'), + array('31', '32'), + array('32', '41'), + array('41', '42'), + array('42', '51'), + array('51', '52'), + array('52', '53'), + array('53', '0') + ) + ) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'teff_etabM' => array( + 'label' => 'Tranche d\'effectif de l\'établissement M', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'teff_entrepM' => array( + 'label' => 'Tranche d\'effectif de l\'entreprise M', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'nbEtab' => array( + 'label' => 'Nombre d\'établissements', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'eff_entrep' => array( + 'label' => 'Effectif réel de l\'entreprise', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'eff_etab' => array( + 'label' => 'Effectif réel de l\'établissement', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'economique', + 'activated' => true, + ), + 'capital' => array( + 'label' => 'Capital de l\'entreprise', + 'fields' => array( + 'intervalSelect' => array( + 'value' => array( + array(0, 15000), + array(15000, 30000), + array(30000, 75000), + array(75000, 150000), + array(150000, 750000), + array(750000, 0), + ) + ) + ), + 'famille' => 'economique', + 'activated' => true, + ), + //geographique + 'adr_com' => array( + 'label' => 'Localisation géographique', + 'fields' => array( + 'tree' => array('value' => null, 'action' => 'geographique', 'title' => "Arborescence géographique"), + 'text' => array('value' => null, 'label' => "Recherche", 'title'=>"Recherche géographique"), + ), + 'famille' => 'geographique', + 'activated' => true, + ), + 'ex_domtom' => array( + 'label' => 'Exclusion des Dom-Tom', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + ), + 'ex_entr' => array( + 'label' => 'Exclusion départements étrangés', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + ), + 'ex_corse' => array( + 'label' => 'Exclusion corse', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + ), + 'adr_reg' => array( + 'label' => 'Liste code région', + 'fields' => array( + 'text' => array('value' => null), + 'textarea' => array('value' => null) + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'textarea', + 'class' => null, + 'action' => 'geographique', + 'title' => 'Localisation' + ), + 'adr_reg_ex' => array( + 'label' => 'Liste code région (Exclure)', + 'fields' => array( + 'text' => array('value' => null), + 'textarea' => array('value' => null) + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'textarea', + 'class' => null, + 'action' => 'geographique', + 'title' => 'Localisation' + ), + 'zus' => array( + 'label' => 'Zones urbaines sensibles', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + 'zru' => array( + 'label' => 'Zones de redynamisation urbaine', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + 'zfu' => array( + 'label' => 'zones franches urbaines', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + 'cucs' => array( + 'label' => 'Contrats urbains de cohésion sociale', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + 'zrr' => array( + 'label' => 'Zone de revitalisation rurale', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + 'zafr' => array( + 'label' => 'Zones Aide à finalité régionale', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'geographique', + 'activated' => true, + 'type' => 'select', + ), + + /* + * Forme Juridique + */ + 'cj' => array( + 'label' => 'Forme Juridique', + 'fields' => array( + 'tree' => array('value' => null, 'action' => 'juridique', 'title' => "Arborescence Forme Juridique"), + 'text' => array('value' => null, 'label' => "Recherche", 'title'=>"Recherche Forme Juridique"), + ), + 'famille' => 'juridique', + 'activated' => true, + ), + + 'actifEco' => array( + 'label' => 'Établissement économiquement actif', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'juridique', + 'activated' => true, + ), + 'procolHisto' => array( + 'label' => 'Présence procédure collective dans histo', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'juridique', + 'activated' => true, + ), + 'tvaIntraValide' => array( + 'label' => 'Numéro de TVA intracommunautaire valide', + 'fields' => array( + 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + ), + 'famille' => 'juridique', + 'activated' => true, + ), + 'dateImmat' => array( + 'label' => 'Date d\'immatriculation', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'juridique', + 'activated' => true, + ), + //financier + 'bilType' => array( + 'label' => 'Type du dernier bilan', + 'fields' => array( + 'selectMultiple' => array('value' => array( + 'I' => 'Inconnue', + 'R' => 'Réel', + 'E' => 'Estimé') + ), + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'avisCs' => array( + 'label' => 'Informations de paiements', + 'fields' => array( + 'selectMultiple' => array('value' => array( + '' => 'Risque indéterminé', + '00' => 'Aucun risque resencé', + '10' => 'Présence d\'impayé(s)', + '15' => 'Présence de privilèges', + '23-29-39-43' => 'Risque moyen', + '21-26-28' => 'Risque important', + '31-50' => 'Risque très important', + '24' => 'Risque dans le groupe') + ), + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilDuree' => array( + 'label' => 'Durée du dernier bilan en mois', + 'fields' => array( + 'intervalSelect' => array( + 'value' => array( + array(0, 5), + array(5, 10), + array(10, 15), + array(20, 23), + array(23, 0) + ) + ) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilTca' => array( + 'label' => 'Tranche de CA issue du bilan', + 'fields' => array( + 'selectMultiple' => array('value' => array( + '0' => 'Non déterminée', + '1' => 'de 500K€ à1M€', + '2' => 'de 1 à 2 ME', + '3' => 'de 2 à 5 ME', + '4' => 'de 5 à 10 ME', + '5' => 'de 10 à 20 ME', + '6' => 'de 20 à 50 ME', + '7' => '50 à 100 ME', + '8' => 'de 100 à 200 ME', + '9' => '+ de 200 ME' + )), + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilAnnee' => array( + 'label' => 'Dernière année de bilan', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilCloture' => array( + 'label' => 'Dernière date de clôture du bilan', + 'fields' => array( + 'interval' => array('value' => array('0', '1000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilEE' => array( + 'label' => 'Total bilan (EE)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilFL' => array( + 'label' => 'CA total (FL)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilFK' => array( + 'label' => 'Chiffre d\'affaires Export (FK)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilFR' => array( + 'label' => 'Produits d\'Exploitation (FR)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + 'type' => 'interval', + 'class' => null + ), + 'bilGF' => array( + 'label' => 'Charges d\'Exploitation (GF)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilGP' => array( + 'label' => 'Charges Financières (GP)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilGW' => array( + 'label' => 'R.C.A.I - Résultat courant av. impôt (GW)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilHD' => array( + 'label' => 'Produits Exceptionnels (HD)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilHH' => array( + 'label' => 'Charges Exceptionnels (HH)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilHL' => array( + 'label' => 'Total des Produits (HL)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilHM' => array( + 'label' => 'Total des Charges (HM)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilHN' => array( + 'label' => 'Résultat (HN)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ), + 'bilYP' => array( + 'label' => 'Effectif salarié (YP)', + 'fields' => array( + 'interval' => array('value' => array('0', '10000000')) + ), + 'famille' => 'financier', + 'activated' => true, + ) + ); + + /** + * Save all information in this array + * The key NB is mandatory as this + * ['NB']['total'] => store the number of elements matches + * ['NB']['insee'] => store the number of elements matches which type is INSEE + * @var array + */ + protected $ciblage; + protected $total = null; + protected $insee = null; + + /** + * + * @param boolean $batch + */ + public function __construct($batch = false) + { + $session = new Zend_Session_Namespace('ciblage'); + $this->ciblage = empty($session->ciblage) ? array() : $session->ciblage; + if (isset($this->ciblage['NB']['total'])) { $this->total = $this->ciblage['NB']['total']; } + if (isset($this->ciblage['NB']['insee'])) { $this->insee = $this->ciblage['NB']['insee']; } + if (isset($this->ciblage['NB'])) { unset($this->ciblage['NB']); } + } + + /** + * Save data to session + */ + protected function setSession() + { + $session = new Zend_Session_Namespace('ciblage'); + $this->ciblage['NB']['total'] = $this->total; + $this->ciblage['NB']['insee'] = $this->insee; + $session->ciblage = $this->ciblage; + } + + /** + * Enregistre un critère et sa valeur + * @param string $key + * @param mixed $value + */ + public function setCritere($key, $value) + { + $this->ciblage[$key] = $value; + $this->setSession(); + } + + /** + * Définir les critères en une fois + * @param array $criteres Criteres as array with key => val + */ + public function setCriteres($criteres) + { + $this->ciblage = $criteres; + $this->setSession(); + } + + /** + * Désactivation d'un critère + * @param string $key + */ + public function unsetCritere($key) + { + if(key_exists($key, $this->valeur)) { + unset($this->ciblage[$key]); + $this->setSession(); + } + } + + /** + * Permet de supprimer une valeur dans une clef de session + * @param string $key + * @param mixed $valeur + */ + public function unsetCritereValue($key, $valeur) { + + //@todo provisoir trouver une autre technique plus adapté. + if(key_exists($key, $this->ciblage)) { + $don = explode(',', $this->ciblage[$key]); + foreach ($don as $val) { + if($val == $valeur) + $don[key($don)] = ''; + else + $new[] = $val; + } + if(count($new) > 0) { + $don = implode(',', $new); + if(!empty($don)) + $this->ciblage[$key] = $don; + } else { + unset($this->ciblage[$key]); + } + $this->setSession(); + } + } + + /** + * Récupération de la valeur d'un critère + * @param string $key + */ + public function getCritere($key) + { + if(array_key_exists($key, $this->ciblage)) { + return $this->ciblage[$key]; + } + return null; + } + + /** + * Récupération des critères et de leurs valeurs + */ + public function getCriteres() + { + return $this->ciblage; + } + + /** + * Définit un élément de comptage + * @param string $element + * @param integer $nb + */ + public function setNb($element, $nb) + { + $this->{$element} = $nb; + $this->setSession(); + } + + /** + * Récupére la valeur d'un élément de comptage + * @param string $element + */ + public function getNb($element) + { + return $this->{$element}; + } + + /** + * Suppression des critères de toutes une famille + * @param string $famille + */ + public function resetFamille($famille) + { + $reference = $this->getByFamille($famille); + foreach($this->ciblage as $name => $valeur) { + if($name != 'null') { + if(array_key_exists($name, $reference)) { + unset($this->ciblage[$name]); + } + } + } + $this->setSession(); + } + + /** + * Suppression de toutes les valeurs en session + */ + public function clearCiblage() + { + Zend_Session::namespaceUnset('ciblage'); + } + + public function getValues($val = null) + { + if ( $val === null ) { + require_once 'Scores/SessionCiblage.php'; + $session = new SessionCiblage(); + $val = $session->getCriteres(); + } + $values = array(); + foreach($val as $key => $item) + { + if($item != '') { + if( $this->fields[$key]['type'] == 'interval' or + $this->fields[$key]['type'] == 'intervalSelect' or + $this->fields[$key]['type'] == 'textarea' and + empty($this->fields[$key]['action'])) + { + $values[$key] = explode(',', $item); + } else if (!empty($this->fields[$key]['action'])) { + if(!empty($values[$key])) { + $values[$key] = array_merge($this->selectArbo($key, $item), $values[$key]); + } + else { + if($key == 'adr_reg') { + if(!empty($values['adr_dept'])) + $values['adr_dept'] = array_merge($this->selectArbo($key, $item), $values['adr_dept']); + else + $values['adr_dept'] = $this->selectArbo($key, $item); + }else { + $values[$key] = $this->selectArbo($key, $item); + } + } + } else { + $values[$key] = $item; + } + } + } + return ($values); + } + + public function selectArbo($name, $valeur) + { + $values = array(); + switch($name) + { + case 'ape_etab' : + case 'ape_entrep' : + case 'ape_etab_ex': + case 'ape_entrep_ex': + $nafs = explode(',', $valeur); + foreach($nafs as $naf) { + if($naf != ' ') { + $values = array_merge($values, $this->nafArbo($name, $naf)); + } + } + break; + case 'adr_dept': + case 'adr_reg': + case 'adr_com': + case 'adr_com_ex': + case 'adr_dept_ex': + $valeurs = explode(',', $valeur); + foreach($valeurs as $element) { + if(!empty($element)) { + $val = explode(':', $element); + if(count($val)>1) { + $diff = $this->localisationArbo($val[0], $val[1]); + if(!empty($diff)) + $array = array_diff($diff, $values); + } else if(!empty($element)) { + $diff = $this->localisationArbo($name, $element); + if(!empty($diff)) + $array = array_diff($diff, $values); + } + if(!empty($array)) { + $values = array_merge($values, $array); + } + } + } + break; + case 'cj': + case 'cj_ex': + $valeurs = explode(',', $valeur); + foreach($valeurs as $valeur) { + if($valeur != ' ' and !empty($valeur)) + $values = array_merge($values, $this->fj($name, trim($valeur))); + } + } + return ($values); + } + + protected function fj($name, $valeur) + { + $table = new Application_Model_FormeJuridique(); + + if(strlen($valeur) < 5) { + $sql = $table->select('formejuridique', array('fjCode')) + ->where('fjCode LIKE "'.$valeur.'%"'); + } else { + $sql = $table->select('formejuridique', array('fjCode')) + ->where('fjCode = "'.$valeur.'"'); + } + $result = $table->fetchAll($sql)->toArray(); + foreach ($result as $code) { + if(strlen($code['fjCode']) > 2) { + $return[] = $code['fjCode']; + } + } + return ($return); + } + + protected function localisationArbo($name, $valeur) + { + if(strlen($valeur) == 2) { + switch($name) { + case 'adr_reg': + $table = new Application_Model_Departements(); + $sql = $table->select() + ->from('departements') + ->where('codeRegionInsee ='.$valeur) + ->setIntegrityCheck(false); + $result = $table->fetchAll($sql)->toArray(); + foreach ($result as $res) { + $return[] = trim($res['numdep']); + } + break; + case 'adr_dept': + case 'adr_dept_ex': + return (array($valeur)); + break; + } + } else + return (array($valeur)); + return ($return); + } + + protected function nafArbo($key, $valeur) + { + $value = array(); + $table = new Application_Model_Naf(); + $valeur = trim($valeur); + + if(strlen($valeur) == 1) + { + $sql = $table->select()->where('parent = ?', $valeur); + $result =$table->fetchAll($sql)->toArray(); + foreach($result as $code) $where .= " code LIKE '".trim($code['code'])."%' and niveau = 5 or "; + $where = substr($where, 0, (strlen($where)) - 3); + $sql = $table->select()->where($where); + $result = $table->fetchAll($sql)->toArray(); + foreach($result as $code) $value[] = $code['code']; + } else if(strlen($valeur) < 5){ + $sql = $table->select()->where('code LIKE "'.trim($valeur).'%" and niveau = 5'); + $result = $table->fetchAll($sql)->toArray(); + foreach($result as $code) $value[] = $code['code']; + } else if(strlen($valeur) == 5) { + $value[] = $valeur; + } + return ($value); + } + + static public function getMinMax($name) + { + $tab = array('dateCrea_ent','dateCrea_etab'); + if(!in_array($name, $tab)) { + $table = new Application_Model_MinMax(); + return ($table->fetchAll($table->select()->where('cle = ?', $name))->toArray()); + } + return (array()); + } + + public function getFields() { + return $this->fields; + } + + public function get($name) + { + if ($this->fields[$name]['activated'] == true) + return $this->fields[$name]; + return null; + } + + public function getByFamille($famille) + { + $section = array(); + + foreach($this->fields as $name => $item) { + if($item['famille'] == $famille) { + $section[$name] = $item; + } + } + return ($section); + } + + public function getNotActivated($fields) + { + foreach($fields as $name => $field) + { + if(!$field['activated']) { + $desactivated[$name] = ""; + } else if ($field['activated']){ + + } + } + return (json_encode($desactivated)); + } + + public function getLibelle($name) + { + return $this->fields[$name]['label']; + } +} \ No newline at end of file diff --git a/library/Scores/SessionCiblage.php b/library/Scores/SessionCiblage.php deleted file mode 100644 index a95d074d..00000000 --- a/library/Scores/SessionCiblage.php +++ /dev/null @@ -1,144 +0,0 @@ -valeur = empty($session->ciblage) ? array() : $session->ciblage; - if (isset($this->valeur['NB']['total'])){ $this->total = $this->valeur['NB']['total']; } - if (isset($this->valeur['NB']['insee'])){ $this->insee = $this->valeur['NB']['insee']; } - if (isset($this->valeur['NB'])){ unset($this->valeur['NB']); } - } - - /** - * Enregistre les informations dans la session - */ - protected function setSession() - { - $session = new Zend_Session_Namespace('ciblage'); - $this->valeur['NB']['total'] = $this->total; - $this->valeur['NB']['insee'] = $this->insee; - $session->ciblage = $this->valeur; - } - - /** - * Enregistre un critère et sa valeur - * @param unknown_type $key - * @param unknown_type $value - */ - public function setCritere($key, $value) - { - $this->valeur[$key] = $value; - $this->setSession(); - } - - /** - * Définir les critères en une fois - * @param array $criteres - */ - public function setCriteres($criteres) - { - $this->valeur = $criteres; - $this->setSession(); - } - - /** - * Désactivation d'un critère - * @param unknown_type $key - */ - public function unsetCritere($key) - { - if(key_exists($key, $this->valeur)) { - unset($this->valeur[$key]); - $this->setSession(); - } - } - - /*Permet de supprimer une valeur dans une clef de session*/ - public function unsetCritereValue($key, $valeur) { - - //@todo provisoir trouver une autre technique plus adapté. - if(key_exists($key, $this->valeur)) { - $don = explode(',', $this->valeur[$key]); - foreach ($don as $val) { - if($val == $valeur) - $don[key($don)] = ''; - else - $new[] = $val; - } - if(count($new) > 0) { - $don = implode(',', $new); - if(!empty($don)) - $this->valeur[$key] = $don; - } else { - unset($this->valeur[$key]); - } - $this->setSession(); - } - } - - /** - * Récupération de la valeur d'un critère - * @param unknown_type $key - */ - public function getCritere($key) - { - if(array_key_exists($key, $this->valeur)) { - return $this->valeur[$key]; - } - return null; - } - - /** - * Récupération des critères et de leurs valeurs - */ - public function getCriteres() - { - return $this->valeur; - } - - /** - * Définit un élément de comptage - * @param unknown_type $element - * @param unknown_type $nb - */ - public function setNb($element, $nb) - { - $this->{$element} = $nb; - $this->setSession(); - } - - /** - * Récupére la valeur d'un élément de comptage - * @param unknown_type $element - */ - public function getNb($element) - { - return $this->{$element}; - } - - public function resetFamille($famille) - { - require_once('Field.php'); - $fields = new Fields(null); - $reference = $fields->getByFamille($famille); - foreach($this->valeur as $name => $valeur) { - if($name != 'null') { - if(array_key_exists($name, $reference)) { - unset($this->valeur[$name]); - } - } - } - $this->setSession(); - } - - public function clearCiblage() - { - Zend_Session::namespaceUnset('ciblage'); - } - -} \ No newline at end of file diff --git a/public/themes/default/scripts/fields.js b/public/themes/default/scripts/fields.js index d6b2fd08..9faafc69 100644 --- a/public/themes/default/scripts/fields.js +++ b/public/themes/default/scripts/fields.js @@ -238,6 +238,7 @@ $(document).ready(function() } }); + /* $('textarea.complitedNaf').autocomplete({ delay:600, source: function(request, response) { @@ -254,6 +255,7 @@ $(document).ready(function() return false; } }); + */ $('#textarea_adr_dept').autocomplete({ delay:600, From 2697e8933da2fca6c380a14e9c425621c5a54d86 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 11 May 2012 20:25:55 +0000 Subject: [PATCH 04/21] Modification de l'affichage des champs --- .../controllers/ComptageController.php | 30 +- application/controllers/IndexController.php | 10 +- application/views/default/helpers/Field.php | 55 +- .../default/scripts/economique/index.phtml | 2 - .../default/scripts/entreprise/index.phtml | 32 +- .../default/scripts/geographique/index.phtml | 6 +- .../default/scripts/index/criteres.phtml | 6 +- .../default/scripts/juridique/index.phtml | 10 +- library/Object/Comptage.php | 80 +-- library/Scores/Ciblage.php | 629 ++++++------------ library/Scores/Fields.php | 215 +++--- public/themes/default/scripts/fields.js | 225 +------ public/themes/default/scripts/scripts.js | 8 - public/themes/default/styles/main.css | 330 ++------- 14 files changed, 476 insertions(+), 1162 deletions(-) diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index ef58e41e..446424c2 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -16,8 +16,34 @@ class ComptageController extends Zend_Controller_Action $cle = $request->getParam('cle'); $valeur = $request->getParam('valeur'); - $object = new Object_Comptage(); - echo $object->count($cle, $valeur); + //Set the flag for exclusion + $exclude = $request->getParam('exclude'); + $ex = false; + if ( !empty($exclude) ) { + $ex = true; + } + + $fields = new Scores_Fields(); + $fields->setCritere($cle, $valeur, $ex); + + //Comptage + require_once 'Scores/Ciblage.php'; + $ciblage = new Ciblage($fields->getValues()); + + $total = $ciblage->execute(); + $insee = $ciblage->calculRedevanceInsee(); + + $fields->setNb('total', $total); + $fields->setNb('insee', $insee); + + //@todo : Ajouter les critères sous forme json_encode + + //Retour comptage, unité Insee + $result = array( + 'count' => number_format($total, 0, '', ' '), + 'insee' => number_format($insee, 0, '', ' ') + ); + echo json_encode($result); } public function resetAction() diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index fad839da..200c9f9b 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -32,10 +32,14 @@ Class IndexController extends Zend_Controller_Action public function removeAction() { - require_once('Scores/SessionCiblage.php'); $this->_helper->layout()->disableLayout(); - $session = new SessionCiblage(); - $session->unsetCritere($this->getRequest()->getParam('critere')); + + + + $fields = new Scores_Fields(); + $fields->unsetCritere($this->getRequest()->getParam('critere')); + + $objet = new Object_Comptage(); $objet->count(null, null); $this->_redirect('/'); diff --git a/application/views/default/helpers/Field.php b/application/views/default/helpers/Field.php index c4774388..2f8e69d9 100644 --- a/application/views/default/helpers/Field.php +++ b/application/views/default/helpers/Field.php @@ -36,7 +36,9 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $html.= ''; break; case 'text': - $html.= ''; + $html.= ''; + $html.= ''; + $html.= ''; break; } $html.= ' '; @@ -74,6 +76,12 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $label, $this->intervalSelectHTML($name, $options) ); + break; + case 'checkbox': + $html.= $this->structureHTML( + $label, + $this->checkboxHTML($name, $options) + ); break; case 'interval': $html.= $this->structureHTML( @@ -135,9 +143,8 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $class = ' class="fieldgrp"'; if ( $this->display===false ) { $style = ' style="display:none;"'; - $class = ' class="fieldgrp '.$this->name.'"'; } - $out.= '

    '; + $out.= '
    '; $out.= $this->structureLabel($label); $out.= '
    '.$html.'
    '; $out.= '
    '; @@ -157,7 +164,8 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract protected function getMinMax($name, $valeur) { if(!empty($name)) { - $default = Scores_Fields::getMinMax($name); + //$fields = new Scores_Fields(); + //$default = $fields->getMinMax($name); if(empty($valeur[0])){$valeur[0] = $default[0]['min'];} if(empty($valeur[1])){$valeur[1] = $default[0]['max'];} } @@ -193,8 +201,24 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract return ($return); } - /* Select */ - private function selectMultipleHTML($name, $options) + protected function checkboxHTML($name, $options) + { + $session = new Scores_Fields(); + $sessionValeur = $session->getCritere($name); + + $select = ''; + if ($sessionValeur==1) $select = ' checked'; + $return = ''; + return $return; + } + + /** + * + * @param unknown_type $name + * @param unknown_type $options + * @return string + */ + protected function selectMultipleHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); @@ -202,33 +226,40 @@ class Zend_View_Helper_Field extends Zend_View_Helper_Abstract $return = ''; + $return .= 'Sélectionner'; + $return .= ' Exclure'; return $return; } - /* Select Multiple */ - private function selectHTML($name, $options) + /** + * + * @param unknown_type $name + * @param unknown_type $options + * @return string + */ + protected function selectHTML($name, $options) { $session = new Scores_Fields(); $sessionValeur = $session->getCritere($name); - if(is_array($sessionValeur)) + if( is_array($sessionValeur) ) { $sessionValeur = implode(',', $sessionValeur); + } $return = '
    - Exclure Etranger
    - Exclure Corse
    + Field('geo_domtom')?> + Field('geo_etranger')?> + Field('geo_corse')?>
  • Field('zus')?>
  • Field('zru')?>
  • diff --git a/application/views/default/scripts/index/criteres.phtml b/application/views/default/scripts/index/criteres.phtml index 6ec3eea4..1373b732 100644 --- a/application/views/default/scripts/index/criteres.phtml +++ b/application/views/default/scripts/index/criteres.phtml @@ -63,12 +63,12 @@
    -
    + -
    + -
    + \ No newline at end of file diff --git a/application/views/default/scripts/juridique/index.phtml b/application/views/default/scripts/juridique/index.phtml index 0df79166..a0f89c7a 100644 --- a/application/views/default/scripts/juridique/index.phtml +++ b/application/views/default/scripts/juridique/index.phtml @@ -1,15 +1,15 @@
      -
    • Field('cj');?>
    • -
    • Field('actifEco', $this->fields->get('actifEco'));?>
    • -
    • Field('procolHisto', $this->fields->get('procolHisto'));?>
    • -
    • Field('dateImmat', $this->fields->get('dateImmat'));?>
    • +
    • Field('cj')?>
    • +
    • Field('actifEco')?>
    • +
    • Field('procolHisto')?>
    • +
    • Field('dateImmat')?>

    diff --git a/library/Object/Comptage.php b/library/Object/Comptage.php index 6fec91b3..86ba2720 100644 --- a/library/Object/Comptage.php +++ b/library/Object/Comptage.php @@ -60,91 +60,19 @@ class Object_Comptage public function count($key, $valeur, $need = false) { - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); - - if(in_array($key, array('adr_dept', 'adr_com', 'adr_reg', 'adr_com_ex', 'adr_dept_ex'))) - { - $valeurs = explode(',', $valeur); - if($key == 'adr_dept') { - $reg_ = $session->getCritere('adr_reg'); - if(!empty($reg_)) { - $reg_ = explode(',', $reg_); - $table = new Application_Model_Departements(); - $result = array(); - foreach($reg_ as $item) { - $sql = $table->select()->where('codeRegionInsee = ?', $item); - $donner = $table->fetchAll($sql)->toArray(); - foreach ($donner as $don) { - $result[] = $don['numdep']; - } - foreach($result as $dep) { - if(in_array($dep, $valeurs)) { - $diff[] = $dep; - } - } - $session->unsetCritereValue('adr_reg', $item); - } - } - } - foreach($valeurs as $valeur) - { - $type = explode(':', $valeur); - if(count($type) == 2) { - $key = $type[0]; - $valeur = $type[1]; - } - switch($key) { - case 'adr_dept': - case 'adr_reg': - $dept .= trim($valeur).','; - break; - case 'adr_com': - case 'vil': - default: - $vil .= trim($valeur).','; - break; - case 'adr_com_ex': - $adr_com_ex .= trim($valeur).','; - break; - case 'adr_dept_ex': - $adr_dept_ex .= trim($valeur).','; - break; - } - } - if(strlen($dept)>0) { - $dept = substr($dept, 0, strlen($dept)-1); - $session->setCritere('adr_dept', $dept); - } - if(strlen($vil)>0) { - $vil = substr($vil, 0, strlen($vil)-1); - $session->setCritere('adr_com', $vil); - } - if(strlen($adr_com_ex)>0) { - $adr_com_ex = substr($adr_com_ex, 0, strlen($adr_com_ex)-1); - $session->setCritere('adr_com_ex', $adr_com_ex); - } - if(strlen($adr_dept_ex)>0) { - $adr_dept_ex = substr($adr_dept_ex, 0, strlen($adr_dept_ex)-1); - $session->setCritere('adr_dept_ex', $adr_dept_ex); - } - } else - $session->setCritere($key, $valeur); - - require_once 'Scores/Field.php'; - $field = new Fields(); + $fields = new Scores_Fields(); //Comptage require_once 'Scores/Ciblage.php'; - $ciblage = new Ciblage($field->getValues()); + $ciblage = new Ciblage($fields->getValues()); if($need) { return $ciblage->execute(true, 10); } $total = $ciblage->execute(); $insee = $ciblage->calculRedevanceInsee(); - $session->setNb('total', $total); - $session->setNb('insee', $insee); + $fields->setNb('total', $total); + $fields->setNb('insee', $insee); //@todo : Ajouter les critères sous forme json_encode diff --git a/library/Scores/Ciblage.php b/library/Scores/Ciblage.php index fe8bbf45..67bf34a5 100644 --- a/library/Scores/Ciblage.php +++ b/library/Scores/Ciblage.php @@ -16,15 +16,11 @@ class Ciblage */ protected $sphinx; - public $sphinx_match = SPH_MATCH_EXTENDED2; - public $sphinx_sort = SPH_SORT_EXTENDED; - /** * Construct request * @var string */ protected $alpha = ''; - protected $presentRcs = 0; /** * @@ -33,6 +29,8 @@ class Ciblage */ public function __construct($structure, $need = false) { + Zend_Registry::get('firebug')->info($structure); + /* * First of all we need to load the Sphinx API * @todo : Make a test and load the right version of API @@ -46,41 +44,52 @@ class Ciblage //Sphinx init $this->sphinx = new SphinxClient(); - $this->sphinx->SetServer($configuration->sphinx->host, intval($configuration->sphinx->port)); + $this->sphinx->SetServer( + $configuration->sphinx->host, + intval($configuration->sphinx->port) + ); $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED2); $this->sphinx->ResetFilters(); // - foreach($structure as $key => $valeur) { - if (method_exists($this, $key)) { - if(is_array($valeur)) { - if(isset($valeur[0])) { - if($valeur[0] != "" and $valeur[0] != '-') - $this->$key($valeur); - } - } else { - if($valeur != '-' and $valeur != "") - $this->$key($valeur); + if ( count($structure)>0 ) { + foreach($structure as $key => $valeur) { + if ($key!= 'NB' && method_exists($this, $key)) { + $this->{$key}($valeur); } } } } - protected function setMinMax($name, $valeur) - { - if(!empty($name)) { - $default = Fields::getMinMax($name); + protected function setFilter($name, $valeur, $ex = false) + { + //All values must be integer + if ( is_array($valeur) ) { + $valeur = array_map('intval', $valeur); + } else { + $valeur = array(intval($valeur)); + } + $this->sphinx->SetFilter($name, $valeur, $ex); + } - if(empty($valeur[0])){ - $valeur[0] = $default[0]['min']; - } - if(empty($valeur[1])){ - $valeur[1] = $default[0]['max']; - } - } - return ($valeur); + protected function setFilterRange($name, $min, $max) + { + $this->sphinx->SetFilterRange($name, intval($min), intval($max)); } + protected function setAlpha($name, $valeur) + { + if ( $this->alpha!='' ) $this->alpha.= ' '; + $this->alpha.= '@'.$name.' '.$valeur; + } + + + + + + + + public function extract() { $resultats = $this->execute(true); @@ -103,9 +112,6 @@ class Ciblage return ($resSphinx['total_found']); } - - - protected function getSiret($structure) { $siret = array(); @@ -119,8 +125,6 @@ class Ciblage } public function execute($need = false, $limitD = false) { - Zend_Registry::get('firebug')->info("Sphinx : "); - Zend_Registry::get('firebug')->info($this->alpha); if($need) { $return = array(); $limit = 0; @@ -136,436 +140,189 @@ class Ciblage $this->sphinx->SetLimits(0, 1); $resSphinx = $this->sphinx->Query($this->alpha, $this->index); } + Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha); Zend_Registry::get('firebug')->info($resSphinx); - return $resSphinx['total_found']; } - protected function setFilter($name, $valeur, $ex = false) + protected function siege($value) { - if(!is_array($valeur)) { - $this->sphinx->SetFilter($name, array(intval($valeur)), $ex); - }else { - $this->sphinx->SetFilter($name, $this->transformIntval($valeur), $ex); + if ( array_key_exists('in', $value) ) { + $this->setFilter('siege', $value); } } - protected function setFilterRange($name, $valeur) { - $this->sphinx->SetFilterRange($name, intval($valeur[0]), intval($valeur[1])); + //Valeur NULL dans BDD + protected function groupe($value) + { + if ( array_key_exists('in', $value) ) { + //$this->setFilter('sirenGrp', $value); + } } - private function getListeDepartement() - { - $table = new Application_Model_Departements(); - $sql = $table->select(); - $result = $table->fetchAll($sql)->toArray(); - foreach ($result as $dept) { - $depts .= $dept['numdep'].' | '; - } - $depts = substr($depts, 0, strlen($depts)-2); - return ($depts); + protected function tel($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('tel', $value); + } } - protected function writeRequest($name, $valeur, $ex, $or = false) { - if(in_array($name, array('bilType_ex', 'ape_etab_ex', 'ape_entrep_ex'))) { - if(!strstr($this->alpha, 'ape_etab') or - !strstr($this->alpha, 'bilType') or - !strstr($this->alpha, 'ape_entrep')) { - $this->alpha .= ' @exclu (ex) '; - } - switch($name) { - case 'ape_entrep_ex': - $name = 'ape_entrep'; - break; - case 'ape_etab_ex': - $name = 'ape_etab'; - break; - case 'bilType_ex': - $name = 'bilType'; - break; - } - } - $this->alpha .= ((!empty($this->alpha))?' ':'').'@'.$name . (($ex)?" -":" ").'('; - if(!is_array($valeur)) { - $this->alpha .= $valeur.')'; - } else { - $i = 0; - foreach($valeur as $item) { - if($i != 0) - $this->alpha .= ' | '; - $this->alpha .= $item; - $i++; - } - $this->alpha .= ')'; - } + protected function fax($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('fax', $value); + } } - protected function setAlpha($name, $valeur, $ex = false) + + protected function web($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('web', $value); + } + } + + protected function mail($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('mail', $value); + } + } + + protected function presentRcs($value) { - $or = array('adr_com', 'adr_dep', 'adr_com_ex', 'adr_dep_ex'); - $and = array('bilType', 'ape_etab_ex', 'ape_etab','ape_entrep', 'ape_entrep_ex', 'NaceEntrep', 'NaceEtab', 'bilType_ex'); - if(!empty($this->alpha)) - $this->alpha .= ' '; - if(in_array($name, $or)) { - if(!empty($valeur)) { - $this->writeRequest($name, $valeur, $ex); - } - } else if(in_array($name, $and)) { - if(!empty($valeur)) - $this->writeRequest($name, $valeur, $ex); + if ( array_key_exists('in', $value) ) { + $this->setFilter('presentRcs', $value); } } - protected function transformIntval($array) { - $copy = array(); - foreach($array as $item => $valeur) { - $copy[$item] = intval($valeur); - } - return ($copy); - } - protected function dirNom($valeur) { - $this->setFilter('dirNom', $valeur); - } - protected function siege($valeur) { - $this->setFilter('siege', $valeur); - } - protected function adr_com($valeur) { - $this->setAlpha('adr_com', $valeur); - } - protected function ex_domtom($valeur) + + protected function adrDom($value) { - if($valeur == 1) { + if ( array_key_exists('in', $value) ) { + $this->setFilter('adrDom', $value); + } + } + + protected function dirNom($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('dirNom', $value); + } + } + + protected function participation($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('part', $value); + } + } + + protected function action($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('actio', $value); + } + } + + //Don't work + protected function dateCrea_etab($value) + { + + } + + //Don't work + protected function dateCrea_ent($value) + { + + } + + protected function nbActio($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('nbActio', $min, $max); + } + } + + protected function nbPart($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('nbPart', $min, $max); + } + } + + protected function nbMPubli($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('nbMPubli', $value); + } + } + + protected function capital($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('capital', $min, $max); + } + } + + protected function age_entrep($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('age_entrep', $min, $max); + } + } + + protected function age_etab($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('age_etab', $min, $max); + } + } + + protected function teff_entrep($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('teff_entrep', $value); + } + if ( array_key_exists('ex', $value) ) { + $this->setFilter('teff_entrep', $value, true); + } + } + + protected function teff_etab($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('teff_etab', $value); + } + if ( array_key_exists('ex', $value) ) { + $this->setFilter('teff_etab', $value, true); + } + } + + protected function geo_domtom($value) + { + if( $value['in']==1 ) { $this->setFilter('adr_dep', array(971, 972, 973, 974, 976), true); } } - protected function ex_entr($valeur) + protected function geo_etranger($value) { - if($valeur == 1) { + if( $value['in']==1 ) { $this->setFilter('adr_dep', array(986, 987, 988), true); } } - protected function ex_corse($valeur) + protected function geo_corse($value) { - if($valeur == 1) { + if( $value['in']==1 ) { $this->setFilter('adr_dep', array(201, 202), true); } } - protected function adr_com_ex($valeur) { - $this->setAlpha('adr_com_ex', $valeur, true); - } - protected function adr_dep($valeur) { - $this->setAlpha('adr_dep', $valeur); - } - protected function adr_dep_ex($valeur) { - $this->setAlpha('adr_dep_ex', $valeur, true); - } - protected function action($valeur) { - $this->setFilter('action', $valeur); - } - protected function part($valeur) { - $this->setFilter('part', $valeur); - } - protected function tel($valeur) { - $this->setFilter('tel', $valeur); - } - protected function fax($valeur) { - $this->setFilter('fax', $valeur); - } - protected function cj($valeur) { - $this->setFilter('cj', $valeur); - } - protected function cj_ex($valeur) { - $this->setFilter('cj', $valeur, true); - } - protected function capital($valeur) { - $valeur = $this->setMinMax($name, $valeur); - - $this->setFilterRange('capital', $valeur); - } - protected function ape_etab($valeur) { - $this->setAlpha('ape_etab', $valeur); - } - protected function ape_etab_ex($valeur) { - $this->setAlpha('ape_etab_ex', $valeur, true); - } - protected function ape_entrep($valeur) { - $this->setAlpha('ape_entrep', $valeur); - } - protected function ape_entrep_ex($valeur) { - $this->setAlpha('ape_entrep_ex', $valeur, true); - } - protected function age_entrep($valeur) { - $this->setFilter('age_entrep', $valeur); - } - protected function age_etab($valeur) { - $this->setFilter('age_etab', $valeur); - } - protected function tcaexp($valeur) { - $this->setFilterRange('tcaexp', $valeur); - } - protected function teff_entrep($valeur) { - if($valeur[0] != 0 or $valeur[1] != 0) - $this->setFilterRange('teff_entrep', $valeur); - } - protected function teff_entrepM($valeur) { - $this->setFilter('teff_entrepM', $valeur); - } - protected function teff_etabM($valeur) { - $this->setFilter('teff_etabM', $valeur); - } - protected function teff_etab($valeur) { - //$valeur = $this->setMinMax($name, $valeur); - - $this->setFilterRange('teff_etab', $valeur); - } - protected function rang($valeur) { - $this->setFilterRange('rang', $valeur); - } - protected function actifEco($valeur) { - $this->setFilter('actifEco', $valeur); - } - protected function presentRcs($valeur) { - $this->setFilter('presentRcs', $valeur); - } - protected function procolHisto($valeur) { - $this->setFilter('procolHisto', $valeur); - } - protected function tvaIntraValide($valeur) { - $this->setFilter('tvaIntraValide', $valeur); - } - protected function NaceEtab($valeur) { - $this->setAlpha('NaceEtab', $valeur); - } - protected function NaceEntrep($valeur) { - $this->setAlpha('NaceEntrep', $valeur); - } - protected function dateCrea_etab($valeur) { - if(empty($valeur[1])) {$valeur[1] = date('Ymd');} - $valeur = $this->setMinMax('dateCrea_etab', $valeur); - if(!is_array($valeur)) { - $format = explode('/', $valeur); - $valeur = $format[2].$format[1].$format[0]; - } else { - $format1 = explode('/', $valeur[0]); - $format2 = explode('/', $valeur[1]); - - $valeur[0] = $format1[2].$format1[1].$format1[0]; - $valeur[1] = $format2[2].$format2[1].$format2[0]; - } - $this->setFilterRange('dateCrea_etab', $valeur); - - } - protected function dateCrea_ent($valeur) { - if(empty($valeur[1])) {$valeur[1] = date('Ymd');} - $valeur = $this->setMinMax('dateCrea_ent', $valeur); - if(!is_array($valeur)) { - $format = explode('/', $valeur); - $valeur = $format[2].$format[1].$format[0]; - } else { - $format1 = explode('/', $valeur[0]); - $format2 = explode('/', $valeur[1]); - - $valeur[0] = $format1[2].$format1[1].$format1[0]; - $valeur[1] = $format2[2].$format2[1].$format2[0]; - } - $this->setFilterRange('dateCrea_ent', $valeur); - } - protected function dateImmat($valeur) { - if(empty($valeur[1])) {$valeur[1] = date('Ymd');} - $valeur = $this->setMinMax('dateImmat', $valeur); - if(!is_array($valeur)) { - $format = explode('/', $valeur); - $valeur = $format[2].$format[1].$format[0]; - } else { - $format1 = explode('/', $valeur[0]); - $format2 = explode('/', $valeur[0]); - - $valeur[0] = $format1[2].$format1[1].$format1[0]; - $valeur[1] = $format2[2].$format2[1].$format2[0]; - } - $this->setFilterRange('dateImmat', $valeur); - } - protected function eff_entrep($valeur) { - $valeur = $this->setMinMax($name, $valeur); - - $this->setFilter('eff_entrep', $valeur); - } - protected function eff_etab($valeur) { - $valeur = $this->setMinMax($name, $valeur); - - $this->setFilter('eff_etab', $valeur); - } - protected function rivoli($valeur) { - $this->setFilter('rivoli', $valeur); - } - protected function nbEtab($valeur) { - $valeur = $this->setMinMax($name, $valeur); - $this->setFilterRange('nbEtab', $valeur); - } - protected function sirenGrp($valeur) { - $this->setFilter('sirenGrp', $valeur); - } - protected function nbActio($valeur) { - $valeur = $this->setMinMax('nbActio', $valeur); - - $this->setFilterRange('nbActio', $valeur); - } - protected function nbMPubli($valeur) { - $this->setFilter('nbMPubli', $valeur); - } - protected function nbPart($valeur) { - $valeur = $this->setMinMax('nbPart', $valeur); - - $this->setFilterRange('nbPart', $valeur); - } - protected function bilDuree($valeur) { - $this->setFilterRange('bilDuree', $valeur); - } - protected function bilType($valeur) { - foreach ($valeur as $val) { - $string .= '-'.$val; - } - $string = substr($string, 1); - $valeur = explode('-', $string); - $this->setAlpha('bilType', $valeur); - } - protected function bilType_ex($valeur) { - foreach ($valeur as $val) { - $string .= '-'.$val; - } - $string = substr($string, 1); - $valeur = explode('-', $string); - $this->setAlpha('bilType_ex', $valeur, true); - } - protected function bilAnnee($valeur) { - $this->setFilter('bilAnnee', $valeur); - } - protected function bilTca($valeur) { - $this->setFilter('bilTca', $valeur); - } - protected function bilTca_ex($valeur) { - $this->setFilter('bilTca', $valeur, true); - } - protected function bilEE($valeur) { - $valeur = $this->setMinMax('bilEE', $valeur); - $this->setFilterRange('bilEE', $valeur); - } - protected function bilFL($valeur) { - $valeur = $this->setMinMax('bilFL', $valeur); - $this->setFilterRange('bilFL', $valeur); - } - protected function bilFK($valeur) { - $valeur = $this->setMinMax('bilFK', $valeur); - $this->setFilterRange('bilFK', $valeur); - } - protected function bilFR($valeur) { - $valeur = $this->setMinMax('bilFR', $valeur); - $this->setFilterRange('bilFR', $valeur); - } - protected function bilGF($valeur) { - $valeur = $this->setMinMax('bilGF', $valeur); - $this->setFilterRange('bilGF', $valeur); - } - protected function bilGP($valeur) { - $valeur = $this->setMinMax('bilGP', $valeur); - $this->setFilterRange('bilGP', $valeur); - } - protected function bilGU($valeur) { - $valeur = $this->setMinMax('bilGU', $valeur); - $this->setFilterRange('bilGU', $valeur); - } - protected function bilGW($valeur) { - $valeur = $this->setMinMax('bilGW', $valeur); - $this->setFilterRange('bilGW', $valeur); - } - protected function bilHD($valeur) { - $valeur = $this->setMinMax('bilHD', $valeur); - $this->setFilterRange('bilHD', $valeur); - } - protected function bilHL($valeur) { - $valeur = $this->setMinMax('bilHL', $valeur); - $this->setFilterRange('bilHL', $valeur); - } - protected function bilHM($valeur) { - $valeur = $this->setMinMax('bilHM', $valeur); - $this->setFilterRange('bilHM', $valeur); - } - protected function bilHN($valeur) { - $valeur = $this->setMinMax('bilHN', $valeur); - $this->setFilterRange('bilHN', $valeur); - } - protected function bilYP($valeur) { - $valeur = $this->setMinMax('bilYP', $valeur); - $this->setFilterRange('bilYP', $valeur); - } - protected function avisCs($valeur) { - foreach ($valeur as $val) { - $string .= '-'.$val; - } - $string = substr($string, 1); - $valeur = explode('-', $string); - $this->setFilter('avisCs', $valeur); - } - protected function avisCs_ex($valeur) { - foreach ($valeur as $val) { - $string .= '-'.$val; - } - $string = substr($string, 1); - $valeur = explode('-', $string); - $this->setFilter('avisCs', $valeur, true); - } - protected function bilFS($valeur) { - $this->setFilterRange('bilFS', $valeur); - } - protected function lieuAct($valeur) { - $this->setFilter('lieuAct', $valeur); - } - protected function bilGG($valeur) { - $this->setFilterRange('bilGG', $valeur); - } - protected function bilGV($valeur) { - $this->setFilterRange('bilGV', $valeur); - } - protected function bilHI($valeur) { - $this->setFilterRange('bilHI', $valeur); - } - protected function adrDom($valeur) { - $this->setFilter('adrDom', $valeur); - } - protected function web($valeur) { - $this->setFilter('web', $valeur); - } - protected function mail($valeur) { - $this->setFilter('mail', $valeur); - } - protected function bilCloture($valeur) { - if(!is_array($valeur)) { - $format = explode('/', $valeur); - $valeur = $format[2].$format[1].$format[0]; - } else { - $format1 = explode('/', $valeur[0]); - $format2 = explode('/', $valeur[0]); - - $valeur[0] = $format1[2].$format1[1].$format1[0]; - $valeur[1] = $format2[2].$format2[1].$format2[0]; - } - $this->setFilterRange('bilCloture', $valeur); - } - protected function zru($valeur) { - $this->setFilter('zru', $valeur); - } - protected function zus($valeur){ - $this->setFilter('zus', $valeur); - } - protected function zfu($valeur){ - $this->setFilter('zfu', $valeur); - } - protected function cucs($valeur){ - $this->setFilter('cucs', $valeur); - } - protected function zrr($valeur){ - $this->setFilter('zrr', $valeur); - } - protected function zafr($valeur){ - $this->setFilter('zafr', $valeur); - } - } \ No newline at end of file diff --git a/library/Scores/Fields.php b/library/Scores/Fields.php index 558ad7ee..809773c0 100644 --- a/library/Scores/Fields.php +++ b/library/Scores/Fields.php @@ -18,21 +18,21 @@ class Scores_Fields * ) * ) * - * name : the key to retrieve parameters of field + * name : the key to retrieve field parameters * label : the string to display as title - * famille : the key to identify what familly the field belongs to + * famille : the key to identify where familly the field belongs to * activated : true or false * * fields : define all different fields for the same element * => type : which type of element (select, text, tree, ...), it's the key for array - * => values : + * => value : * => label (optional) : * => class : * @var array */ protected $fields = array ( - 'siege' => array( + 'siege' => array ( 'label' => "Type d'établissement", 'fields' => array( 'select' => array('value' => array('1' => 'Sièges', '0' => 'Secondaires')), @@ -40,8 +40,8 @@ class Scores_Fields 'famille' => 'entreprise', 'activated' => true, ), - 'sirenGrp' => array( - 'label' => "Présence d'un groupe", + 'groupe' => array( + 'label' => "Appartient à un groupe", 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), ), @@ -115,7 +115,6 @@ class Scores_Fields 'famille' => 'entreprise', 'activated' => true, ), - 'nbMPubli' => array( 'label' => 'Marchés publiques remportés', 'fields' => array( @@ -125,14 +124,13 @@ class Scores_Fields 'activated' => true, ), 'dateCrea_ent' => array( - 'label' => 'Date de création de l\'entreprise', + 'label' => "Date de création de l'entreprise", 'fields' => array( 'interval' => array('value' => array('0', '1000')) ), 'famille' => 'entreprise', 'activated' => true, ), - 'dateCrea_etab' => array( 'label' => "Date de création de l'établissement", 'fields' => array( @@ -141,7 +139,6 @@ class Scores_Fields 'famille' => 'entreprise', 'activated' => true, ), - 'action' => array( 'label' => 'Présence d\'actionnaires', 'fields' => array( @@ -153,12 +150,13 @@ class Scores_Fields 'nbActio' => array( 'label' => 'Nombre d\'actionnaires connus', 'fields' => array( - 'interval' => array('value' => array('0', '1000')) + //@todo : getMinMax + 'interval' => array('value' => null) ), 'famille' => 'entreprise', 'activated' => true, ), - 'part' => array( + 'participation' => array( 'label' => "Présence de participations", 'fields' => array( 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) @@ -227,25 +225,28 @@ class Scores_Fields 'activated' => true, ), 'teff_entrep' => array( - 'label' => 'Tranche d\'effectif de l\'Entreprise', + 'label' => "Tranche d'effectif de l'Entreprise", 'fields' => array( - 'intervalSelect' => array('value' => array( - array('0', '1 ou 2'), - array('1', '3 ou 5'), - array('2', '3'), - array('3', '11'), - array('11', '12'), - array('12', '21'), - array('21', '22'), - array('22', '31'), - array('31', '32'), - array('32', '41'), - array('41', '42'), - array('42', '51'), - array('51', '52'), - array('52', '53'), - array('53', '0') - )) + 'selectMultiple' => array( + 'value' => array( + 'NN' => "Unités non employeuses", + '0' => "0 salarié", + '1' => "1 ou 2 salariés", + '2' => "3 à 5 salariés", + '3' => "6 à 9 salariés", + '11' => "10 à 19 salariés", + '12' => "20 à 49 salariés", + '21' => "50 à 99 salariés", + '22' => "100 à 199 salariés", + '31' => "200 à 249 salariés", + '32' => "250 à 499 salariés", + '41' => "500 à 999 salariés", + '42' => "1 000 à 1 999 salariés", + '51' => "2 000 à 4 999 salariés", + '52' => "5 000 à 9 999 salariés", + '53' => "10 000 salariés et plus", + ), + ), ), 'famille' => 'economique', 'activated' => true, @@ -253,41 +254,26 @@ class Scores_Fields 'teff_etab' => array( 'label' => 'Tranche d\'effectif de l\'établissement', 'fields' => array( - 'intervalSelect' => array( + 'selectMultiple' => array( 'value' => array( - array('0', '1'), - array('1', '2'), - array('2', '3'), - array('3', '11'), - array('11', '12'), - array('12', '21'), - array('21', '22'), - array('22', '31'), - array('31', '32'), - array('32', '41'), - array('41', '42'), - array('42', '51'), - array('51', '52'), - array('52', '53'), - array('53', '0') + 'NN' => "Unités non employeuses", + '0' => "0 salarié", + '1' => "1 ou 2 salariés", + '2' => "3 à 5 salariés", + '3' => "6 à 9 salariés", + '11' => "10 à 19 salariés", + '12' => "20 à 49 salariés", + '21' => "50 à 99 salariés", + '22' => "100 à 199 salariés", + '31' => "200 à 249 salariés", + '32' => "250 à 499 salariés", + '41' => "500 à 999 salariés", + '42' => "1 000 à 1 999 salariés", + '51' => "2 000 à 4 999 salariés", + '52' => "5 000 à 9 999 salariés", + '53' => "10 000 salariés et plus", ) - ) - ), - 'famille' => 'economique', - 'activated' => true, - ), - 'teff_etabM' => array( - 'label' => 'Tranche d\'effectif de l\'établissement M', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) - ), - 'famille' => 'economique', - 'activated' => true, - ), - 'teff_entrepM' => array( - 'label' => 'Tranche d\'effectif de l\'entreprise M', - 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')) + ), ), 'famille' => 'economique', 'activated' => true, @@ -343,26 +329,27 @@ class Scores_Fields 'famille' => 'geographique', 'activated' => true, ), - 'ex_domtom' => array( - 'label' => 'Exclusion des Dom-Tom', + + 'geo_domtom' => array( + 'label' => 'Exlcure les DOM-TOM', 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + 'checkbox' => array('value' => '1'), ), 'famille' => 'geographique', 'activated' => true, ), - 'ex_entr' => array( - 'label' => 'Exclusion départements étrangés', + 'geo_etranger' => array( + 'label' => 'Exclure les départements étrangers', 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + 'checkbox' => array('value' => '1'), ), 'famille' => 'geographique', 'activated' => true, ), - 'ex_corse' => array( - 'label' => 'Exclusion corse', + 'geo_corse' => array( + 'label' => 'Exclure la corse', 'fields' => array( - 'select' => array('value' => array('1' => 'Oui', '0' => 'Non')), + 'checkbox' => array('value' => '1'), ), 'famille' => 'geographique', 'activated' => true, @@ -687,6 +674,9 @@ class Scores_Fields * The key NB is mandatory as this * ['NB']['total'] => store the number of elements matches * ['NB']['insee'] => store the number of elements matches which type is INSEE + * Other keys + * [key][in] => inclusion + * [key][ex] => exclusion * @var array */ protected $ciblage; @@ -721,10 +711,39 @@ class Scores_Fields * Enregistre un critère et sa valeur * @param string $key * @param mixed $value + * @param boolean $ex */ - public function setCritere($key, $value) + public function setCritere($key, $value, $ex = false) { - $this->ciblage[$key] = $value; + //Remove critere for these values on all type of fields + if ( in_array($value, array('', '-', null)) ) { + unset($this->ciblage[$key]); + return; + } + + //Before to save the value + $types = array_keys($this->fields[$key]['fields']); + switch ( $types[0] ) { + case 'interval': + $value = explode(',', $value); + //@todo : Check Min Max + + + break; + case 'checkbox': + if ( $value==0 ) { + unset($this->ciblage[$key]); + return; + } + break; + } + + //Save the value + if ($ex) { + $this->ciblage[$key]['ex'] = $value; + } else { + $this->ciblage[$key]['in'] = $value; + } $this->setSession(); } @@ -744,7 +763,7 @@ class Scores_Fields */ public function unsetCritere($key) { - if(key_exists($key, $this->valeur)) { + if( key_exists($key, $this->ciblage) ) { unset($this->ciblage[$key]); $this->setSession(); } @@ -845,40 +864,9 @@ class Scores_Fields public function getValues($val = null) { if ( $val === null ) { - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); - $val = $session->getCriteres(); + $val = $this->getCriteres(); } - $values = array(); - foreach($val as $key => $item) - { - if($item != '') { - if( $this->fields[$key]['type'] == 'interval' or - $this->fields[$key]['type'] == 'intervalSelect' or - $this->fields[$key]['type'] == 'textarea' and - empty($this->fields[$key]['action'])) - { - $values[$key] = explode(',', $item); - } else if (!empty($this->fields[$key]['action'])) { - if(!empty($values[$key])) { - $values[$key] = array_merge($this->selectArbo($key, $item), $values[$key]); - } - else { - if($key == 'adr_reg') { - if(!empty($values['adr_dept'])) - $values['adr_dept'] = array_merge($this->selectArbo($key, $item), $values['adr_dept']); - else - $values['adr_dept'] = $this->selectArbo($key, $item); - }else { - $values[$key] = $this->selectArbo($key, $item); - } - } - } else { - $values[$key] = $item; - } - } - } - return ($values); + return $val; } public function selectArbo($name, $valeur) @@ -1002,14 +990,11 @@ class Scores_Fields return ($value); } - static public function getMinMax($name) + protected function getMinMax($name) { - $tab = array('dateCrea_ent','dateCrea_etab'); - if(!in_array($name, $tab)) { - $table = new Application_Model_MinMax(); - return ($table->fetchAll($table->select()->where('cle = ?', $name))->toArray()); - } - return (array()); + $MinMaxM = new Application_Model_MinMax(); + $minmax = $table->fetchAll($table->select()->where('cle = ?', $name))->toArray(); + return $minmax; } public function getFields() { diff --git a/public/themes/default/scripts/fields.js b/public/themes/default/scripts/fields.js index 9faafc69..6c0d9d02 100644 --- a/public/themes/default/scripts/fields.js +++ b/public/themes/default/scripts/fields.js @@ -21,72 +21,22 @@ $(document).ready(function() }); }); - $("div.slider-range").slider({ - range: true, - create: function(event, ui) { - var max = $("#"+$(this).attr('input')).attr('max'); - var min = $("#"+$(this).attr('input')).attr('min'); - - $(this).slider( "option", "min", min ); - $(this).slider( "option", "max", max ); - }, - values : [0, 10000000000], - slide: function( event, ui ) { - var name = $(this).attr('input'); - $( "#"+name ).val( ui.values[ 0 ] + " , " + ui.values[ 1 ] ); - }, - step: 10, - stop: function( event, ui ) { - var name = $(this).attr('input'); - set(name, ui.values[ 0 ] + "," + ui.values[ 1 ]); - } - }); - $("input.datepicker").datepicker({ dateFormat: 'dd/mm/yy' } ); - $( "#accordion" ).accordion({ - autoHeight: false, - navigation: true, - icons: { - header: "ui-icon-circle-arrow-e", - headerSelected: "ui-icon-circle-arrow-s" - } - }); - - $( "#toggle" ).button().toggle(function() { - $( "#accordion" ).accordion( "option", "icons", false ); - }, function() { - $( "#accordion" ).accordion( "option", "icons", icons ); - }); - $( ".column" ).sortable({ - connectWith: ".column" - }); - - $( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) - .find( ".portlet-header" ) - .addClass( "ui-widget-header ui-corner-all" ) - .prepend( "") - .end() - .find( ".portlet-content" ); - - $( ".portlet-header .ui-icon" ).click(function() { - $( this ).toggleClass( "ui-icon-minusthick" ).toggleClass( "ui-icon-plusthick" ); - $( this ).parents( ".portlet:first" ).find( ".portlet-content" ).toggle(); - }); - - $( ".column" ).disableSelection(); - $('#tabs').delegate('select.criteres', 'change', function(e){ var valeur = $(this, ':selected').val(); e.stopPropagation(); set($(this).attr('name'), valeur); - }); $('#tabs').delegate('input[type=checkbox].criteres', 'click', function(e){ e.stopPropagation(); - set($(this).attr('name'), $(this).val()); + if($(this).is(':checked')) { + set($(this).attr('name'), 1); + } else { + set($(this).attr('name'), 0); + } }); $('#tabs').delegate('input[type=radio].criteres', 'click', function(e){ @@ -172,159 +122,16 @@ $(document).ready(function() return false; }); - $('.resetFamille').click(function(){ - var famille = $(this).attr('id'); - $.ajax({ - type : "GET", - cache : false, - url : famille+'/reset', - data : $(this).serializeArray(), - success: function(data) { - set(null, null); - } - }); - window.location.replace('/'); - }); - - $('.checkbox_ex').click(function(){ - if($(this).is(':checked')) { - $('#'+$(this).attr('name')+'_in').css('display', 'none'); - $('#'+$(this).attr('name')+'_ex').css('display', 'block'); + $('#tabs').delegate('a.text', 'click', function(e) { + e.preventDefault(); + var id = $(this).attr('id'); + if ($('div#'+id).css('display') == 'none') { + $('div#'+id).show('blind'); } else { - $('#'+$(this).attr('name')+'_in').css('display', 'block'); - $('#'+$(this).attr('name')+'_ex').css('display', 'none'); + $('div#'+id).hide('blind'); } }); - $('.ex_prede').click(function(){ - if($(this).is(':checked')) { - set($(this).attr('name'), 1); - } else { - set($(this).attr('name'), 0); - } - }); - - $('textarea.complitedCj').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('textarea.complitedCj_ex').autocomplete({ - delay:300, - source: function(request, response) { - $.getJSON('/juridique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - /* - $('textarea.complitedNaf').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/economique/completed', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - */ - - $('#textarea_adr_dept').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/dep/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('#textarea_adr_reg').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/reg/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - $('#textarea_adr_dept').val(terms.join( "," )+$('#textarea_adr_dept').val()); - $(this).val(''); - return false; - } - }); - - $('textarea.complitedadr_com').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/adr_com/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); - - $('textarea.complitedadr_com_ex').autocomplete({ - delay:600, - source: function(request, response) { - $.getJSON('/geographique/completed/adr_com_ex/1', { q: extractLast( request.term ) }, - function(data) { response(data); } - ); - }, - select: function(event, ui){ - var terms = split( this.value ); - terms.pop(); - terms.push( ui.item.value ); - terms.push( "" ); - this.value = terms.join( ", " ); - return false; - } - }); }); @@ -334,16 +141,14 @@ function set(key, value) $('#attente').css('display', 'block'); $('#panel').html(''); - $.post('/comptage', { cle:key, valeur:value }, function(data, status) { + $.post('/comptage/index', { cle:key, valeur:value }, function(data, status) { var html = 'Nombre sélectionnées : ' + data.count + ' (dont ' + data.insee +' unité(s) insee)'; $('#attente').css('display', 'none'); $('#comptage').html(html).css('display','block'); - - - + $.ajax({ type : "GET", cache : false, @@ -353,9 +158,7 @@ function set(key, value) $('#panel').html(data); } }); - - - + }, 'json') .error(function(){ alert('error'); }); } diff --git a/public/themes/default/scripts/scripts.js b/public/themes/default/scripts/scripts.js index b9cad296..1f51fcdf 100644 --- a/public/themes/default/scripts/scripts.js +++ b/public/themes/default/scripts/scripts.js @@ -68,14 +68,6 @@ $(document).ready(function(){ return false; }); - $('.manuel').click( function(){ - var id = $(this).attr('ref'); - if($('.'+id).css('display') == 'none') - $('.'+id).show('blind'); - else - $('.'+id).hide('blind'); - }); - $('.mode').click(function(){ var id = $(this).attr('id'); if($('#'+id).css('display') == 'none') { diff --git a/public/themes/default/styles/main.css b/public/themes/default/styles/main.css index 8624cb8a..aa0473d5 100644 --- a/public/themes/default/styles/main.css +++ b/public/themes/default/styles/main.css @@ -144,49 +144,6 @@ body { min-width: 0px; } -.range -{ - margin-left:10px; - margin-top:3px; - float:left; - border:0; - color:black; - font-weight:bold; -} - -.mySlider -{ - margin:0px; - padding:10px; -} - -.critereSelection li -{ - list-style: none; -} - -label { - font-weight:800; -} - -li.liHover { - border:1px solid silver; - padding:5px; - margin:1px; - background-repeat: no-repeat; - background-position:2px; - cursor:move; - font-size: 0.9em; -} - -li.liHover a { - text-decoration:none; -} - -li.liHover:hover { - cursor:pointer; -} - table#client { width:100%; } table#client td { border:1px solid #000; @@ -198,7 +155,6 @@ table#client tr:hover { background-color: #88ccff; } - .paragraph { margin:5px; padding:5px; @@ -235,14 +191,6 @@ h3 { padding:2px; } -#accordion { - -} - -#rappel { - -} - .ui-accordion .ui-accordion-content { padding:0; } @@ -264,9 +212,6 @@ h3 { height:200px; } -ul#fieldsblock li { list-style-type: none; } - - table.ciblage { width:100%; } @@ -281,34 +226,54 @@ table.ciblage td { padding:2px; } -.fieldgrp { - clear: both; - width: 100%; - overflow: hidden; +ul#fieldsblock li { + list-style-type: none; + padding:5px; + border:1px solid silver; + margin-top:2px; + background-color:#D4D4D4; + border:1px solid silver; + margin:1px; + font-size: 0.9em; } -.fieldgrp:after { - content: "."; - display: block; - clear: both; - visibility: hidden; - line-height: 0; - height: 0; +ul#fieldsblock li a { + text-decoration:none; } -.fieldgrp label { +ul#fieldsblock li:hover { + background-color:#9EC5FF; +} + +ul#fieldsblock li div.fieldgrp { + clear: both; + width: 100%; + overflow: hidden; +} + +ul#fieldsblock li div.fieldgrp:after { + content: "."; + display: block; + clear: both; + visibility: hidden; + line-height: 0; + height: 0; +} + +ul#fieldsblock li div.fieldgrp:first-child label { font-weight: bold; - /*width: 320px;*/ +} + +ul#fieldsblock li div.fieldgrp label { clear: both; line-height: 22px; _padding-top: 3px; - float: right; display: block; font-size:0.9em; float:left; } -.field { +ul#fieldsblock li div.fieldgrp div.field { width: 350px; float: right; padding: 0 10px 0 0; @@ -317,109 +282,77 @@ table.ciblage td { text-align: right; } -.field a -{ +ul#fieldsblock li div.fieldgrp div.field a { font-size:10px; color:blue; } -.field .longfield { +ul#fieldsblock li div.fieldgrp div.field .longfield { width: 215px; } -.field .longfield-select { +ul#fieldsblock li div.fieldgrp div.field .longfield-select { width: 220px; } -.field .smallfield { +ul#fieldsblock li div.fieldgrp div.field .smallfield { width: 95px; } -.field .medfield { +ul#fieldsblock li div.fieldgrp div.field .medfield { width: 110px; } -.field input, .field textarea { +ul#fieldsblock li div.fieldgrp div.field input, .field textarea { font-size: 0.9em; margin: 2px 0; border:1px solid #000000; width:100%; } -.field input[type="radio"] { +ul#fieldsblock li div.fieldgrp div.field input[type="radio"] { margin: 0 5px 0 5px; } -.slider-range -{ - width:100%; +ul#fieldsblock li div.fieldgrp div.field input[type="checkbox"] { + width:auto; } -.range {background-color:transparent;} +ul#fieldsblock li div.fieldgrp div.field select { + width:265px; +} -#helper -{ +ul#fieldsblock li div.fieldgrp div.field select.intervalSelect { + width:102px; +} + +ul#fieldsblock li div.fieldgrp div.field .interval input[type=text] { + width:100px; +} + +#helper { border:2px solid silver; background-color: #CBD3D2; padding:10px; } -.Valide -{ +.Valide { padding:5px; border:1px solid black; background-color:#182838; } -.Valide a -{ +.Valide a { color:white; text-decoration: none; } -#economique -{ - font-size:13px; - -} - -#economique select { - width:80px; -} - -#economique li { - padding:5px; - border:1px solid silver; - margin-top:2px; - background-color:#D4D4D4; -} - -#economique li:hover { - background-color:#9EC5FF; -} - -#link -{ +#link { text-align:right; margin-top:20px; font-size:13px; } -#economique .interval input[type=text] -{ - width:100px; -} - -#economique select.intervalSelect -{ - width:102px; -} - -#economique select -{ - width:265px; -} - .error { display:block; border:1px solid red; @@ -434,150 +367,7 @@ table.ciblage td { color:red; } -#entreprise -{ - font-size:13px; -} - -#entreprise select { - width:70%; -} - -#entreprise li { - height:20px; - padding:5px; - border:1px solid silver; - margin-top:2px; - background-color:#D4D4D4; -} - -#entreprise li:hover { - background-color:#9EC5FF; -} - -#entreprise li input { - width:125px; -} - -#entreprise .interval input[type=text] -{ - width:100px; -} - -#entreprise select.intervalSelect -{ - width:102px; -} - -#entreprise select -{ - width:265px; - border:1px solid silver; -} - -.resetFamille -{ +.resetFamille { cursor:pointer; text-decoration: underline; -} - -#financiere -{ - font-size:13px; -} - -#financiere select { - width:80px; -} - -#financiere li { - padding:5px; - border:1px solid silver; - margin-top:2px; - background-color:#D4D4D4; -} - -#financiere li:hover { - background-color:#9EC5FF; -} - -#financiere select -{ - width:100%; -} - -#financiere .interval input[type=text] -{ - width:100px; -} - -#financiere select.intervalSelect -{ - width:102px; -} - -#financiere select -{ - width:265px; -} - -#geographique -{ - font-size:13px; -} - -#geographique select { - width:70%; -} - -#geographique li { - padding:5px; - border:1px solid silver; - margin-top:2px; - background-color:#D4D4D4; -} - -#geographique li:hover { - background-color:#9EC5FF; -} - -#geographique .interval input[type=text] -{ - width:100px; -} - -#juridique -{ - font-size:13px; - text-shadow: 1px 1px 1px white; -} - -#juridique select { - width:80px; -} - -#juridique li { - padding:5px; - border:1px solid silver; - margin-top:2px; - background-color:#D4D4D4; -} - -#juridique li:hover { - background-color:#9EC5FF; -} - -#juridique .interval input[type=text] -{ - width:100px; -} - -#juridique select.intervalSelect -{ - width:102px; -} - -#juridique select -{ - width:265px; } \ No newline at end of file From df5ebbdb7f9534f59cf72a57ad9b64e22d3b6032 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Sat, 12 May 2012 16:46:00 +0000 Subject: [PATCH 05/21] Suppression de Session Ciblage --- application/controllers/ComptageController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/application/controllers/ComptageController.php b/application/controllers/ComptageController.php index 446424c2..78cfb6c5 100644 --- a/application/controllers/ComptageController.php +++ b/application/controllers/ComptageController.php @@ -48,21 +48,21 @@ class ComptageController extends Zend_Controller_Action public function resetAction() { - require_once 'Scores/SessionCiblage.php'; $erreurs = new Zend_Session_Namespace('erreurs'); - $session = new SessionCiblage(); - $session->clearCiblage(); + + $fields = new Scores_Fields(); + $fields->clearCiblage(); + unset($erreurs->erreurs); - $this->_redirect('./'); + $this->_redirect('/'); } public function savedialogAction() { $this->_helper->layout()->disableLayout(); //Récupération de la session pour le profil et les valeurs du comptage - require_once 'Scores/SessionCiblage.php'; - $session = new SessionCiblage(); - $criteres = $session->getCriteres(); + $fields = new Scores_Fields(); + $criteres = $fields->getCriteres(); $this->view->criteres = $criteres; if (count($criteres) == 0) { From 2c9d24dfb1216883710d6ef5c3d6bcac66edaa65 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Sun, 13 May 2012 13:20:28 +0000 Subject: [PATCH 06/21] Ajout bil --- library/Scores/Ciblage.php | 213 +++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/library/Scores/Ciblage.php b/library/Scores/Ciblage.php index 67bf34a5..4beee701 100644 --- a/library/Scores/Ciblage.php +++ b/library/Scores/Ciblage.php @@ -313,16 +313,229 @@ class Ciblage $this->setFilter('adr_dep', array(971, 972, 973, 974, 976), true); } } + protected function geo_etranger($value) { if( $value['in']==1 ) { $this->setFilter('adr_dep', array(986, 987, 988), true); } } + protected function geo_corse($value) { if( $value['in']==1 ) { $this->setFilter('adr_dep', array(201, 202), true); } } + + protected function zus($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('zus', $value); + } + } + + protected function zru($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('zru', $value); + } + } + + protected function zfu($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('zfu', $value); + } + } + + protected function cucs($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('cucs', $value); + } + } + + protected function zrr($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('zrr', $value); + } + } + + protected function zafr($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('zafr', $value); + } + } + + protected function actifEco($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('actifEco', $value); + } + } + + protected function procolHisto($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('procolHisto', $value); + } + } + + protected function tvaIntraValide($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('tvaIntraValide', $value); + } + } + + protected function bilType($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('bilType', $value); + } + if ( array_key_exists('ex', $value) ) { + $this->setFilter('bilType', $value, true); + } + } + + protected function avisCs($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('avisCs', $value); + } + if ( array_key_exists('ex', $value) ) { + $this->setFilter('avisCs', $value, true); + } + } + + protected function bilTca($value) + { + if ( array_key_exists('in', $value) ) { + $this->setFilter('bilTca', $value); + } + if ( array_key_exists('ex', $value) ) { + $this->setFilter('bilTca', $value, true); + } + } + + protected function bilEE($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilEE', $min, $max); + } + } + + protected function bilFL($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilFL', $min, $max); + } + } + + protected function bilFK($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilFK', $min, $max); + } + } + + protected function bilFR($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilFR', $min, $max); + } + } + + protected function bilGF($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilGF', $min, $max); + } + } + + protected function bilGP($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilGP', $min, $max); + } + } + + protected function bilGW($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilGW', $min, $max); + } + } + + protected function bilHD($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilHD', $min, $max); + } + } + + protected function bilHH($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilHH', $min, $max); + } + } + + protected function bilHL($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilHL', $min, $max); + } + } + + protected function bilHM($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilHM', $min, $max); + } + } + + protected function bilHN($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilHN', $min, $max); + } + } + + protected function bilYP($value) + { + if ( array_key_exists('in', $value) ) { + $min = $value['in'][0]; + $max = $value['in'][1]; + $this->setFilterRange('bilYP', $min, $max); + } + } + } \ No newline at end of file From 1d261f6c7f09c33ca4ec7436679a26bbd3d38be4 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Sun, 13 May 2012 13:21:15 +0000 Subject: [PATCH 07/21] Suppression adr_reg_ex --- library/Scores/Fields.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/library/Scores/Fields.php b/library/Scores/Fields.php index 809773c0..66957d26 100644 --- a/library/Scores/Fields.php +++ b/library/Scores/Fields.php @@ -367,19 +367,6 @@ class Scores_Fields 'action' => 'geographique', 'title' => 'Localisation' ), - 'adr_reg_ex' => array( - 'label' => 'Liste code région (Exclure)', - 'fields' => array( - 'text' => array('value' => null), - 'textarea' => array('value' => null) - ), - 'famille' => 'geographique', - 'activated' => true, - 'type' => 'textarea', - 'class' => null, - 'action' => 'geographique', - 'title' => 'Localisation' - ), 'zus' => array( 'label' => 'Zones urbaines sensibles', 'fields' => array( From 66d8069d91653a1e9eed65d2671daf383f958050 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Sun, 13 May 2012 13:59:15 +0000 Subject: [PATCH 08/21] =?UTF-8?q?Modification=20pour=20la=20suppression=20?= =?UTF-8?q?du=20crit=C3=A8re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/IndexController.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 200c9f9b..257c1a0c 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -34,15 +34,21 @@ Class IndexController extends Zend_Controller_Action { $this->_helper->layout()->disableLayout(); - + $nameCritereToDelete = $this->getRequest()->getParam('critere'); $fields = new Scores_Fields(); - $fields->unsetCritere($this->getRequest()->getParam('critere')); + $fields->unsetCritere($nameCritereToDelete); + + //Comptage + require_once 'Scores/Ciblage.php'; + $ciblage = new Ciblage($fields->getValues()); + + $total = $ciblage->execute(); + $insee = $ciblage->calculRedevanceInsee(); + + $fields->setNb('total', $total); + $fields->setNb('insee', $insee); - - $objet = new Object_Comptage(); - $objet->count(null, null); $this->_redirect('/'); } -} - +} \ No newline at end of file From 41f9ce83e30aa36d21b1f3e20c2f0b0db5527b9f Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 14 May 2012 07:36:27 +0000 Subject: [PATCH 09/21] Pris en compte que des select simple --- public/themes/default/scripts/fields.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/themes/default/scripts/fields.js b/public/themes/default/scripts/fields.js index 6c0d9d02..8fcbe802 100644 --- a/public/themes/default/scripts/fields.js +++ b/public/themes/default/scripts/fields.js @@ -22,12 +22,13 @@ $(document).ready(function() }); $("input.datepicker").datepicker({ dateFormat: 'dd/mm/yy' } ); - $('#tabs').delegate('select.criteres', 'change', function(e){ - var valeur = $(this, ':selected').val(); e.stopPropagation(); - set($(this).attr('name'), valeur); + if ( !$(this).attr('size') ){ + var valeur = $(this, ':selected').val(); + set($(this).attr('name'), valeur); + } }); $('#tabs').delegate('input[type=checkbox].criteres', 'click', function(e){ From a4ac98b4e64127fcd13bf0c46c16bb7065940d5f Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 14 May 2012 07:49:58 +0000 Subject: [PATCH 10/21] Diverses corrections --- .../scripts/arborescence/geographique.phtml | 12 +++++------ .../scripts/arborescence/juridique.phtml | 20 +++++++++---------- .../default/scripts/arborescence/naf.phtml | 14 ++++++------- library/Object/Codepostaux.php | 10 ++++------ library/Object/Formejuridique.php | 5 ++--- library/Object/Naf.php | 11 +++++----- public/themes/default/scripts/fields.js | 9 +++++++++ 7 files changed, 43 insertions(+), 38 deletions(-) diff --git a/application/views/default/scripts/arborescence/geographique.phtml b/application/views/default/scripts/arborescence/geographique.phtml index a97536fb..31a6f058 100644 --- a/application/views/default/scripts/arborescence/geographique.phtml +++ b/application/views/default/scripts/arborescence/geographique.phtml @@ -1,16 +1,16 @@ -

    +