public function del()
 {
     //1、根据点击删除传递过来的ID获取相关数据
     $ids = I('ids');
     $map['id'] = array("in", $ids);
     $result = get_result($this->table, $map);
     //2、获取评论内容中的图片并删除
     foreach ($result as $key => $value) {
         //删除内容中的图片
         delStrImgs($value['content']);
         //3、统计评论删除后新闻的评论数量
         $_POST['id'] = $value['product_id'];
         $_POST['comment'] = count_data($this->table, array("product_id" => $value['product_id']));
         update_data("article");
     }
     //4、删除数据表中的数据
     delete_data($this->table, $map);
     $this->success("删除成功");
 }
Esempio n. 2
0
    } else {
        $table = TB_PREF . "stores";
        $field = "store_name, description, address, contact, person_id ";
        $value = "'" . $_POST['store_name'] . "', '" . $_POST['description'] . "' ," . "'" . $_POST['address'] . "', '" . $_POST['contact'] . "', '" . $_POST['person_id'] . "' ";
        $query = insert_record($table, $field, $value);
        if ($query) {
            display_success("Data " . $_POST['store_name'] . " berhasil disimpan | <a href='?" . $parameter_key . "kd_tabel=tb_stores' />Close</a>");
        } else {
            display_error("Gagal menyimpan data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_stores' />Close</a>");
        }
    }
}
//-------------------------------UPDATE ACTION-----------------------------------------
if (isset($_POST['submit_update'])) {
    //CEK EXISTING DATA IN TABLE
    $cek_exist = count_data(TB_PREF . "stores", 'store_name', "store_name='" . $_POST['store_name'] . "'");
    if ($cek_exist[0] > 1) {
        display_error("Data pembaruhan sudah ada " . "| <a href='?" . $parameter_key . "kd_tabel=tb_stores' />Close</a>");
    } else {
        $table = TB_PREF . "stores";
        $value = "store_name='" . $_POST['store_name'] . "' " . ", description='" . $_POST['description'] . "' " . ", address='" . $_POST['address'] . "' " . ", contact='" . $_POST['contact'] . "' " . ", person_id='" . $_POST['person_id'] . "' ";
        $where = " WHERE id='" . $_POST['id'] . "'";
        $query = update_record($table, $value, $where);
        if ($query) {
            display_success("Data berhasil diperbaruhi " . "| <a href='?" . $parameter_key . "kd_tabel=tb_stores' />Close</a>");
        } else {
            display_error("Gagal memperbaruhi data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_stores' />Close</a>");
        }
    }
}
//-------------------------------ISSET UPDATE/DELETE-----------------------------------------
    session_start();
    if (!isset($_SESSION['id'])) {
        header("location:login.php");
    }
}
//include
include "include_masters/db_masters.inc";
//catch parameter
$id_item = '';
if (isset($_GET['item'])) {
    $id_item = $_GET['item'];
}
//-------------------------------INSERT ACTION-----------------------------------------
if (isset($_POST['submit'])) {
    //CEK EXISTING DATA IN TABLE
    $cek_exist = count_data(TB_PREF . "maping_category_items", 'id_item', "id_item='" . $_POST['id_item'] . "' AND id_category='" . $_POST['id_category'] . "' ");
    if ($cek_exist[0] > 0) {
        display_error("Data yang dimasukkan sudah ada |" . " <a href='?" . $parameter_key . "kd_tabel=tb_maping_item_category&item=" . $_POST['id_item'] . "' />Close</a>");
    } else {
        $table = TB_PREF . "maping_category_items";
        $field = "id_item, id_category, description";
        $value = "'" . $_POST['id_item'] . "' , '" . $_POST['id_category'] . "', '" . $_POST['description'] . "' ";
        $query = insert_record($table, $field, $value);
        if ($query) {
            display_success("Data berhasil disimpan | " . "<a href='?" . $parameter_key . "kd_tabel=tb_maping_item_category&item=" . $_POST['id_item'] . "' />Close</a>");
        } else {
            display_error("Gagal menyimpan data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_maping_item_category&item=" . $_POST['id_item'] . "' />Close</a>");
        }
    }
}
//-------------------------------ISSET DELETE-----------------------------------------
Esempio n. 4
0
        } else {
            display_error("Gagal memperbaruhi data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_categories' />Close</a>");
        }
    }
}
//-------------------------------ISSET UPDATE/DELETE-----------------------------------------
if (isset($_GET['update'])) {
    $id = $_GET['update'];
    $val_selected = display_table_all_column(TB_PREF . 'categories', "id='{$id}'", true, false, '', '');
    $_POST['AddNew'] = 'update';
}
//DELETE ACTION
if (isset($_GET['delete'])) {
    $id = $_GET['delete'];
    //CEK DATA IN other table BEFORE DELETE
    $cek_exist = count_data(TB_PREF . "categories", 'id', "parent_category='" . $id . "'");
    if ($cek_exist[0] > 0) {
        display_error("Data ini masih digunakan... " . "| <a href='?" . $parameter_key . "kd_tabel=tb_categories' />Close</a>");
    } else {
        $table = TB_PREF . "categories";
        $field_key = "id";
        $field_val = "'" . $id . "'";
        $query = delete_record($table, $field_key, $field_val);
        if ($query) {
            display_success("Data berhasil dihapus " . "| <a href='?" . $parameter_key . "kd_tabel=tb_categories' />Close</a>");
        } else {
            display_error("Gagal menghapus data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_categories' />Close</a>");
        }
    }
}
//-------------------------------FORM-----------------------------------------
    session_start();
    if (!isset($_SESSION['id'])) {
        header("location:login.php");
    }
}
//include
include "include_masters/db_masters.inc";
//catch parameter
$id_item = '';
if (isset($_GET['item'])) {
    $id_item = $_GET['item'];
}
//-------------------------------INSERT ACTION-----------------------------------------
if (isset($_POST['submit'])) {
    //CEK EXISTING DATA IN TABLE
    $cek_exist = count_data(TB_PREF . "maping_size_items", 'id_item', "id_item='" . $_POST['id_item'] . "' AND size='" . $_POST['size'] . "' ");
    if ($cek_exist[0] > 0) {
        display_error("Data yang dimasukkan sudah ada |" . " <a href='?" . $parameter_key . "kd_tabel=tb_maping_item_size&item=" . $_POST['id_item'] . "' />Close</a>");
    } else {
        $table = TB_PREF . "maping_sizess_items";
        $field = "id_item, size, unit_price, discount, weight, description";
        $value = "'" . $_POST['id_item'] . "' , '" . $_POST['size'] . "', " . "'" . $_POST['unit_price'] . "', '" . $_POST['discount'] . "'," . "'" . $_POST['weight'] . "', '" . $_POST['description'] . "' ";
        $query = insert_record($table, $field, $value);
        if ($query) {
            display_success("Data berhasil disimpan | " . "<a href='?" . $parameter_key . "kd_tabel=tb_maping_item_size&item=" . $_POST['id_item'] . "' />Close</a>");
        } else {
            display_error("Gagal menyimpan data <br>" . "(" . db_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_maping_item_size&item=" . $_POST['id_item'] . "' />Close</a>");
        }
    }
}
//-------------------------------ISSET DELETE-----------------------------------------
Esempio n. 6
0
        } else {
            display_error("Gagal memperbaruhi data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_brands' />Close</a>");
        }
    }
}
//-------------------------------ISSET UPDATE/DELETE-----------------------------------------
if (isset($_GET['update'])) {
    $id = $_GET['update'];
    $val_selected = display_table_all_column(TB_PREF . 'brands', "id='{$id}'", true, false, '', '');
    $_POST['AddNew'] = 'update';
}
//DELETE ACTION
if (isset($_GET['delete'])) {
    $id = $_GET['delete'];
    //CEK DATA IN other table BEFORE DELETE
    $cek_exist = count_data(TB_PREF . "items", 'id', "id_brand='" . $id . "'");
    if ($cek_exist[0] > 0) {
        display_error("Data ini masih digunakan... " . "| <a href='?" . $parameter_key . "kd_tabel=tb_brands' />Close</a>");
    } else {
        $table = TB_PREF . "brands";
        $field_key = "id";
        $field_val = "'" . $id . "'";
        $query = delete_record($table, $field_key, $field_val);
        if ($query) {
            display_success("Data berhasil dihapus " . "| <a href='?" . $parameter_key . "kd_tabel=tb_brands' />Close</a>");
        } else {
            display_error("Gagal menghapus data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_brands' />Close</a>");
        }
    }
}
//-------------------------------FORM-----------------------------------------
Esempio n. 7
0
 public function del()
 {
     //1、根据点击删除传递过来的ID获取相关数据
     $ids = I('ids');
     $map['id'] = array("in", $ids);
     $result = get_result($this->table, $map);
     //2、获取内容中的图片并删除
     foreach ($result as $key => $value) {
         //删除封面
         if (file_exists($value['cover'])) {
             @unlink($value['cover']);
         }
         //删除内容中的图片
         delStrImgs($value['content']);
         //3、重新统计删除后分类下的新闻数量
         //通过path获取到父级分类id
         $info_path = explode('-', $value['path']);
         foreach ($info_path as $key => $val) {
             $_POST = null;
             if ($val != 0) {
                 $_POST['id'] = $val;
                 $_POST['num'] = count_data($this->table, array("path" => array("like", '%-' . $val . '-%')));
                 update_data("category");
             }
         }
     }
     F('news_category_result', null);
     //4、删除数据表中的数据
     delete_data($this->table, $map);
     $this->success("删除成功");
 }
 function doDel($id)
 {
     $info = get_info($this->table, array("id" => $id));
     if ($info) {
         if ($info['is_fixed'] == 1) {
             $this->error("分类【" . $info['title'] . "】为内置分类,禁止删除");
         }
         if ($info['num'] >= 1) {
             $this->error("分类【" . $info['title'] . "】下还有内容");
         }
         $count = count_data($this->table, array("pid" => $id));
         if ($count >= 1) {
             $this->error("删除失败<br />该分类下还有下级分类,请先删除下级分类后再删除");
         } else {
             delete_data($this->table, array("id" => $info['id']));
         }
     }
 }
