Merge branch 'ticket-14739-PackLogistic'

This commit is contained in:
Michael RICOIS 2018-02-22 09:35:41 +01:00
commit 48f2940d2d
12 changed files with 1292 additions and 273 deletions

View File

@ -21,6 +21,8 @@ class AdminAntLogistic extends AdminTab
{
public $_html = '';
public $submitShipAfter = false;
private function stripaccents($str)
{
return preg_replace(
@ -332,8 +334,8 @@ class AdminAntLogistic extends AdminTab
$render = $logistics_carriers['mondialrelay']->renderLabel(new Order($id_order), $weight, $result[1]);
$this->printLabel($render,true);
} elseif(Tools::isSubmit('submitShip') && ($id_order = (int) Tools::getValue('id_order'))) {
$order = new Order((int) $id_order);
$order = new Order((int) $id_order);
$to_ship = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order_detail`, SUM(d.`product_quantity`) AS `product_quantity`, SUM(d.`product_quantity_refunded`) AS `product_quantity_refunded`, SUM(d.`product_quantity_return`) AS `product_quantity_return`, SUM(w.`quantity`) AS `quantity_sent`
@ -426,6 +428,8 @@ class AdminAntLogistic extends AdminTab
} else {
$this->_html .= '<p class="error">'.$this->l('Please enter a weight and select at least one product').'</p><br />';
}
$this->submitShipAfter = true;
}
} elseif(Tools::isSubmit('submitMod') && ($id_order = (int) Tools::getValue('id_order'))) {
$product_ids = Tools::getValue('product_ids');
@ -469,9 +473,10 @@ class AdminAntLogistic extends AdminTab
}
}
public function display() {
public function display()
{
global $cookie, $logistics_carriers;
$unavailable_carriers = array();
foreach($logistics_carriers as $name => $class) {
@ -603,18 +608,19 @@ class AdminAntLogistic extends AdminTab
padding: 3px;
text-decoration: none;
}
* html .ui-multiselect-checkboxes label {
border: medium none;
}
.ui-multiselect-hasfilter ul { position:relative; top:2px }
.ui-multiselect-filter { float:left; margin-right:10px; font-size:11px }
.ui-multiselect-filter input { width:300px; font-size:10px; margin-left:5px; height:15px; padding:2px; border:1px solid #292929; -webkit-appearance:textfield; -webkit-box-sizing:content-box; }
.location {
color: #0066ff;
}
.ui-multiselect-hasfilter ul { position:relative; top:2px }
.ui-multiselect-filter { float:left; margin-right:10px; font-size:11px }
.ui-multiselect-filter input { width:300px; font-size:10px; margin-left:5px; height:15px; padding:2px; border:1px solid #999999; -webkit-appearance:textfield; -webkit-box-sizing:content-box; }
#html_products thead th,
#html_logs thead th{
font-size:12px;
@ -785,14 +791,25 @@ class AdminAntLogistic extends AdminTab
}
}
});
}
</script>
}';
if ($this->submitShipAfter && Tools::getIsset('id_order')) {
$helperForm->_js .= '
$(function() {
$("#manualinput").val('.Tools::getValue('id_order').');
$("#barcodeinput").val("");
loadOrder(null, true);
});
';
}
$helperForm->_js .= '</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/ant_logistic/libs/jquery.hotkeys.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/ant_logistic/libs/jquery.multiselect.min.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/ant_logistic/libs/jquery.multiselect.filter.min.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/ant_logistic/script.js?v=1"></script>';
$this->_html.='
$helperForm->_js .='
<div class="modal" id="confirm" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -835,22 +852,22 @@ class AdminAntLogistic extends AdminTab
<div class="panel-content">
<form action="'.__PS_BASE_URI__.'modules/ant_logistic/select_sale.php?token='.Tools::getValue('token').'&id_employee='.(int) $cookie->id_employee.'" method="POST">
<div>
<select multiple="true" id="filter_id_sale" name="filter_id_sale[]" style="display:none">';
foreach(Db::getInstance()->ExecuteS('
SELECT s.`id_sale`, c.`name`
FROM `'._DB_PREFIX_.'privatesale` s
LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = s.`id_category`)
WHERE c.`id_lang` = 2
AND (
s.`date_end` > DATE_SUB(NOW(), INTERVAL 90 DAY)
OR s.`public` = 1
)
') as $row) {
$this->_html .= '<option value="'.(int) $row['id_sale'].'"'.(in_array((int) $row['id_sale'], $sales_list)? ' selected="selected"': '').'>'.(int) $row['id_sale'].' - '.htmlentities($row['name']).'</option>';
}
$this->_html .= '</select>
<select multiple="true" id="filter_id_sale" name="filter_id_sale[]" style="display:none;">';
foreach(Db::getInstance()->ExecuteS('
SELECT s.`id_sale`, c.`name`
FROM `'._DB_PREFIX_.'privatesale` s
LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = s.`id_category`)
WHERE c.`id_lang` = 2
AND (
s.`date_end` > DATE_SUB(NOW(), INTERVAL 90 DAY)
OR s.`public` = 1
)
') as $row) {
$this->_html .= '<option value="'.(int) $row['id_sale'].'"'.(in_array((int) $row['id_sale'], $sales_list)? ' selected="selected"': '').'>'.(int) $row['id_sale'].' - '.htmlentities($row['name']).'</option>';
}
$this->_html .= '</select>
<input class="btn btn-primary pull-right" type="submit" value="Valider" /><br style="clear: both" />
</div>
</div>
</form>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@ -1,47 +0,0 @@
/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood{at}iinet.com.au),
Stéphane Nahmani (sholby@sholby.net),
Stéphane Raimbault <stephane.raimbault@gmail.com> */
jQuery(function($){
$.datepicker.regional['fr'] = {
closeText: 'Fermer',
prevText: 'Précédent',
nextText: 'Suivant',
currentText: 'Aujourd\'hui',
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
dayNamesMin: ['D','L','M','M','J','V','S'],
weekHeader: 'Sem.',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['fr']);
});
/* French translation for the jQuery Timepicker Addon */
/* Written by Thomas Lété */
(function($) {
$.timepicker.regional['fr'] = {
timeOnlyTitle: 'Choisir une heure',
timeText: 'Heure',
hourText: 'Heures',
minuteText: 'Minutes',
secondText: 'Secondes',
millisecText: 'Millisecondes',
timezoneText: 'Fuseau horaire',
currentText: 'Maintenant',
closeText: 'Terminé',
timeFormat: 'hh:mm',
amNames: ['AM', 'A'],
pmNames: ['PM', 'P'],
ampm: false
};
$.timepicker.setDefaults($.timepicker.regional['fr']);
})(jQuery);

View File

@ -0,0 +1,25 @@
.ui-multiselect { padding:2px 0 2px 4px; text-align:left }
.ui-multiselect span.ui-icon { float:right }
.ui-multiselect-single .ui-multiselect-checkboxes input { left:-9999px; position:absolute !important; top: auto !important; }
.ui-multiselect-single .ui-multiselect-checkboxes label { padding:5px !important }
.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px; }
.ui-multiselect-header ul { font-size:0.9em }
.ui-multiselect-header ul li { float:left; padding:0 10px 0 0; }
.ui-multiselect-header a { text-decoration:none; }
.ui-multiselect-header a:hover { text-decoration:underline; }
.ui-multiselect-header span.ui-icon { float:left; }
.ui-multiselect-header .ui-multiselect-close { float:right; padding-right:0; text-align:right; }
.ui-multiselect-menu { display:none; padding:3px; position:absolute; text-align: left; }
.ui-multiselect-checkboxes { overflow-y:auto; position:relative; }
.ui-multiselect-checkboxes label { border:1px solid transparent; cursor:default; display:block; padding:3px 1px; }
.ui-multiselect-checkboxes label input { position:relative; top:1px }
.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; list-style: none; padding-right:3px; }
.ui-multiselect-checkboxes .ui-multiselect-optgroup { padding: 3px; }
.ui-multiselect-columns { display: inline-block; vertical-align: top; }
.ui-multiselect-checkboxes .ui-multiselect-optgroup a { border-bottom:1px solid; cursor: pointer; display:block; font-weight:bold; margin:1px 0; padding:3px; text-align:center; text-decoration:none; }
@media print{
.ui-multiselect-menu {display: none;}
}

View File

@ -0,0 +1,3 @@
.ui-multiselect-hasfilter ul { position:relative; top:2px }
.ui-multiselect-filter { float:left; margin-right:10px; font-size:11px }
.ui-multiselect-filter input { width:100px; font-size:10px; margin-left:5px; height:15px; padding:2px; border:1px solid #292929; -webkit-appearance:textfield; -webkit-box-sizing:content-box; }

View File

@ -0,0 +1,219 @@
/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */
/*
* jQuery MultiSelect UI Widget Filtering Plugin 2.0.0
* Copyright (c) 2012 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
* Depends:
* - jQuery UI MultiSelect widget
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($) {
var rEscape = /[\-\[\]{}()*+?.,\\\^$|#\s]/g;
//Courtesy of underscore.js
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(context, args);
}
};
}
$.widget('ech.multiselectfilter', {
options: {
label: 'Filter:',
width: null, /* override default width set in css file (px). null will inherit */
placeholder: 'Enter keywords',
autoReset: false,
debounceMS: 250
},
_create: function() {
var opts = this.options;
var elem = $(this.element);
// get the multiselect instance
this.instance = elem.multiselect('instance');
// store header; add filter class so the close/check all/uncheck all links can be positioned correctly
this.header = this.instance.menu.find('.ui-multiselect-header').addClass('ui-multiselect-hasfilter');
// wrapper elem
this.input = $("<input/>").attr({
placeholder: opts.placeholder,
type: "search"
}).css({
width: (/\d/.test(opts.width) ? opts.width + 'px' : null)
}).bind({
keydown: function(e) {
// prevent the enter key from submitting the form / closing the widget
if(e.which === 13) {
e.preventDefault();
} else if(e.which === 27) {
elem.multiselect('close');
e.preventDefault();
} else if(e.which === 9 && e.shiftKey) {
elem.multiselect('close');
e.preventDefault();
} else if(e.altKey) {
switch(e.which) {
case 82:
e.preventDefault();
$(this).val('').trigger('input', '');
break;
case 65:
elem.multiselect('checkAll');
break;
case 85:
elem.multiselect('uncheckAll');
break;
case 76:
elem.multiselect('instance').labels.first().trigger("mouseenter");
break;
}
}
},
input: $.proxy(debounce(this._handler, opts.debounceMS), this),
search: $.proxy(this._handler, this)
});
// automatically reset the widget on close?
if(this.options.autoReset) {
elem.bind('multiselectclose', $.proxy(this._reset, this));
}
// rebuild cache when multiselect is updated
elem.bind('multiselectrefresh', $.proxy(function() {
this.updateCache();
this._handler();
}, this));
this.wrapper = $("<div/>").addClass("ui-multiselect-filter").text(opts.label).append(this.input).prependTo(this.header);
// reference to the actual inputs
this.inputs = this.instance.menu.find('input[type="checkbox"], input[type="radio"]');
// cache input values for searching
this.updateCache();
// rewrite internal _toggleChecked fn so that when checkAll/uncheckAll is fired,
// only the currently filtered elements are checked
this.instance._toggleChecked = function(flag, group) {
var $inputs = (group && group.length) ? group : this.labels.find('input');
var _self = this;
// do not include hidden elems if the menu isn't open.
var selector = _self._isOpen ? ':disabled, :hidden' : ':disabled';
$inputs = $inputs
.not(selector)
.each(this._toggleState('checked', flag));
// update text
this.update();
// gather an array of the values that actually changed
var values = {};
$inputs.each(function() {
values[this.value] = true;
});
// select option tags
this.element.find('option').filter(function() {
if(!this.disabled && values[this.value]) {
_self._toggleState('selected', flag).call(this);
}
});
// trigger the change event on the select
if($inputs.length) {
this.element.trigger('change');
}
};
},
// thx for the logic here ben alman
_handler: function(e) {
var term = $.trim(this.input[0].value.toLowerCase()),
// speed up lookups
rows = this.rows, inputs = this.inputs, cache = this.cache;
var $groups = this.instance.menu.find(".ui-multiselect-optgroup");
$groups.show();
if(!term) {
rows.show();
} else {
rows.hide();
var regex = new RegExp(term.replace(rEscape, "\\$&"), 'gi');
this._trigger("filter", e, $.map(cache, function(v, i) {
if(v.search(regex) !== -1) {
rows.eq(i).show();
return inputs.get(i);
}
return null;
}));
}
// show/hide optgroups
$groups.each(function() {
var $this = $(this);
if(!$this.children("li:visible").length) {
$this.hide();
}
});
this.instance._setMenuHeight();
},
_reset: function() {
this.input.val('').trigger('input', '');
},
updateCache: function() {
// each list item
this.rows = this.instance.labels.parent();
// cache
this.cache = this.element.children().map(function() {
var elem = $(this);
// account for optgroups
if(this.tagName.toLowerCase() === "optgroup") {
elem = elem.children();
}
return elem.map(function() {
return this.innerHTML.toLowerCase();
}).get();
}).get();
},
widget: function() {
return this.wrapper;
},
destroy: function() {
$.Widget.prototype.destroy.call(this);
this.input.val('').trigger("keyup");
this.wrapper.remove();
}
});
})(jQuery);

View File

@ -1,6 +1,7 @@
/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */
/*
* jQuery MultiSelect UI Widget Filtering Plugin 1.4
* Copyright (c) 2011 Eric Hynds
* jQuery MultiSelect UI Widget Filtering Plugin 2.0.0
* Copyright (c) 2012 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
@ -11,5 +12,5 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function(a){var f=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;a.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:!1},_create:function(){var e;var b=this,c=this.options,d=this.instance=a(this.element).data("multiselect");this.header=d.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");e=this.wrapper=a('<div class="ui-multiselect-filter">'+(c.label.length?c.label:"")+'<input placeholder="'+c.placeholder+'" type="search"'+(/\d/.test(c.width)? 'style="width:'+c.width+'px"':"")+" /></div>").prependTo(this.header),c=e;this.inputs=d.menu.find('input[type="checkbox"], input[type="radio"]');this.input=c.find("input").bind({keydown:function(a){13===a.which&&a.preventDefault()},keyup:a.proxy(b._handler,b),click:a.proxy(b._handler,b)});this.updateCache();d._toggleChecked=function(c,d){var e=d&&d.length?d:this.labels.find("input"),i=this,e=e.not(b.instance._isOpen?":disabled, :hidden":":disabled").each(this._toggleState("checked",c));this.update(); var j=e.map(function(){return this.value}).get();this.element.find("option").filter(function(){!this.disabled&&-1<a.inArray(this.value,j)&&i._toggleState("selected",c).call(this)})};d=a(document).bind("multiselectrefresh",function(){b.updateCache();b._handler()});this.options.autoReset&&d.bind("multiselectclose",a.proxy(this._reset,this))},_handler:function(b){var c=a.trim(this.input[0].value.toLowerCase()),d=this.rows,g=this.inputs,h=this.cache;if(c){d.hide();var e=RegExp(c.replace(f,"\\$&"),"gi"); this._trigger("filter",b,a.map(h,function(a,b){return-1!==a.search(e)?(d.eq(b).show(),g.get(b)):null}))}else d.show();this.instance.menu.find(".ui-multiselect-optgroup-label").each(function(){var b=a(this),c=b.nextUntil(".ui-multiselect-optgroup-label").filter(function(){return"none"!==a.css(this,"display")}).length;b[c?"show":"hide"]()})},_reset:function(){this.input.val("").trigger("keyup")},updateCache:function(){this.rows=this.instance.menu.find(".ui-multiselect-checkboxes li:not(.ui-multiselect-optgroup-label)");this.cache=this.element.children().map(function(){var b=a(this);"optgroup"===this.tagName.toLowerCase()&&(b=b.children());return b.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){a.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery);
*/
(function($){var rEscape=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){func.apply(context,args)}}}$.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:false,debounceMS:250},_create:function(){var opts=this.options;var elem=$(this.element);this.instance=elem.multiselect("instance");this.header=this.instance.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");this.input=$("<input/>").attr({placeholder:opts.placeholder,type:"search"}).css({width:/\d/.test(opts.width)?opts.width+"px":null}).bind({keydown:function(e){if(e.which===13){e.preventDefault()}else if(e.which===27){elem.multiselect("close");e.preventDefault()}else if(e.which===9&&e.shiftKey){elem.multiselect("close");e.preventDefault()}else if(e.altKey){switch(e.which){case 82:e.preventDefault();$(this).val("").trigger("input","");break;case 65:elem.multiselect("checkAll");break;case 85:elem.multiselect("uncheckAll");break;case 76:elem.multiselect("instance").labels.first().trigger("mouseenter");break}}},input:$.proxy(debounce(this._handler,opts.debounceMS),this),search:$.proxy(this._handler,this)});if(this.options.autoReset){elem.bind("multiselectclose",$.proxy(this._reset,this))}elem.bind("multiselectrefresh",$.proxy(function(){this.updateCache();this._handler()},this));this.wrapper=$("<div/>").addClass("ui-multiselect-filter").text(opts.label).append(this.input).prependTo(this.header);this.inputs=this.instance.menu.find('input[type="checkbox"], input[type="radio"]');this.updateCache();this.instance._toggleChecked=function(flag,group){var $inputs=group&&group.length?group:this.labels.find("input");var _self=this;var selector=_self._isOpen?":disabled, :hidden":":disabled";$inputs=$inputs.not(selector).each(this._toggleState("checked",flag));this.update();var values={};$inputs.each(function(){values[this.value]=true});this.element.find("option").filter(function(){if(!this.disabled&&values[this.value]){_self._toggleState("selected",flag).call(this)}});if($inputs.length){this.element.trigger("change")}}},_handler:function(e){var term=$.trim(this.input[0].value.toLowerCase()),rows=this.rows,inputs=this.inputs,cache=this.cache;var $groups=this.instance.menu.find(".ui-multiselect-optgroup");$groups.show();if(!term){rows.show()}else{rows.hide();var regex=new RegExp(term.replace(rEscape,"\\$&"),"gi");this._trigger("filter",e,$.map(cache,function(v,i){if(v.search(regex)!==-1){rows.eq(i).show();return inputs.get(i)}return null}))}$groups.each(function(){var $this=$(this);if(!$this.children("li:visible").length){$this.hide()}});this.instance._setMenuHeight()},_reset:function(){this.input.val("").trigger("input","")},updateCache:function(){this.rows=this.instance.labels.parent();this.cache=this.element.children().map(function(){var elem=$(this);if(this.tagName.toLowerCase()==="optgroup"){elem=elem.children()}return elem.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){$.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery);

View File

@ -0,0 +1,952 @@
/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */
/*
* jQuery MultiSelect UI Widget 2.0.1
* Copyright (c) 2012 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
* Depends:
* - jQuery 1.4.2+
* - jQuery UI 1.11 widget factory
*
* Optional:
* - jQuery UI effects
* - jQuery UI position utility
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($, undefined) {
// Counter used to prevent collisions
var multiselectID = 0;
var $doc = $(document);
$.widget("ech.multiselect", {
// default options
options: {
header: true,
height: 175,
minWidth: 225,
classes: '',
checkAllText: 'Check all',
uncheckAllText: 'Uncheck all',
noneSelectedText: 'Select options',
showCheckAll: true,
showUncheckAll: true,
selectedText: '# selected',
selectedList: 0,
closeIcon: 'ui-icon-circle-close',
show: null,
hide: null,
autoOpen: false,
multiple: true,
position: {},
appendTo: null,
menuWidth:null,
selectedListSeparator: ', ',
disableInputsOnToggle: true,
groupColumns: false
},
_getAppendEl: function() {
var element = this.options.appendTo;
if(element) {
element = element.jquery || element.nodeType ? $(element) : this.document.find(element).eq(0);
}
if(!element || !element[0]) {
element = this.element.closest(".ui-front, dialog");
}
if(!element.length) {
element = this.document[0].body;
}
return element;
},
_create: function() {
var el = this.element;
var o = this.options;
this.speed = $.fx.speeds._default; // default speed for effects
this._isOpen = false; // assume no
this.inputIdCounter = 0;
// create a unique namespace for events that the widget
// factory cannot unbind automatically. Use eventNamespace if on
// jQuery UI 1.9+, and otherwise fallback to a custom string.
this._namespaceID = this.eventNamespace || ('multiselect' + multiselectID);
// bump unique ID after assigning it to the widget instance
this.multiselectID = multiselectID++;
var button = (this.button = $('<button type="button"><span class="ui-icon ui-icon-triangle-1-s"></span></button>'))
.addClass('ui-multiselect ui-widget ui-state-default ui-corner-all')
.addClass(o.classes)
.attr({ 'title':el.attr('title'), 'tabIndex':el.attr('tabIndex'), 'id': el.attr('id') ? el.attr('id') + '_ms' : null })
.prop('aria-haspopup', true)
.insertAfter(el);
this.buttonlabel = $('<span />')
.html(o.noneSelectedText)
.appendTo(button);
this.menu = $('<div />')
.addClass('ui-multiselect-menu ui-widget ui-widget-content ui-corner-all')
.addClass(o.classes)
.appendTo(this._getAppendEl());
this.header = $('<div />')
.addClass('ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix')
.appendTo(this.menu);
this.headerLinkContainer = $('<ul />')
.addClass('ui-helper-reset')
.html(function() {
if(o.header === true) {
var header_lis = '';
if(o.showCheckAll) {
header_lis = '<li><a class="ui-multiselect-all" href="#"><span class="ui-icon ui-icon-check"></span><span>' + o.checkAllText + '</span></a></li>';
}
if(o.showUncheckAll) {
header_lis += '<li><a class="ui-multiselect-none" href="#"><span class="ui-icon ui-icon-closethick"></span><span>' + o.uncheckAllText + '</span></a></li>';
}
return header_lis;
} else if(typeof o.header === "string") {
return '<li>' + o.header + '</li>';
} else {
return '';
}
})
.append('<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close"><span class="ui-icon '+o.closeIcon+'"></span></a></li>')
.appendTo(this.header);
var checkboxContainer = (this.checkboxContainer = $('<ul />'))
.addClass('ui-multiselect-checkboxes ui-helper-reset')
.appendTo(this.menu);
// perform event bindings
this._bindEvents();
// build menu
this.refresh(true);
// some addl. logic for single selects
if(!o.multiple) {
this.menu.addClass('ui-multiselect-single');
}
el.hide();
},
_init: function() {
if(this.options.header === false) {
this.header.hide();
}
if(!this.options.multiple) {
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').hide();
} else {
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').show();
}
if(this.options.autoOpen) {
this.open();
}
if(this.element.is(':disabled')) {
this.disable();
}
},
_makeOption: function(option) {
var title = option.title ? option.title : null;
var value = option.value;
var id = this.element.attr('id') || this.multiselectID; // unique ID for the label & option tags
var inputID = 'ui-multiselect-' + this.multiselectID + '-' + (option.id || id + '-option-' + this.inputIdCounter++);
var isDisabled = option.disabled;
var isSelected = option.selected;
var labelClasses = [ 'ui-corner-all' ];
var liClasses = [];
var o = this.options;
if(isDisabled) {
liClasses.push('ui-multiselect-disabled');
labelClasses.push('ui-state-disabled');
}
if(option.className) {
liClasses.push(option.className);
}
if(isSelected && !o.multiple) {
labelClasses.push('ui-state-active');
}
var $item = $("<li/>").addClass(liClasses.join(' '));
var $label = $("<label/>").attr({
"for": inputID,
"title": title
}).addClass(labelClasses.join(' ')).appendTo($item);
var $input = $("<input/>").attr({
"name": "multiselect_" + id,
"type": o.multiple ? "checkbox" : "radio",
"value": value,
"title": title,
"id": inputID,
"checked": isSelected ? "checked" : null,
"aria-selected": isSelected ? "true" : null,
"disabled": isDisabled ? "disabled" : null,
"aria-disabled": isDisabled ? "true" : null
}).data($(option).data()).appendTo($label);
$("<span/>").text($(option).text()).appendTo($label);
return $item;
},
_buildOptionList: function(element, $appendTo) {
var self = this;
element.children().each(function() {
var $this = $(this);
if(this.tagName === 'OPTGROUP') {
var $optionGroup = $("<ul/>").addClass('ui-multiselect-optgroup ' + this.className).appendTo($appendTo);
if(self.options.groupColumns) {
$optionGroup.addClass("ui-multiselect-columns");
}
$("<a/>").text(this.getAttribute('label')).appendTo($optionGroup);
self._buildOptionList($this, $optionGroup);
} else {
var $listItem = self._makeOption(this).appendTo($appendTo);
}
});
},
refresh: function(init) {
var self = this;
var el = this.element;
var o = this.options;
var menu = this.menu;
var checkboxContainer = this.checkboxContainer;
var html = "";
var $dropdown = $("<ul/>").addClass('ui-multiselect-checkboxes ui-helper-reset');
this.inputIdCounter = 0;
// update header link container visibility if needed
if (this.options.header) {
if(!this.options.multiple) {
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').hide();
} else {
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').show();
}
}
this._buildOptionList(el, $dropdown);
this.menu.find(".ui-multiselect-checkboxes").remove();
this.menu.append($dropdown);
// cache some moar useful elements
this.labels = menu.find('label');
this.inputs = this.labels.children('input');
this._setButtonWidth();
this.update(true);
// broadcast refresh event; useful for widgets
if(!init) {
this._trigger('refresh');
}
},
// updates the button text. call refresh() to rebuild
update: function(isDefault) {
var o = this.options;
var $inputs = this.inputs;
var $checked = $inputs.filter(':checked');
var numChecked = $checked.length;
var value;
if(numChecked === 0) {
value = o.noneSelectedText;
} else {
if($.isFunction(o.selectedText)) {
value = o.selectedText.call(this, numChecked, $inputs.length, $checked.get());
} else if(/\d/.test(o.selectedList) && o.selectedList > 0 && numChecked <= o.selectedList) {
value = $checked.map(function() { return $(this).next().text(); }).get().join(o.selectedListSeparator);
} else {
value = o.selectedText.replace('#', numChecked).replace('#', $inputs.length);
}
}
this._setButtonValue(value);
if(isDefault) {
this.button[0].defaultValue = value;
}
},
// this exists as a separate method so that the developer
// can easily override it.
_setButtonValue: function(value) {
this.buttonlabel.text(value);
},
_bindButtonEvents: function() {
var self = this;
var button = this.button;
function clickHandler() {
self[ self._isOpen ? 'close' : 'open' ]();
return false;
}
// webkit doesn't like it when you click on the span :(
button
.find('span')
.bind('click.multiselect', clickHandler);
// button events
button.bind({
click: clickHandler,
keypress: function(e) {
switch(e.which) {
case 27: // esc
case 38: // up
case 37: // left
self.close();
break;
case 39: // right
case 40: // down
self.open();
break;
}
},
mouseenter: function() {
if(!button.hasClass('ui-state-disabled')) {
$(this).addClass('ui-state-hover');
}
},
mouseleave: function() {
$(this).removeClass('ui-state-hover');
},
focus: function() {
if(!button.hasClass('ui-state-disabled')) {
$(this).addClass('ui-state-focus');
}
},
blur: function() {
$(this).removeClass('ui-state-focus');
}
});
},
_bindMenuEvents: function() {
var self = this;
// optgroup label toggle support
this.menu.delegate('.ui-multiselect-optgroup a', 'click.multiselect', function(e) {
e.preventDefault();
var $this = $(this);
var $inputs = $this.parent().find('input:visible:not(:disabled)');
var nodes = $inputs.get();
var label = $this.text();
// trigger event and bail if the return is false
if(self._trigger('beforeoptgrouptoggle', e, { inputs:nodes, label:label }) === false) {
return;
}
// toggle inputs
self._toggleChecked(
$inputs.filter(':checked').length !== $inputs.length,
$inputs
);
self._trigger('optgrouptoggle', e, {
inputs: nodes,
label: label,
checked: nodes.length ? nodes[0].checked : null
});
})
.delegate('label', 'mouseenter.multiselect', function() {
if(!$(this).hasClass('ui-state-disabled')) {
self.labels.removeClass('ui-state-hover');
$(this).addClass('ui-state-hover').find('input').focus();
}
})
.delegate('label', 'keydown.multiselect', function(e) {
if(e.which === 82) {
return; //"r" key, often used for reload.
}
if(e.which > 111 && e.which < 124) {
return; //Keyboard function keys.
}
e.preventDefault();
switch(e.which) {
case 9: // tab
if(e.shiftKey) {
self.menu.find(".ui-state-hover").removeClass("ui-state-hover");
self.header.find("li").last().find("a").focus();
} else {
self.close();
}
break;
case 27: // esc
self.close();
break;
case 38: // up
case 40: // down
case 37: // left
case 39: // right
self._traverse(e.which, this);
break;
case 13: // enter
case 32:
$(this).find('input')[0].click();
break;
case 65:
if(e.altKey) {
self.checkAll();
}
break;
case 85:
if(e.altKey) {
self.uncheckAll();
}
break;
}
})
.delegate('input[type="checkbox"], input[type="radio"]', 'click.multiselect', function(e) {
var $this = $(this);
var val = this.value;
var optionText = $this.parent().find("span").text();
var checked = this.checked;
var tags = self.element.find('option');
// bail if this input is disabled or the event is cancelled
if(this.disabled || self._trigger('click', e, { value: val, text: optionText, checked: checked }) === false) {
e.preventDefault();
return;
}
// make sure the input has focus. otherwise, the esc key
// won't close the menu after clicking an item.
$this.focus();
// toggle aria state
$this.prop('aria-selected', checked);
// change state on the original option tags
tags.each(function() {
if(this.value === val) {
this.selected = checked;
} else if(!self.options.multiple) {
this.selected = false;
}
});
// some additional single select-specific logic
if(!self.options.multiple) {
self.labels.removeClass('ui-state-active');
$this.closest('label').toggleClass('ui-state-active', checked);
// close menu
self.close();
}
// fire change on the select box
self.element.trigger("change");
// setTimeout is to fix multiselect issue #14 and #47. caused by jQuery issue #3827
// http://bugs.jquery.com/ticket/3827
setTimeout($.proxy(self.update, self), 10);
});
},
_bindHeaderEvents: function() {
var self = this;
// header links
this.header.delegate('a', 'click.multiselect', function(e) {
var $this = $(this);
if($this.hasClass('ui-multiselect-close')) {
self.close();
} else if($this.hasClass("ui-multiselect-all")) {
self.checkAll();
} else if($this.hasClass("ui-multiselect-none")) {
self.uncheckAll();
}
e.preventDefault();
}).delegate('a', 'keydown.multiselect', function(e) {
switch(e.which) {
case 27:
self.close();
break;
case 9:
var $target = $(e.target);
if((e.shiftKey && !$target.parent().prev().length && !self.header.find(".ui-multiselect-filter").length) || (!$target.parent().next().length && !self.labels.length && !e.shiftKey)) {
self.close();
e.preventDefault();
}
break;
}
});
},
// binds events
_bindEvents: function() {
var self = this;
this._bindButtonEvents();
this._bindMenuEvents();
this._bindHeaderEvents();
// close each widget when clicking on any other element/anywhere else on the page
$doc.bind('mousedown.' + self._namespaceID, function(event) {
var target = event.target;
if(self._isOpen &&
target !== self.button[0] &&
target !== self.menu[0] &&
!$.contains(self.menu[0], target) &&
!$.contains(self.button[0], target)
) {
self.close();
}
});
// deal with form resets. the problem here is that buttons aren't
// restored to their defaultValue prop on form reset, and the reset
// handler fires before the form is actually reset. delaying it a bit
// gives the form inputs time to clear.
$(this.element[0].form).bind('reset.' + this._namespaceID, function() {
setTimeout($.proxy(self.refresh, self), 10);
});
},
_getMinWidth: function() {
var minVal = this.options.minWidth;
var width = 0;
switch (typeof minVal) {
case 'number':
width = minVal;
break;
case 'string':
var lastChar = minVal[ minVal.length -1 ];
width = minVal.match(/\d+/);
if(lastChar === '%') {
width = this.element.parent().outerWidth() * (width/100);
} else {
width = parseInt(minVal, 10);
}
break;
}
return width;
},
// set button width
_setButtonWidth: function() {
var width = this.element.outerWidth();
var minVal = this._getMinWidth();
if(width < minVal) {
width = minVal;
}
// set widths
this.button.outerWidth(width);
},
// set menu width
_setMenuWidth: function() {
var m = this.menu;
var width = (this.button.outerWidth() <= 0) ? this._getMinWidth() : this.button.outerWidth();
m.outerWidth(this.options.menuWidth || width);
},
_setMenuHeight: function() {
var headerHeight = this.menu.children(".ui-multiselect-header:visible").outerHeight(true);
var ulHeight = 0;
this.menu.find(".ui-multiselect-checkboxes li, .ui-multiselect-checkboxes a").each(function(idx, li) {
ulHeight += $(li).outerHeight(true);
});
if(ulHeight > this.options.height) {
this.menu.children(".ui-multiselect-checkboxes").css("overflow", "auto");
ulHeight = this.options.height;
} else {
this.menu.children(".ui-multiselect-checkboxes").css("overflow", "hidden");
}
this.menu.children(".ui-multiselect-checkboxes").height(ulHeight);
this.menu.height(ulHeight + headerHeight);
},
_resizeMenu: function() {
this._setMenuWidth();
this._setMenuHeight();
},
// move up or down within the menu
_traverse: function(which, start) {
var $start = $(start);
var moveToLast = which === 38 || which === 37;
// select the first li that isn't an optgroup label / disabled
var $next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup):visible').first();
// we might have to jump to the next/previous option group
if(!$next.length) {
$next = $start.parents(".ui-multiselect-optgroup")[moveToLast ? "prev" : "next" ]();
}
// if at the first/last element
if(!$next.length) {
var $container = this.menu.find('ul').last();
// move to the first/last
this.menu.find('label:visible')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
// set scroll position
$container.scrollTop(moveToLast ? $container.height() : 0);
} else {
$next.find('label:visible')[ moveToLast ? "last" : "first" ]().trigger('mouseover');
}
},
// This is an internal function to toggle the checked property and
// other related attributes of a checkbox.
//
// The context of this function should be a checkbox; do not proxy it.
_toggleState: function(prop, flag) {
return function() {
if(!this.disabled) {
this[ prop ] = flag;
}
if(flag) {
this.setAttribute('aria-selected', true);
} else {
this.removeAttribute('aria-selected');
}
};
},
_toggleChecked: function(flag, group) {
var $inputs = (group && group.length) ? group : this.inputs;
var self = this;
// toggle state on inputs
$inputs.each(this._toggleState('checked', flag));
// give the first input focus
$inputs.eq(0).focus();
// update button text
this.update();
// gather an array of the values that actually changed
var values = {};
$inputs.each(function() {
values[this.value] = true;
});
// toggle state on original option tags
this.element
.find('option')
.each(function() {
if(!this.disabled && values[this.value]) {
self._toggleState('selected', flag).call(this);
}
});
// trigger the change event on the select
if($inputs.length) {
this.element.trigger("change");
}
},
_toggleDisabled: function(flag) {
this.button.prop({ 'disabled':flag, 'aria-disabled':flag })[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
if(this.options.disableInputsOnToggle) {
var checkboxes = this.menu.find(".ui-multiselect-checkboxes").get(0);
var matchedInputs = [];
var key = "ech-multiselect-disabled";
var i = 0;
if(flag) {
// remember which elements this widget disabled (not pre-disabled)
// elements, so that they can be restored if the widget is re-enabled.
matchedInputs = checkboxes.querySelectorAll("input:enabled");
for(i = 0; i < matchedInputs.length; i++) {
matchedInputs[i].setAttribute(key, true);
matchedInputs[i].setAttribute("disabled", "disabled");
matchedInputs[i].setAttribute("aria-disabled", "disabled");
matchedInputs[i].parentNode.className = matchedInputs[i].parentNode.className + " ui-state-disabled";
}
} else {
matchedInputs = checkboxes.querySelectorAll("input:disabled");
for(i = 0; i < matchedInputs.length; i++) {
if(matchedInputs[i].hasAttribute(key)) {
matchedInputs[i].removeAttribute(key);
matchedInputs[i].removeAttribute("disabled");
matchedInputs[i].removeAttribute("aria-disabled");
matchedInputs[i].parentNode.className = matchedInputs[i].parentNode.className.replace(" ui-state-disabled", "");
}
}
}
}
this.element.prop({
'disabled':flag,
'aria-disabled':flag
});
},
// open the menu
open: function(e) {
var self = this;
var button = this.button;
var menu = this.menu;
var speed = this.speed;
var o = this.options;
var args = [];
// bail if the multiselectopen event returns false, this widget is disabled, or is already open
if(this._trigger('beforeopen') === false || button.hasClass('ui-state-disabled') || this._isOpen) {
return;
}
var $container = menu.find('.ui-multiselect-checkboxes');
var effect = o.show;
// figure out opening effects/speeds
if($.isArray(o.show)) {
effect = o.show[0];
speed = o.show[1] || self.speed;
}
// if there's an effect, assume jQuery UI is in use
// build the arguments to pass to show()
if(effect) {
args = [ effect, speed ];
}
// set the scroll of the checkbox container
$container.scrollTop(0);
// show the menu, maybe with a speed/effect combo
$.fn.show.apply(menu, args);
this._resizeMenu();
// positon
this.position();
// select the first not disabled option or the filter input if available
var filter = this.header.find(".ui-multiselect-filter");
if(filter.length) {
filter.first().find('input').trigger('focus');
} else if(this.labels.length){
this.labels.filter(':not(.ui-state-disabled)').eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');
} else {
this.header.find('a').first().trigger('focus');
}
button.addClass('ui-state-active');
this._isOpen = true;
this._trigger('open');
},
// close the menu
close: function() {
if(this._trigger('beforeclose') === false) {
return;
}
var o = this.options;
var effect = o.hide;
var speed = this.speed;
var args = [];
// figure out opening effects/speeds
if($.isArray(o.hide)) {
effect = o.hide[0];
speed = o.hide[1] || this.speed;
}
if(effect) {
args = [ effect, speed ];
}
$.fn.hide.apply(this.menu, args);
this.button.removeClass('ui-state-active').trigger('blur').trigger('mouseleave');
this._isOpen = false;
this._trigger('close');
this.button.trigger('focus');
},
enable: function() {
this._toggleDisabled(false);
},
disable: function() {
this._toggleDisabled(true);
},
checkAll: function(e) {
this._toggleChecked(true);
this._trigger('checkAll');
},
uncheckAll: function() {
this._toggleChecked(false);
this._trigger('uncheckAll');
},
getChecked: function() {
return this.menu.find('input').filter(':checked');
},
getUnchecked: function() {
return this.menu.find('input').not(':checked');
},
destroy: function() {
// remove classes + data
$.Widget.prototype.destroy.call(this);
// unbind events
$doc.unbind(this._namespaceID);
$(this.element[0].form).unbind(this._namespaceID);
this.button.remove();
this.menu.remove();
this.element.show();
return this;
},
isOpen: function() {
return this._isOpen;
},
widget: function() {
return this.menu;
},
getButton: function() {
return this.button;
},
getMenu: function() {
return this.menu;
},
getLabels: function() {
return this.labels;
},
addOption: function(attributes, text, groupLabel) {
var $option = $("<option/>").attr(attributes).text(text);
var optionNode = $option.get(0);
if(groupLabel) {
this.element.children("OPTGROUP").filter(function() {
return $(this).prop("label") === groupLabel;
}).append($option);
this.menu.find(".ui-multiselect-optgroup").filter(function() {
return $(this).find("a").text() === groupLabel;
}).append(this._makeOption(optionNode));
} else {
this.element.append($option);
this.menu.find(".ui-multiselect-checkboxes").append(this._makeOption(optionNode));
}
//update cached elements
this.labels = this.menu.find('label');
this.inputs = this.labels.children('input');
},
removeOption: function(value) {
if(!value) {
return;
}
this.element.find("option[value=" + value + "]").remove();
this.labels.find("input[value=" + value + "]").parents("li").remove();
//update cached elements
this.labels = this.menu.find('label');
this.inputs = this.labels.children('input');
},
position: function() {
var pos = {
my: "top",
at: "bottom",
of: this.button
};
if(!$.isEmptyObject(this.options.position)) {
pos.my = this.options.position.my || pos.my;
pos.at = this.options.position.at || pos.at;
pos.of = this.options.position.of || pos.of;
}
if($.ui && $.ui.position) {
this.menu.position(pos);
} else {
pos = this.button.position();
pos.top += this.button.outerHeight(false);
this.menu.offset(pos);
}
},
// react to option changes after initialization
_setOption: function(key, value) {
var menu = this.menu;
switch(key) {
case 'header':
if(typeof value === 'boolean') {
this.header[value ? 'show' : 'hide']();
} else if(typeof value === 'string') {
this.headerLinkContainer.children("li:not(:last-child)").remove();
this.headerLinkContainer.prepend("<li>" + value + "</li>");
}
break;
case 'checkAllText':
menu.find('a.ui-multiselect-all span').eq(-1).text(value);
break;
case 'uncheckAllText':
menu.find('a.ui-multiselect-none span').eq(-1).text(value);
break;
case 'height':
this.options[key] = value;
this._setMenuHeight();
break;
case 'minWidth':
case 'menuWidth':
this.options[key] = value;
this._setButtonWidth();
this._setMenuWidth();
break;
case 'selectedText':
case 'selectedList':
case 'noneSelectedText':
this.options[key] = value; // these all needs to update immediately for the update() call
this.update();
break;
case 'classes':
menu.add(this.button).removeClass(this.options.classes).addClass(value);
break;
case 'multiple':
menu.toggleClass('ui-multiselect-single', !value);
this.options.multiple = value;
this.element[0].multiple = value;
this.uncheckAll();
this.refresh();
break;
case 'position':
this.position();
break;
case 'selectedListSeparator':
this.options[key] = value;
this.update(true);
break;
}
$.Widget.prototype._setOption.apply(this, arguments);
}
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -1,27 +0,0 @@
/*
* SimpleModal 1.4.4 - jQuery Plugin
* http://simplemodal.com/
* Copyright (c) 2013 Eric Martin
* Licensed under MIT and GPL
* Date: Sun, Jan 20 2013 15:58:56 -0800
*/
(function(b){"function"===typeof define&&define.amd?define(["jquery"],b):b(jQuery)})(function(b){var j=[],n=b(document),k=navigator.userAgent.toLowerCase(),l=b(window),g=[],o=null,p=/msie/.test(k)&&!/opera/.test(k),q=/opera/.test(k),m,r;m=p&&/msie 6./.test(k)&&"object"!==typeof window.XMLHttpRequest;r=p&&/msie 7.0/.test(k);b.modal=function(a,h){return b.modal.impl.init(a,h)};b.modal.close=function(){b.modal.impl.close()};b.modal.focus=function(a){b.modal.impl.focus(a)};b.modal.setContainerDimensions=
function(){b.modal.impl.setContainerDimensions()};b.modal.setPosition=function(){b.modal.impl.setPosition()};b.modal.update=function(a,h){b.modal.impl.update(a,h)};b.fn.modal=function(a){return b.modal.impl.init(this,a)};b.modal.defaults={appendTo:"body",focus:!0,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:!1,autoPosition:!0,zIndex:1E3,
close:!0,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:"simplemodal-close",escClose:!0,overlayClose:!1,fixed:!0,position:null,persist:!1,modal:!0,onOpen:null,onShow:null,onClose:null};b.modal.impl={d:{},init:function(a,h){if(this.d.data)return!1;o=p&&!b.support.boxModel;this.o=b.extend({},b.modal.defaults,h);this.zIndex=this.o.zIndex;this.occb=!1;if("object"===typeof a){if(a=a instanceof b?a:b(a),this.d.placeholder=!1,0<a.parent().parent().size()&&(a.before(b("<span></span>").attr("id",
"simplemodal-placeholder").css({display:"none"})),this.d.placeholder=!0,this.display=a.css("display"),!this.o.persist))this.d.orig=a.clone(!0)}else if("string"===typeof a||"number"===typeof a)a=b("<div></div>").html(a);else return alert("SimpleModal Error: Unsupported data type: "+typeof a),this;this.create(a);this.open();b.isFunction(this.o.onShow)&&this.o.onShow.apply(this,[this.d]);return this},create:function(a){this.getDimensions();if(this.o.modal&&m)this.d.iframe=b('<iframe src="javascript:false;"></iframe>').css(b.extend(this.o.iframeCss,
{display:"none",opacity:0,position:"fixed",height:g[0],width:g[1],zIndex:this.o.zIndex,top:0,left:0})).appendTo(this.o.appendTo);this.d.overlay=b("<div></div>").attr("id",this.o.overlayId).addClass("simplemodal-overlay").css(b.extend(this.o.overlayCss,{display:"none",opacity:this.o.opacity/100,height:this.o.modal?j[0]:0,width:this.o.modal?j[1]:0,position:"fixed",left:0,top:0,zIndex:this.o.zIndex+1})).appendTo(this.o.appendTo);this.d.container=b("<div></div>").attr("id",this.o.containerId).addClass("simplemodal-container").css(b.extend({position:this.o.fixed?
"fixed":"absolute"},this.o.containerCss,{display:"none",zIndex:this.o.zIndex+2})).append(this.o.close&&this.o.closeHTML?b(this.o.closeHTML).addClass(this.o.closeClass):"").appendTo(this.o.appendTo);this.d.wrap=b("<div></div>").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(this.d.container);this.d.data=a.attr("id",a.attr("id")||this.o.dataId).addClass("simplemodal-data").css(b.extend(this.o.dataCss,{display:"none"})).appendTo("body");this.setContainerDimensions();
this.d.data.appendTo(this.d.wrap);(m||o)&&this.fixIE()},bindEvents:function(){var a=this;b("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()});a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});n.bind("keydown.simplemodal",function(b){a.o.modal&&9===b.keyCode?a.watchTab(b):a.o.close&&a.o.escClose&&27===b.keyCode&&(b.preventDefault(),a.close())});l.bind("resize.simplemodal orientationchange.simplemodal",
function(){a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();m||o?a.fixIE():a.o.modal&&(a.d.iframe&&a.d.iframe.css({height:g[0],width:g[1]}),a.d.overlay.css({height:j[0],width:j[1]}))})},unbindEvents:function(){b("."+this.o.closeClass).unbind("click.simplemodal");n.unbind("keydown.simplemodal");l.unbind(".simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this.o.position;b.each([this.d.iframe||null,!this.o.modal?null:this.d.overlay,
"fixed"===this.d.container.css("position")?this.d.container:null],function(b,e){if(e){var f=e[0].style;f.position="absolute";if(2>b)f.removeExpression("height"),f.removeExpression("width"),f.setExpression("height",'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"'),f.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"');else{var c,d;a&&a.constructor===
Array?(c=a[0]?"number"===typeof a[0]?a[0].toString():a[0].replace(/px/,""):e.css("top").replace(/px/,""),c=-1===c.indexOf("%")?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',a[1]&&(d="number"===typeof a[1]?
a[1].toString():a[1].replace(/px/,""),d=-1===d.indexOf("%")?d+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(d.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"')):(c='(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',
d='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"');f.removeExpression("top");f.removeExpression("left");f.setExpression("top",c);f.setExpression("left",d)}}})},focus:function(a){var h=this,a=a&&-1!==b.inArray(a,["first","last"])?a:"first",e=b(":input:enabled:visible:"+a,h.d.wrap);setTimeout(function(){0<e.length?e.focus():h.d.wrap.focus()},
10)},getDimensions:function(){var a="undefined"===typeof window.innerHeight?l.height():window.innerHeight;j=[n.height(),n.width()];g=[a,l.width()]},getVal:function(a,b){return a?"number"===typeof a?a:"auto"===a?0:0<a.indexOf("%")?parseInt(a.replace(/%/,""))/100*("h"===b?g[0]:g[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){if(!this.d.data)return!1;this.d.origHeight=this.getVal(a,"h");this.d.origWidth=this.getVal(b,"w");this.d.data.hide();a&&this.d.container.css("height",a);b&&this.d.container.css("width",
b);this.setContainerDimensions();this.d.data.show();this.o.focus&&this.focus();this.unbindEvents();this.bindEvents()},setContainerDimensions:function(){var a=m||r,b=this.d.origHeight?this.d.origHeight:q?this.d.container.height():this.getVal(a?this.d.container[0].currentStyle.height:this.d.container.css("height"),"h"),a=this.d.origWidth?this.d.origWidth:q?this.d.container.width():this.getVal(a?this.d.container[0].currentStyle.width:this.d.container.css("width"),"w"),e=this.d.data.outerHeight(!0),f=
this.d.data.outerWidth(!0);this.d.origHeight=this.d.origHeight||b;this.d.origWidth=this.d.origWidth||a;var c=this.o.maxHeight?this.getVal(this.o.maxHeight,"h"):null,d=this.o.maxWidth?this.getVal(this.o.maxWidth,"w"):null,c=c&&c<g[0]?c:g[0],d=d&&d<g[1]?d:g[1],i=this.o.minHeight?this.getVal(this.o.minHeight,"h"):"auto",b=b?this.o.autoResize&&b>c?c:b<i?i:b:e?e>c?c:this.o.minHeight&&"auto"!==i&&e<i?i:e:i,c=this.o.minWidth?this.getVal(this.o.minWidth,"w"):"auto",a=a?this.o.autoResize&&a>d?d:a<c?c:a:f?
f>d?d:this.o.minWidth&&"auto"!==c&&f<c?c:f:c;this.d.container.css({height:b,width:a});this.d.wrap.css({overflow:e>b||f>a?"auto":"visible"});this.o.autoPosition&&this.setPosition()},setPosition:function(){var a,b;a=g[0]/2-this.d.container.outerHeight(!0)/2;b=g[1]/2-this.d.container.outerWidth(!0)/2;var e="fixed"!==this.d.container.css("position")?l.scrollTop():0;this.o.position&&"[object Array]"===Object.prototype.toString.call(this.o.position)?(a=e+(this.o.position[0]||a),b=this.o.position[1]||b):
a=e+a;this.d.container.css({left:b,top:a})},watchTab:function(a){if(0<b(a.target).parents(".simplemodal-container").length){if(this.inputs=b(":input:enabled:visible:first, :input:enabled:visible:last",this.d.data[0]),!a.shiftKey&&a.target===this.inputs[this.inputs.length-1]||a.shiftKey&&a.target===this.inputs[0]||0===this.inputs.length)a.preventDefault(),this.focus(a.shiftKey?"last":"first")}else a.preventDefault(),this.focus()},open:function(){this.d.iframe&&this.d.iframe.show();b.isFunction(this.o.onOpen)?
this.o.onOpen.apply(this,[this.d]):(this.d.overlay.show(),this.d.container.show(),this.d.data.show());this.o.focus&&this.focus();this.bindEvents()},close:function(){if(!this.d.data)return!1;this.unbindEvents();if(b.isFunction(this.o.onClose)&&!this.occb)this.occb=!0,this.o.onClose.apply(this,[this.d]);else{if(this.d.placeholder){var a=b("#simplemodal-placeholder");this.o.persist?a.replaceWith(this.d.data.removeClass("simplemodal-data").css("display",this.display)):(this.d.data.hide().remove(),a.replaceWith(this.d.orig))}else this.d.data.hide().remove();
this.d.container.hide().remove();this.d.overlay.hide();this.d.iframe&&this.d.iframe.hide().remove();this.d.overlay.remove();this.d={}}}}});

View File

@ -272,64 +272,62 @@ function checkEAN() {
ean_timeout = setTimeout(function() {
var eanval = $("#eaninput").val();
if (eanval != "") {
/* Select simple product */
var eanval_item = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval) {
return $(this).attr("rel") == '0'+eanval;
/* Select pack product */
var eanval_item_pack = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval+'_pack') {
return $(this).attr("rel") == '0'+eanval+'_pack';
}
return $(this).attr("rel") == eanval;
});
if (eanval_item.length > 0) {
$(eanval_item).each(function(id, el) {
var current_val = parseInt($(el).find(".shipped input").val());
var max_val = parseInt($(el).find(".toship strong").text());
return $(this).attr("rel") == eanval+'_pack';
});
if (eanval_item_pack.length > 0) {
$(eanval_item_pack).each(function(id_pack, el_pack) {
var current_val = parseInt($(el_pack).find(".shipped input").val());
var max_val = parseInt($(el_pack).find(".toship strong").text());
if (current_val < max_val) {
qtyUp($(el).find(".shipped a")[0], max_val);
qtyUp($(el_pack).find(".shipped a")[0], max_val);
} else {
var eanval_item_pack = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval+'_pack') {
return $(this).attr("rel") == '0'+eanval+'_pack';
var eanval_item = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval) {
return $(this).attr("rel") == '0'+eanval;
}
return $(this).attr("rel") == eanval+'_pack';
return $(this).attr("rel") == eanval;
});
if (eanval_item_pack.length > 0) {
$(eanval_item_pack).each(function(id_pack, el_pack) {
var current_val = parseInt($(el_pack).find(".shipped input").val());
var max_val = parseInt($(el_pack).find(".toship strong").text());
if (eanval_item.length > 0) {
$(eanval_item).each(function(id, el) {
var current_val = parseInt($(el).find(".shipped input").val());
var max_val = parseInt($(el).find(".toship strong").text());
if (current_val < max_val) {
qtyUp($(el_pack).find(".shipped a")[0], max_val);
qtyUp($(el).find(".shipped a")[0], max_val);
} else {
confirm("Quantité à envoyer déjà atteinte pour ce produit");
confirm("Quantité à envoyer déjà atteinte pour ce produit");
}
});
} else {
confirm("Quantité à envoyer déjà atteinte pour ce produit");
}
}
}
});
}
/* Select pack product */
/* Select simple product */
else {
var eanval_item_pack = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval+'_pack') {
return $(this).attr("rel") == '0'+eanval+'_pack';
var eanval_item = $("#button_form tbody tr").filter(function() {
if ($(this).attr("rel") != eanval) {
return $(this).attr("rel") == '0'+eanval;
}
return $(this).attr("rel") == eanval+'_pack';
});
if (eanval_item_pack.length > 0) {
$(eanval_item_pack).each(function(id_pack, el_pack) {
var current_val = parseInt($(el_pack).find(".shipped input").val());
var max_val = parseInt($(el_pack).find(".toship strong").text());
return $(this).attr("rel") == eanval;
});
if (eanval_item.length > 0) {
$(eanval_item).each(function(id, el) {
var current_val = parseInt($(el).find(".shipped input").val());
var max_val = parseInt($(el).find(".toship strong").text());
if (current_val < max_val) {
qtyUp($(el_pack).find(".shipped a")[0], max_val);
qtyUp($(el).find(".shipped a")[0], max_val);
} else {
confirm("Quantité à envoyer déjà atteinte pour ce produit");
confirm("Quantité à envoyer déjà atteinte pour ce produit");
}
});
} else {
confirm("Aucun produit avec cet EAN13 ne figure dans cette commande");
confirm("Aucun produit avec cet EAN13 ne figure dans cette commande");
}
}
}
$("#eaninput").val("");
}
}, 200);

View File

@ -910,9 +910,9 @@ class AdminLogistics extends AdminTab
</div>
<form action="'.__PS_BASE_URI__.'modules/logistics/select_sale.php?token='.Tools::getValue('token').'&id_employee='.(int) $cookie->id_employee.'" method="POST">
<div><select multiple="true" id="filter_id_sale" name="filter_id_sale[]" style="display: none;">
<div>
<select multiple="true" id="filter_id_sale" name="filter_id_sale[]" style="display: none;">
';
foreach(Db::getInstance()->ExecuteS('
SELECT s.`id_sale`, c.`name`
FROM `'._DB_PREFIX_.'privatesale` s
@ -927,7 +927,9 @@ class AdminLogistics extends AdminTab
$this->_html .= '<option value="'.(int) $row['id_sale'].'"'.(in_array((int) $row['id_sale'], $sales_list)? ' selected="selected"': '').'>'.(int) $row['id_sale'].' - '.htmlentities($row['name']).'</option>';
}
$this->_html .= '</select><input class="button" type="submit" value="Valider" style="float: right;" /><br style="clear: both" /></div>
$this->_html .= '</select>
<input class="button" type="submit" value="Valider" style="float: right;" /><br style="clear: both" />
</div>
</form>
<fieldset style="overflow: auto; position: relative; margin-top: 30px;'.($cookie->profile == 1 || count($sales_list) > 0? ' display: block;': 'display: none;').'">