require(['dojo/query', 'dojo/on', 'dojo/ready', 'dojo/dom', 'dojo/_base/lang', 'dojo/dom-construct', 'dojo/_base/xhr'], function(query, on, ready, dom, lang, domConstruct, xhr){ ready(function(){ var checkAll = dom.byId('check_all_command_lines'); var createContactButton = function(){ if(!query('div[class=\"align_right\"]').length){ var linkContainer = domConstruct.create('div', {class: 'align_right'}, 'pnb_ui_list', 'before'); var contactLink = domConstruct.create('a', {href: '#', innerHTML: pmbDojo.messages.getMessage('edition_pnb', 'pnb_contact_link_title')}, linkContainer, 'last'); on(contactLink, 'mousedown', function(e){ var checkboxes = Array.prototype.slice.call(document.querySelectorAll('input[type=\"checkbox\"][data-pnb]:checked:enabled')); if(checkboxes.length){ var spinner = domConstruct.create('i', {class: 'fa fa-2x fa-circle-o-notch fa-spin', ariaHidden:true}, contactLink); var commandsIds = []; checkboxes.forEach(function(checkbox){ commandsIds.push(checkbox.value); }); xhr.post({ url:'./ajax.php?module=edit&categ=pnb&sub=orders&action=mailto', sync: true, postData: 'commands_ids='+commandsIds.join(','), handleAs:'json', load: function(data){ if(data){ var body = ''; for(var key in data){ if((key != 'GLN') && (key != 'address')){ body+= '\\nReference commande: '+data[key].orderId+'\\n'+pmbDojo.messages.getMessage('edition_pnb', 'pnb_contact_command_create_date')+': '+data[key].orderCreateDate+'\\n'+pmbDojo.messages.getMessage('edition_pnb', 'pnb_contact_command_line_id')+': '+data[key].orderLineId+'\\n'+pmbDojo.messages.getMessage('edition_pnb', 'pnb_contact_gln')+': '+data['GLN']+'\\n\\n'; } } domConstruct.destroy(spinner); contactLink.href = 'mailto:'+data['address']+'?subject='+encodeURI(pmbDojo.messages.getMessage('edition_pnb', 'pnb_contact_mail_title'))+'&body='+encodeURI(body); contactLink.click(); contactLink.href = '#'; } } }); }else{ alert(pmbDojo.messages.getMessage('edition_pnb', 'pnb_please_select_command')); } e.preventDefault(); return false; }); } }(); var checkboxes = query('input[type=\"checkbox\"][data-pnb]'); on(checkAll, 'click', lang.hitch(this, function(){ var checked = Array.prototype.slice.call(document.querySelectorAll('input[type=\"checkbox\"][data-pnb]:checked:enabled')); var notChecked = Array.prototype.slice.call(document.querySelectorAll('input[type=\"checkbox\"][data-pnb]:checked:disabled')); if(checked.length < checkboxes.length){ checkboxes.forEach(function(checkbox){ checkbox.checked = true; }); }else{ checkboxes.forEach(function(checkbox){ checkbox.checked = false; }); } })); }); }); function check(cac) { cac.checked=!cac.checked; } function verifChk(formToCheck,valAction) { nb = formToCheck.elements.length; res = false; for (var i=0;i "; $pnb_ui_search_filters_form_tpl = " ";