Esempio n. 9
0
    } else {
        $table = TB_PREF . "items";
        $field = "item_code, item_name, id_brand, unit_price, discount, weight, description";
        $value = "'" . $_POST['item_code'] . "' , '" . $_POST['item_name'] . "', " . "'" . $_POST['id_brand'] . "', '" . $_POST['unit_price'] . "', '" . $_POST['discount'] . "', " . "'" . $_POST['weight'] . "', '" . $_POST['description'] . "' ";
        $query = insert_record($table, $field, $value);
        if ($query) {
            display_success("Data " . $_POST['item_name'] . " berhasil disimpan | <a href='?" . $parameter_key . "kd_tabel=tb_items' />Close</a>");
        } else {
            display_error("Gagal menyimpan data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_items' />Close</a>");
        }
    }
}
//-------------------------------UPDATE ACTION-----------------------------------------
if (isset($_POST['submit_update'])) {
    //CEK EXISTING DATA IN TABLE
    $cek_exist = count_data(TB_PREF . "items", 'item_name', "item_name='" . $_POST['item_name'] . "'");
    if ($cek_exist[0] > 1) {
        display_error("Data pembaruhan sudah ada " . "| <a href='?" . $parameter_key . "kd_tabel=tb_items' />Close</a>");
    } else {
        $table = TB_PREF . "items";
        $value = "item_code='" . $_POST['item_code'] . "', " . " item_name='" . $_POST['item_name'] . "', " . " id_brand='" . $_POST['id_brand'] . "', " . " unit_price='" . $_POST['unit_price'] . "', " . " discount='" . $_POST['discount'] . "', " . " weight='" . $_POST['weight'] . "', " . " description='" . $_POST['description'] . "' ";
        $where = " WHERE id='" . $_POST['id'] . "'";
        $query = update_record($table, $value, $where);
        if ($query) {
            display_success("Data berhasil diperbaruhi " . "| <a href='?" . $parameter_key . "kd_tabel=tb_items' />Close</a>");
        } else {
            display_error("Gagal memperbaruhi data <br>" . "(" . mysql_error() . ") | <a href='?" . $parameter_key . "kd_tabel=tb_items' />Close</a>");
        }
    }
}
//-------------------------------ISSET UPDATE/DELETE-----------------------------------------