diff --git a/application/controllers/items.php b/application/controllers/items.php index 32706233c..b9ffc9237 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -320,7 +320,6 @@ class Items extends Secure_area implements iData_controller 'receiving_quantity'=>$this->input->post('receiving_quantity'), 'allow_alt_description'=>$this->input->post('allow_alt_description'), 'is_serialized'=>$this->input->post('is_serialized'), - 'pic_id'=>$upload_data['raw_name'], 'deleted'=>$this->input->post('is_deleted'), /** Parq 131215 **/ 'custom1'=>$this->input->post('custom1'), /**GARRISON ADDED 4/21/2013**/ 'custom2'=>$this->input->post('custom2'),/**GARRISON ADDED 4/21/2013**/ @@ -334,6 +333,11 @@ class Items extends Secure_area implements iData_controller 'custom10'=>$this->input->post('custom10')/**GARRISON ADDED 4/21/2013**/ ); + if (!empty($upload_data['raw_name'])) + { + $item_data['pic_id'] = $upload_data['raw_name']; + } + $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; $cur_item_info = $this->Item->get_info($item_id); @@ -417,8 +421,8 @@ class Items extends Secure_area implements iData_controller $config = array('upload_path' => './uploads/item_pics/', 'allowed_types' => 'gif|jpg|png', 'max_size' => '100', - 'max_width' => '1024', - 'max_height' => '768', + 'max_width' => '640', + 'max_height' => '480', 'file_name' => sizeof($map)); $this->load->library('upload', $config); $this->upload->do_upload('item_image'); diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 29c13929f..e1cdf1b52 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -228,7 +228,7 @@ function get_item_data_row($item,$controller) $images = glob ("uploads/item_pics/" . $item->pic_id . ".*"); if (sizeof($images) > 0) { - $image.=''; + $image.=''; } } $table_data_row.='' . $image . ''; diff --git a/application/views/items/manage.php b/application/views/items/manage.php index 5a0abbee2..ea398e763 100644 --- a/application/views/items/manage.php +++ b/application/views/items/manage.php @@ -22,12 +22,45 @@ $(document).ready(function() $(this).attr('href','index.php/items/generate_barcodes/'+selected.join(':')); }); - $("#is_serialized, #no_description, #search_custom, #is_deleted").click(function() + $('#is_serialized, #no_description, #search_custom, #is_deleted').click(function() { $('#items_filter_form').submit(); }); + + resize_thumbs(); }); +function resize_thumbs() +{ + $('a.rollover').imgPreview(); + $('a.rollover img').each(function() + { + var maxWidth = 52; // Max width for the image + var maxHeight = 32; // Max height for the image + var ratio = 0; // Used for aspect ratio + var width = $(this).width(); // Current image width + var height = $(this).height(); // Current image height + + // Check if the current width is larger than the max + if(width > maxWidth){ + ratio = maxWidth / width; // get ratio for scaling image + $(this).css("width", maxWidth); // Set new width + $(this).css("height", height * ratio); // Scale height based on ratio + height = height * ratio; // Reset height to match scaled image + width = width * ratio; // Reset width to match scaled image + } + + // Check if current height is larger than max + if(height > maxHeight){ + ratio = maxHeight / height; // get ratio for scaling image + $(this).css("height", maxHeight); // Set new height + $(this).css("width", width * ratio); // Scale width based on ratio + width = width * ratio; // Reset width to match scaled image + height = height * ratio; // Reset height to match scaled image + } + }); +} + function init_table_sorting() { @@ -59,9 +92,8 @@ function post_item_form_submit(response) //This is an update, just update one row if(jQuery.inArray(response.item_id,get_visible_checkbox_ids()) != -1) { - update_row(response.item_id,''); + update_row(response.item_id,'',resize_thumbs); set_feedback(response.message,'success_message',false); - } else //refresh entire table { @@ -86,7 +118,7 @@ function post_bulk_form_submit(response) var selected_item_ids=get_selected_values(); for(k=0;k'); + update_row(selected_item_ids[k],'',resize_thumbs); } set_feedback(response.message,'success_message',false); } diff --git a/application/views/partial/header.php b/application/views/partial/header.php index 3f65a343f..56d292004 100644 --- a/application/views/partial/header.php +++ b/application/views/partial/header.php @@ -18,6 +18,7 @@ + diff --git a/css/general.css b/css/general.css index 41cd7ddfd..cb0d8443a 100644 --- a/css/general.css +++ b/css/general.css @@ -140,21 +140,6 @@ input padding: 3px; } -input#search -{ - padding: 0px; -} - -select#stock_location -{ - border: none; -} - -#select_customer_form input, #select_supplier_form input -{ - width: 95%; -} - .clearfix:after { content: "."; diff --git a/css/ospos.css b/css/ospos.css index fd7b16729..2da97e799 100644 --- a/css/ospos.css +++ b/css/ospos.css @@ -151,3 +151,23 @@ a.none clear:both; } + +input#search +{ + padding: 0px; +} + +select#stock_location +{ + border: none; +} + +#select_customer_form input, #select_supplier_form input +{ + width: 95%; +} + +a.rollover img +{ + padding: 3px; +} diff --git a/js/imgpreview.full.jquery.js b/js/imgpreview.full.jquery.js new file mode 100644 index 000000000..c2f370342 --- /dev/null +++ b/js/imgpreview.full.jquery.js @@ -0,0 +1,109 @@ +/* + * imgPreview jQuery plugin + * Copyright (c) 2009 James Padolsey + * j@qd9.co.uk | http://james.padolsey.com + * Dual licensed under MIT and GPL. + * Updated: 09/02/09 + * @author James Padolsey + * @version 0.22 + */ +(function($){ + + $.expr[':'].linkingToImage = function(elem, index, match){ + // This will return true if the specified attribute contains a valid link to an image: + return !! ($(elem).attr(match[3]) && $(elem).attr(match[3]).match(/\.(gif|jpe?g|png|bmp)$/i)); + }; + + $.fn.imgPreview = function(userDefinedSettings){ + + var s = $.extend({ + + /* DEFAULTS */ + + // CSS to be applied to image: + imgCSS: {}, + // Distance between cursor and preview: + distanceFromCursor: {top:10, left:10}, + // Boolean, whether or not to preload images: + preloadImages: true, + // Callback: run when link is hovered: container is shown: + onShow: function(){}, + // Callback: container is hidden: + onHide: function(){}, + // Callback: Run when image within container has loaded: + onLoad: function(){}, + // ID to give to container (for CSS styling): + containerID: 'imgPreviewContainer', + // Class to be given to container while image is loading: + containerLoadingClass: 'loading', + // Prefix (if using thumbnails), e.g. 'thumb_' + thumbPrefix: '', + // Where to retrieve the image from: + srcAttr: 'href' + + }, userDefinedSettings), + + $container = $('
').attr('id', s.containerID) + .append('').hide() + .css('position','absolute') + .appendTo('body'), + + $img = $('img', $container).css(s.imgCSS), + + // Get all valid elements (linking to images / ATTR with image link): + $collection = this.filter(':linkingToImage(' + s.srcAttr + ')'); + + // Re-usable means to add prefix (from setting): + function addPrefix(src) { + return src.replace(/(\/?)([^\/]+)$/,'$1' + s.thumbPrefix + '$2'); + } + + if (s.preloadImages) { + (function(i){ + var tempIMG = new Image(), + callee = arguments.callee; + tempIMG.src = addPrefix($($collection[i]).attr(s.srcAttr)); + tempIMG.onload = function(){ + $collection[i + 1] && callee(i + 1); + }; + })(0); + } + + $collection + .mousemove(function(e){ + + $container.css({ + top: e.pageY + s.distanceFromCursor.top + 'px', + left: e.pageX + s.distanceFromCursor.left + 'px' + }); + + }) + .hover(function(){ + + var link = this; + $container + .addClass(s.containerLoadingClass) + .show(); + $img + .load(function(){ + $container.removeClass(s.containerLoadingClass); + $img.show(); + s.onLoad.call($img[0], link); + }) + .attr( 'src' , addPrefix($(link).attr(s.srcAttr)) ); + s.onShow.call($container[0], link); + + }, function(){ + + $container.hide(); + $img.unbind('load').attr('src','').hide(); + s.onHide.call($container[0], this); + + }); + + // Return full selection, not $collection! + return this; + + }; + +})(jQuery); \ No newline at end of file diff --git a/js/manage_tables.js b/js/manage_tables.js index ddc1e1504..e4fc35b91 100644 --- a/js/manage_tables.js +++ b/js/manage_tables.js @@ -282,7 +282,7 @@ function get_table_row(id) { return $element; } -function update_row(row_id,url) +function update_row(row_id,url,callback) { $.post(url, { 'row_id': row_id },function(response) { @@ -291,6 +291,7 @@ function update_row(row_id,url) row_to_update.replaceWith(response); reinit_row(row_id); hightlight_row(row_id); + callback && typeof(callback) == "function" && callback(); }); }