Images are not removed from items when no file is chosen

Image thumbnails are resized proportionally and updated after update_row
refresh
Add some padding to the thumbnails
Move select specific styles to ospos.css stylesheet
This commit is contained in:
jekkos-t520
2015-02-04 15:29:34 +01:00
parent 7efb1428f5
commit 8ccba57d98
8 changed files with 176 additions and 24 deletions

View File

@@ -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');

View File

@@ -228,7 +228,7 @@ function get_item_data_row($item,$controller)
$images = glob ("uploads/item_pics/" . $item->pic_id . ".*");
if (sizeof($images) > 0)
{
$image.='<a class="rollover" href="'. $images[0] .'"><img src="'.base_url($images[0]).'"></a>';
$image.='<a class="rollover" href="'. base_url($images[0]) .'"><img src="'.base_url($images[0]).'"></a>';
}
}
$table_data_row.='<td align="center" width="55px">' . $image . '</td>';

View File

@@ -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,'<?php echo site_url("$controller_name/get_row")?>');
update_row(response.item_id,'<?php echo site_url("$controller_name/get_row")?>',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<selected_item_ids.length;k++)
{
update_row(selected_item_ids[k],'<?php echo site_url("$controller_name/get_row")?>');
update_row(selected_item_ids[k],'<?php echo site_url("$controller_name/get_row")?>',resize_thumbs);
}
set_feedback(response.message,'success_message',false);
}

View File

@@ -18,6 +18,7 @@
<script src="<?php echo base_url();?>js/jquery.autocomplete.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.validate.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.jkey-1.1.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/imgpreview.full.jquery.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/thickbox.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/common.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/manage_tables.js" type="text/javascript" language="javascript" charset="UTF-8"></script>

View File

@@ -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: ".";

View File

@@ -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;
}

View File

@@ -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 = $('<div/>').attr('id', s.containerID)
.append('<img/>').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);

View File

@@ -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();
});
}