<?php $data = array(); $data['title'] = "Sửa thông tin khách hàng"; $data['template'] = "customer/edit_customer"; $db = new libraries_customer(); $id = $_GET['cid']; $data['info'] = $db->getdata($id); $data['items'] = $db->list_cate(); $data['errors'] = ""; if (isset($_POST['ok'])) { $name = $_POST['customer_name']; $user = $_POST['customer_user']; $cate_id = $_POST['cate_id']; $address = $_POST['customer_address']; $url = $_POST['customer_url']; $info = $_POST['customer_info']; $status = $_POST['status']; $dir = "../uploads/customer/thumb/"; $update = array("customer_name" => $name, "customer_user" => $user, "cate_id" => $cate_id, "customer_address" => $address, "customer_url" => $url, "customer_info" => $info, "customer_status" => $status); $types = array("image/gif", "image/GIF", "image/JPG", "image/jpg", "image/JPEG", "image/jpeg", "image/png", "image/PNG", "application/x-zip-compressed", "application/msword", "application/vnd.ms-excel"); $tmp_img = $_FILES["img"]["tmp_name"]; $new_img = $_FILES["img"]["name"]; if ($new_img != NULL) { if (in_array($_FILES["img"]["type"], $types)) { move_uploaded_file($tmp_img, $dir . $new_img); $update['customer_image'] = $_FILES["img"]["name"]; } else { $data['errors'] = "Ảnh không đúng định dạng!"; loadview("layout", $data); //echo "<script>alert('Định dạng file không hợp lệ !')/script>";
<?php $data = array(); $data['title'] = "Thêm mới khách hàng"; $data['template'] = "customer/add_customer"; $db = new libraries_customer(); $data['items'] = $db->list_cate(); if (isset($_POST['ok'])) { $name = $_POST['customer_name']; $user = $_POST['customer_user']; $cate_id = $_POST['cate_id']; $address = $_POST['customer_address']; $url = $_POST['customer_url']; $info = $_POST['customer_info']; $dir = "../uploads/customer/thumb/"; $types = array("image/gif", "image/GIF", "image/JPG", "image/jpg", "image/JPEG", "image/jpeg", "image/png", "image/PNG", "application/x-zip-compressed", "application/msword", "application/vnd.ms-excel"); $tmp_img = $_FILES["img"]["tmp_name"]; $tmp_avatar = $_FILES["avatar"]["tmp_name"]; $tmp_website = $_FILES["website"]["tmp_name"]; $new_img = $_FILES["img"]["name"]; $new_avatar = $_FILES["avatar"]["name"]; $new_website = $_FILES["website"]["name"]; if (in_array($_FILES["img"]["type"], $types)) { move_uploaded_file($tmp_img, $dir . $new_img); $img = $_FILES["img"]["name"]; } else { echo "<script>alert('Định dạng file không hợp lệ !');</script>"; } if (in_array($_FILES["avatar"]["type"], $types)) { move_uploaded_file($tmp_avatar, $dir . $new_avatar); $avatar = $_FILES["avatar"]["name"];
<?php $id = $_GET['cid']; $db = new libraries_customer(); $db->del_customer("tbl_customer", $id); header("location:index.php?mod=customer&act=list");
<?php $data = array(); $data['title'] = "Danh sách khách hàng"; $data['template'] = "customer/list_customer"; $db = new libraries_customer(); $pager = new libraries_pager(); $limit = 10; $pager->set_link("index.php?mod=customer&act=list"); $total = $db->total_customer(); $start = $pager->start(); $pages = $pager->page($total, $limit); $data['listpage'] = $pager->listpage($pages, $start, $limit); $data['list'] = $db->list_customer($start, $limit); loadview("layout", $data);