From 7aec26586cfb1fc93a134bc6c621ef0da2b2cc4c Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Sun, 22 Mar 2009 16:33:06 +0000 Subject: [PATCH] Option to remove image. --- CHANGELOG.txt | 2 +- inventory/manage/items.php | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 625b5275..42e8664a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -20,7 +20,7 @@ Legend: $ -> Affected files 22-Mar-2009 Janusz Dobrowolski/Joe Hun rerun, didn't work (empty file when inserting) -# Fixed item picture display after upload, fixed item image filenames. +# Fixed item picture display after upload, fixed item image filenames. Option to remove image. $ /inventory/manage/items.php /inventory/includes/inventory_db.inc /reporting/rep104.php diff --git a/inventory/manage/items.php b/inventory/manage/items.php index ca65111d..8a465010 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -142,7 +142,13 @@ if (isset($_POST['addupdate'])) if ($input_error != 1) { - + if (check_value('del_image')) + { + $filename = $comp_path . "/$user_comp/images/".item_img_name($_POST['NewStockID']).".jpg"; + if (file_exists($filename)) + unlink($filename); + } + if (!$new_item) { /*so its an existing one */ @@ -164,8 +170,8 @@ if (isset($_POST['addupdate'])) $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id']); - display_notification(_("A new item has been added.")); - $_POST['stock_id'] = $_POST['NewStockID']; + display_notification(_("A new item has been added.")); + $_POST['stock_id'] = $_POST['NewStockID']; } set_focus('stock_id'); $Ajax->activate('_page_body'); @@ -326,7 +332,7 @@ else $_POST['assembly_account'] = $myrow['assembly_account']; $_POST['dimension_id'] = $myrow['dimension_id']; $_POST['dimension2_id'] = $myrow['dimension2_id']; - + $_POST['del_image'] = 0; label_row(_("Item Code:"),$_POST['NewStockID']); hidden('NewStockID', $_POST['NewStockID']); set_focus('description'); @@ -391,6 +397,7 @@ table_section_title(_("Picture")); label_row(_("Image File (.jpg)") . ":", ""); // Add Image upload for New Item - by Joe $stock_img_link = ""; +$check_remove_image = false; if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/" .item_img_name($_POST['NewStockID']).".jpg")) { @@ -398,6 +405,7 @@ if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/" $stock_img_link .= "[".$_POST["; + $check_remove_image = true; } else { @@ -405,7 +413,9 @@ else } label_row(" ", $stock_img_link); - +if ($check_remove_image) + check_row(_("Delete Image:"), 'del_image', $_POST['del_image']); + end_outer_table(1); div_end(); div_start('controls'); -- 2.30.2