$couponfilename = $_FILES['txtCouponImage']['name'];
 $coupontempname = $_FILES['txtCouponImage']['tmp_name'];
 //','txtCouponImage','txtCouponAmount','ddlArtist'
 $update_gift_coupon = "UPDATE " . $tableprefix . "products\n                                           SET product_name = " . GetSQLValueString($_POST['txtGiftCouponName'], "text") . ",\n                                               product_code = " . GetSQLValueString($_POST['txtGiftCouponCode'], "text") . ",\n                                               product_description = " . GetSQLValueString($_POST['txtCouponDescription'], "text") . ",\n                                               product_price = " . GetSQLValueString($_POST['txtCouponAmount'], "text");
 $update_gift_coupon .= " WHERE product_id = '" . $_GET['edit_product_id'] . "'";
 mysql_query($update_gift_coupon) or die(mysql_error());
 $update_product_options = "UPDATE " . $tableprefix . "product_options\n                                                SET product_stock = " . GetSQLValueString($_POST['txtCouponStock'], "text") . ",\n                                                    reorder_level = " . GetSQLValueString($_POST['txtStockReorder'], "text");
 $update_gift_coupon_master = "UPDATE " . $tableprefix . "giftcoupon_master\n\t\t\t\t\t\t\t\t\t  SET ngift_coupon_amount = " . GetSQLValueString($_POST['txtCouponAmount'], "text") . " WHERE ngift_product_id = " . $_GET['edit_product_id'];
 mysql_query($update_gift_coupon_master) or die(mysql_error());
 $message = "Gift Coupon Details Updated Successfully !!";
 if ($_FILES['txtCouponImage']['name'][0] != "") {
     if (!isValidWebImageType($couponfiletype, $couponfilename, $coupontempname)) {
         $message_image = " * Invalid Image !! Upload an image (jpg/gif/png)" . "<br>";
         $image_flag = 1;
     } else {
         $imagewidth_height_type_array = explode(":", ImageTypeBanner($_FILES['txtCouponImage']['tmp_name']));
         $imagetype = $imagewidth_height_type_array[0];
         $assignedname_small = "gift_coupon_small" . time() . "." . $imagetype;
         $assignedname_large = "gift_coupon_large" . time() . "." . $imagetype;
         if (move_uploaded_file($_FILES['txtCouponImage']['tmp_name'], "../products/" . $assignedname_large)) {
             chmod("../products/{$assignedname_large}", 0777);
             /*taken from the general site settings table*/
             $gift_image_size = '400,400';
             $gift_size = split(',', $gift_image_size);
             resizeImg("../products/" . $assignedname_large, 283, 269, false, 100, 0, "_thumb");
             @copy("../products/{$assignedname_large}", "../products/{$assignedname_small}");
             resizeImg("../products/" . $assignedname_small, 191, 183, false, 100, 0, "_thumb");
             $update_product_options .= ",image_small = '" . $assignedname_small . "',\n\t\t\t\t\t\t\t\t    image_big = '" . $assignedname_large . "'";
             unlink('../products/' . $_POST['txtCouponBuffer']);
         }
     }
    $total_image_count = mysql_num_rows($result_bulk_images);
}
if (isset($_POST['add'])) {
    for ($i = 1; $i <= $settings_product_image_count[0]; $i++) {
        $product_image = "txtImage_" . $i;
        $productfiletype = $_FILES[$product_image]['type'];
        $productfilename = $_FILES[$product_image]['name'];
        $producttempname = $_FILES[$product_image]['tmp_name'];
        $product_description = "txtDescription_" . $i;
        $dir_dest = "../products/bulk_images/";
        if ($_FILES[$product_image]['name'][0] != "") {
            if (!isValidWebImageType($productfiletype, $productfilename, $producttempname)) {
                $message .= " * Image{$i} is no a valid image !! Upload an image (jpg/gif/png)" . "<br>";
                $invalid_image_flag = 1;
            } else {
                $imagewidth_height_type_array = explode(":", ImageTypeBanner($_FILES[$product_image]['tmp_name']));
                $imagetype = $imagewidth_height_type_array[0];
                list($org_name, $ext) = explode(".", $_FILES[$product_image]['name']);
                $name_replaced = "product_image_" . time() . $i . str_replace(' ', '', $org_name);
                $name_thumb = "thumb_product_image_" . time() . $i . str_replace(' ', '', $org_name);
                $assignedname = "product_image_" . time() . $i . str_replace(' ', '', $_FILES[$product_image]['name']);
                $thumbimage = "thumb_product_image_" . time() . $i . str_replace(' ', '', $_FILES[$product_image]['name']);
                $handle = new Upload($_FILES[$product_image]);
                if ($handle->uploaded) {
                    $handle->image_resize = true;
                    $handle->image_x = 192;
                    $handle->image_y = 183;
                    $handle->file_new_name_body = $name_thumb;
                    $handle->Process($dir_dest);
                    $handle->image_resize = true;
                    $handle->image_x = 283;