}
         }
         if (!file_exists(DIR_WS_IMAGES . $brand_folder)) {
             mkdir(DIR_WS_IMAGES . $brand_folder, 0755);
         }
         $image_uploaded = move_uploaded_file($_FILES['brand_image']['tmp_name'], $brand_image_path);
         if ($image_uploaded) {
             chmod($brand_image_path, 0640);
         }
     }
     $sda = array('brand_name' => $brand_name, 'brand_description' => $brand_description, 'active_status' => $active_status, 'need_repackaging' => $need_repackaging, 'seo_text' => $seo_text);
     if ($image_uploaded) {
         $sda['brand_image'] = $brand_image_file;
     }
     if ($brand_id == '') {
         $brand_id = $class_pb->insert($sda);
         $action = 'insert';
     } else {
         $class_pb->update($brand_id, $sda);
         $action = 'update';
         $brand = $class_pb->retrieveDetail($brand_id);
     }
     if (isset($_POST['sp_brand_id']) && is_array($_POST['sp_brand_id'])) {
         foreach ($_POST['sp_brand_id'] as $jng_sp_id => $sp_brand_id) {
             $class_pb->updateSPbrandID($jng_sp_id, $brand_id, $sp_brand_id);
         }
     }
     header("Location: ?open=products-brand&id={$brand_id}&action={$action}");
     exit;
 } elseif ($_POST['me_action'] == 'DELETEBRAND') {
     if ($id > 0) {