public function actionAddAjax() { if (!isset(Yii::app()->user->storeID)) { $data['message'] = '<div class="alert alert-success">Store not found. </div>'; echo json_encode($data); exit; } $model = new Customer(); if (isset($_POST['Customer'])) { $model->attributes = $_POST['Customer']; $data = array(); $mss = ''; if (count($data) == 0) { $model->pk_s_id = '-1'; $model->i_flag_sync = 1; $model->i_flag_deleted = 0; $model->i_disable = 0; if ($model->save()) { $model->pk_s_id = 'SV' . $model->id; if ($model->save()) { $data['option'] = '<option selected="selected" value ="' . $model->pk_s_id . '">' . $model->s_name . '</option>'; $data['message'] = '<div class="alert alert-success">Success! Customer created. </div>'; } else { $model->delete(); $data['message'] = '<div class="alert alert-danger">Error! Please try again later.</div>'; } } else { $data['message'] = json_encode($model->errors); //'<div class="alert alert-danger">Error! Please try again later2.</div>'; } } echo json_encode($data); } }
public function delete() { if ($this->f3->exists('PARAMS.id')) { $user = new Customer($this->db); $user->delete($this->f3->get('PARAMS.id')); } $this->f3->reroute('/customer'); }
public function testCustomerDelete() { $token = 'cus_zDdjHBuNW3do8G3jaTqApzsI'; $this->mockResponse($this->success_customer_delete_response()); $customer = Customer::delete($token); $this->assertNotNull($customer->token); $this->assertNotNull($customer->email); $this->assertFalse($customer->is_active); }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); // abre uma transação $customer = new Customer(40); $customer->delete(); // exclui o objeto $customer = new Customer(); $customer->delete(41); // exclui o objeto new TMessage('info', 'Objeto excluído'); TTransaction::close(); // fecha a transação. } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
public function __construct() { parent::__construct(); try { TTransaction::open('samples'); // open transaction $customer = new Customer(40); // load object $customer->delete(); // delete object $customer = new Customer(); $customer->delete(41); // delete object new TMessage('info', 'Object deleted'); TTransaction::close(); // close transaction } catch (Exception $e) { new TMessage('error', $e->getMessage()); } }
/** * method Delete() * Delete a record */ function Delete($param) { try { // get the parameter $key $key = $param['key']; // open a transaction with database 'samples' TTransaction::open('samples'); // instantiates object Customer $object = new Customer($key); // deletes the object from the database $object->delete(); // close the transaction TTransaction::close(); // reload the listing $this->onReload($param); // shows the success message new TMessage('info', "Record Deleted"); } catch (Exception $e) { // shows the exception error message new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } }
public function uninstall() { $id = Configuration::get('YA_POKUPKI_CUSTOMER'); $customer = new Customer($id); $customer->id = $id; $customer->delete(); Db::getInstance()->execute('DROP TABLE IF EXISTS ' . _DB_PREFIX_ . 'pokupki_orders'); foreach ($this->status as $s) { $os = new OrderState((int) $s); $os->id = $s; $os->delete(); } return parent::uninstall(); }
/** * 添加顾客 */ public function actionAddCust() { $user_model = new User(); $addr_model = new Address(); $cust_model = new Customer(); $custhi_model = new Cust_Health_Info(); if (isset($_POST["User"]) && isset($_POST["Customer"])) { $user_model->attributes = $_POST["User"]; //设定用户种别为:顾客 $user_model->usr_kind = 2; //设定用户密码为:xyz123456 $user_model->usr_password = md5("xyz123456"); $user_model->user_chg_pwd_old = "oldpassword"; $user_model->user_chg_pwd_new = "newpassword"; $user_model->user_chg_pwd_new_cfm = "newpassword"; //设置用户头像的默认值 if ($user_model->usr_pic_id == '') { $user_model->usr_pic_id = '100000'; } if ($user_model->save()) { $cust_model->attributes = $_POST["Customer"]; //customer表里面的主键是user表的外键,user表的外键又是自增的,所以要先保存完user表才能保存customer表 $cust_model->pk_cust_id = $user_model->pk_usr_id; //将作为用户名的手机号填入顾客信息里 $cust_model->cust_mobile1 = $_POST['User']['usr_username']; //将用户喜爱的项目按位计算并保存 $cust_prefer = 0; //如果啥都没选的话,下记字符串应该为空,否则为数组(内容为数字) if ($_POST['Customer']['cust_prefer'] != '') { for ($i = 0; $i < count($_POST['Customer']['cust_prefer']); $i++) { if ($_POST['Customer']['cust_prefer'][$i]) { $cust_prefer |= (int) $_POST['Customer']['cust_prefer'][$i]; } } } else { $cust_prefer = 0; } $cust_model->cust_prefer = $cust_prefer; //将用户喜爱的美疗师按位计算并保存 $cust_beautician = 0; //如果啥都没选的话,下记字符串应该为空,否则为字符串数组(内容为数字) if ($_POST['Customer']['cust_beautician'] != '') { for ($i = 0; $i < count($_POST['Customer']['cust_beautician']); $i++) { if ($_POST['Customer']['cust_beautician'][$i]) { $cust_beautician |= (int) $_POST['Customer']['cust_beautician'][$i]; } } } else { $cust_beautician = 0; } $cust_model->cust_beautician = $cust_beautician; if ($cust_model->save()) { $addr_model->attributes = $_POST['Address']; $addr_model->addr_cust_id = $user_model->pk_usr_id; if (!$addr_model->save()) { $cust_model->delete(); $user_model->delete(); echo "<script>alert('地址信息添加失败!');</script>"; } $custhi_model->attributes = $_POST['Cust_Health_Info']; $custhi_model->pk_custhi_cust_id = $user_model->pk_usr_id; $custhi_model->custhi_height = (double) $_POST['Cust_Health_Info']['custhi_height']; $custhi_model->custhi_weight = (double) $_POST['Cust_Health_Info']['custhi_weight']; $custhi_model->custhi_date = date("Y-m-d H:i:s", time()); if (!$custhi_model->save()) { $addr_model->delete(); $cust_model->delete(); $user_model->delete(); echo "<script>alert('用户健康信息添加失败!');</script>"; } $this->redirect("./index.php?r=user/showCust"); } else { $user_model->delete(); var_dump($cust_model->getErrors()); echo "<script>alert('顾客信息添加失败!');</script>"; } } else { // var_dump($user_model->getErrors()); echo "<script>alert('用户信息添加失败!');</script>"; } } $this->renderPartial('addCust', array('user_info' => $user_model, 'cust_info' => $cust_model, 'addr_info' => $addr_model, 'custhi_info' => $custhi_model)); }
/** * Delete a customer * @route DELETE customer/$id/$token (rewritten by codeigniter route) * @param type $id * @param type $token */ public function customer_delete($id, $token) { $token_entry = new Token(); $token_entry->get_by_valid_token($token)->get(); $response = new stdClass(); if ($token_entry->exists() && $token_entry->user->get()->is_admin) { $customer = new Customer(); $customer->get_by_id($id); $customer->delete(); $response->status = TRUE; $this->response($response); } else { $response->status = FALSE; $response->error = 'Token not found, not an admin or session expired'; $this->response($response); } }
function delete($id) { $this->checkRole(array(1)); $customers = new Customer($id); if (!$customers->exists()) { show_404(); } if ($customers->delete()) { flash_message('success', 'Thành công. Đối tượng đã được xóa'); redirect($_SERVER['HTTP_REFERER']); } }
<?php require_once "util.php"; require_once "DataBase/Customer.php"; require_once "DataBase/Tour.php"; require_once "DataBase/Priceset.php"; $db_action = var_get_post("db_action", ""); $customer = new Customer(); $tour = new Tour(); $priceset = new Priceset(); switch ($db_action) { case "new": $customer->create(var_post("customer_number", ""), array(var_post("password", ""), var_post("prename", ""), var_post("postname", ""), var_post("street", ""), var_post("streetnumber", ""), var_post("plz", ""), var_post("city", ""), var_post("telephone", ""), var_post("telefax", ""), var_post("email", ""), var_post("pricelist_id", ""), var_post("tour_id", ""), var_post("rabatt", ""), var_post("details", ""), var_post("bank_name", ""), var_post("bank_account", ""), var_post("blz", ""))); break; case "edit": $customer->update(var_post("customer_number", ""), array(var_post("password", ""), var_post("prename", ""), var_post("postname", ""), var_post("street", ""), var_post("streetnumber", ""), var_post("plz", ""), var_post("city", ""), var_post("telephone", ""), var_post("telefax", ""), var_post("email", ""), var_post("pricelist_id", ""), var_post("tour_id", ""), var_post("rabatt", ""), var_post("details", ""), var_post("bank_name", ""), var_post("bank_account", ""), var_post("blz", ""))); break; case "delete": $customer->delete(var_get("customer_id", "")); break; }
$error->check(); break; case 'create_customer': $customer = new Customer(); $customer_id = CUSTOMER_PREFIX . $customer_name; $result = $customer->create($conn_asm, $conn_db, $customer_id, $customer_password); $error->check(); break; case 'exist_customer': $customer = new Customer(); $result = $customer->check($conn_asm, $conn_db, $customer_id); $error->check(); break; case 'delete_customer': $customer = new Customer(); $result = $customer->delete($conn_asm, $conn_db, $customer_id); $error->check(); break; case 'update_consumer_group': $customer = new Customer(); $result = $customer->update_consumer_group($conn_db, $customer_id, $consumer_group); $error->check(); break; case 'update_storage_quota': $drive = new Drive(); $result = $drive->update_storage_quota($conn_db, $customer_id, $max_gbytes); $error->check(); break; case 'update_compression': $drive = new Drive(); $result = $drive->update_compression($conn_db, $customer_id, $compression);
function deleteCustomer($id) { if (is_null($id)) { Functions::setResponse(400); } try { $c = new Customer($id); $c->delete(); return true; } catch (RuntimeException $e) { Functions::setResponse(404); } }
die("<b style='color:red'>Error CANNOT4:" . SmartTest::instance()->canwe); exit; } SmartTest::instance()->progress(); $cust3 = new Customer(); $cust4 = new Customer(); $cust3->add($cust4); $cust3->add($cust4); //also test multiple assoc $c = $cust3->getRelatedCustomer(); if (count($c) !== 1) { die("<b style='color:red'>Error CANNOT5:" . SmartTest::instance()->canwe); exit; } SmartTest::instance()->progress(); Customer::delete($cust4); $c = $cust3->getRelatedCustomer(); if (count($c) !== 0) { die("<b style='color:red'>Error CANNOT6:" . SmartTest::instance()->canwe); exit; } SmartTest::instance()->progress(); SmartTest::instance()->canwe = "import from post"; $_POST["hallo"] = 123; $_POST["there"] = 456; $_POST["nope"] = 789; $cust = new Customer(); $cust->importFromPost(array("hallo", "there")); if ($cust->getHallo() == 123 && $cust->getThere() == 456 && !$cust->getNope()) { SmartTest::instance()->progress(); } else {
private function truncateTables($case) { switch ((int) $case) { case $this->entities[$this->l('Categories')]: $categories = Db::getInstance()->ExecuteS('SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category` WHERE id_category != 1'); foreach ($categories as $category) { $c = new Category((int) $category['id_category']); $c->delete(); } break; case $this->entities[$this->l('Products')]: $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`'); foreach ($products as $product) { $p = new Product((int) $product['id_product']); $p->delete(true); } break; case $this->entities[$this->l('Customers')]: $customers = Db::getInstance()->ExecuteS('SELECT `id_customer` FROM `' . _DB_PREFIX_ . 'customer`'); foreach ($customers as $customer) { $c = new Customer((int) $customer['id_customer']); $c->delete(); } break; case $this->entities[$this->l('Addresses')]: $addresses = Db::getInstance()->ExecuteS('SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address`'); foreach ($addresses as $address) { $a = new Address((int) $address['id_address']); $a->delete(); } break; case $this->entities[$this->l('Combinations')]: $products = Db::getInstance()->ExecuteS('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product`'); foreach ($products as $product) { $p = new Product((int) $product['id_product']); $p->deleteProductAttributes(); } break; case $this->entities[$this->l('Manufacturers')]: $manufacturers = Db::getInstance()->ExecuteS('SELECT `id_manufacturer` FROM `' . _DB_PREFIX_ . 'manufacturer`'); foreach ($manufacturers as $manufacturer) { $m = new Manufacturer((int) $manufacturer['id_manufacturer']); $m->delete(); } break; case $this->entities[$this->l('Suppliers')]: $suppliers = Db::getInstance()->ExecuteS('SELECT `id_supplier` FROM `' . _DB_PREFIX_ . 'supplier`'); foreach ($suppliers as $supplier) { $m = new Supplier((int) $supplier['id_supplier']); $m->delete(); } break; } Image::clearTmpDir(); return true; }
function customers_list() { global $Shopp, $Customers, $wpdb; $db = DB::get(); $defaults = array('page' => false, 'deleting' => false, 'selected' => false, 'update' => false, 'newstatus' => false, 'pagenum' => 1, 'per_page' => false, 'start' => '', 'end' => '', 'status' => false, 's' => '', 'range' => '', 'startdate' => '', 'enddate' => ''); $args = array_merge($defaults, $_GET); extract($args, EXTR_SKIP); if ($page == "shopp-customers" && !empty($deleting) && !empty($selected) && is_array($selected)) { foreach ($selected as $deletion) { $Customer = new Customer($deletion); $Billing = new Billing($Customer->id, 'customer'); $Billing->delete(); $Shipping = new Shipping($Customer->id, 'customer'); $Shipping->delete(); $Customer->delete(); } } if (!empty($_POST['save'])) { check_admin_referer('shopp-save-customer'); if ($_POST['id'] != "new") { $Customer = new Customer($_POST['id']); $Billing = new Billing($Customer->id, 'customer'); $Shipping = new Shipping($Customer->id, 'customer'); } else { $Customer = new Customer(); } $Customer->updates($_POST); if (!empty($_POST['new-password']) && !empty($_POST['confirm-password']) && $_POST['new-password'] == $_POST['confirm-password']) { $Customer->password = wp_hash_password($_POST['new-password']); if (!empty($Customer->wpuser)) { wp_set_password($_POST['new-password'], $Customer->wpuser); } } $Customer->save(); $Billing->updates($_POST['billing']); $Billing->save(); $Shipping->updates($_POST['shipping']); $Shipping->save(); } $pagenum = absint($pagenum); if (empty($pagenum)) { $pagenum = 1; } if (!$per_page || $per_page < 0) { $per_page = 20; } $index = $per_page * ($pagenum - 1); if (!empty($start)) { $startdate = $start; list($month, $day, $year) = explode("/", $startdate); $starts = mktime(0, 0, 0, $month, $day, $year); } if (!empty($end)) { $enddate = $end; list($month, $day, $year) = explode("/", $enddate); $ends = mktime(23, 59, 59, $month, $day, $year); } $customer_table = DatabaseObject::tablename(Customer::$table); $billing_table = DatabaseObject::tablename(Billing::$table); $purchase_table = DatabaseObject::tablename(Purchase::$table); $users_table = $wpdb->users; $where = ''; if (!empty($s)) { $s = stripslashes($s); if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER)) { foreach ($props as $search) { $keyword = !empty($search[2]) ? $search[2] : $search[3]; switch (strtolower($search[1])) { case "company": $where .= (empty($where) ? "WHERE " : " AND ") . "c.company LIKE '%{$keyword}%'"; break; case "login": $where .= (empty($where) ? "WHERE " : " AND ") . "u.user_login LIKE '%{$keyword}%'"; break; case "address": $where .= (empty($where) ? "WHERE " : " AND ") . "(b.address LIKE '%{$keyword}%' OR b.xaddress='%{$keyword}%')"; break; case "city": $where .= (empty($where) ? "WHERE " : " AND ") . "b.city LIKE '%{$keyword}%'"; break; case "province": case "state": $where .= (empty($where) ? "WHERE " : " AND ") . "b.state='{$keyword}'"; break; case "zip": case "zipcode": case "postcode": $where .= (empty($where) ? "WHERE " : " AND ") . "b.postcode='{$keyword}'"; break; case "country": $where .= (empty($where) ? "WHERE " : " AND ") . "b.country='{$keyword}'"; break; } } } elseif (strpos($s, '@') !== false) { $where .= (empty($where) ? "WHERE " : " AND ") . "c.email='{$s}'"; } else { $where .= (empty($where) ? "WHERE " : " AND ") . " (c.id='{$s}' OR CONCAT(c.firstname,' ',c.lastname) LIKE '%{$s}%' OR c.company LIKE '%{$s}%')"; } } if (!empty($starts) && !empty($ends)) { $where .= (empty($where) ? "WHERE " : " AND ") . ' (UNIX_TIMESTAMP(c.created) >= ' . $starts . ' AND UNIX_TIMESTAMP(c.created) <= ' . $ends . ')'; } $customercount = $db->query("SELECT count(*) as total FROM {$customer_table} AS c {$where}"); $query = "SELECT c.*,b.city,b.state,b.country, u.user_login, SUM(p.total) AS total,count(distinct p.id) AS orders FROM {$customer_table} AS c LEFT JOIN {$purchase_table} AS p ON p.customer=c.id LEFT JOIN {$billing_table} AS b ON b.customer=c.id LEFT JOIN {$users_table} AS u ON u.ID=c.wpuser AND (c.wpuser IS NULL OR c.wpuser !=0) {$where} GROUP BY c.id ORDER BY c.created DESC LIMIT {$index},{$per_page}"; $Customers = $db->query($query, AS_ARRAY); $num_pages = ceil($customercount->total / $per_page); $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => $num_pages, 'current' => $pagenum)); $ranges = array('all' => __('Show New Customers', 'Shopp'), 'today' => __('Today', 'Shopp'), 'week' => __('This Week', 'Shopp'), 'month' => __('This Month', 'Shopp'), 'quarter' => __('This Quarter', 'Shopp'), 'year' => __('This Year', 'Shopp'), 'yesterday' => __('Yesterday', 'Shopp'), 'lastweek' => __('Last Week', 'Shopp'), 'last30' => __('Last 30 Days', 'Shopp'), 'last90' => __('Last 3 Months', 'Shopp'), 'lastmonth' => __('Last Month', 'Shopp'), 'lastquarter' => __('Last Quarter', 'Shopp'), 'lastyear' => __('Last Year', 'Shopp'), 'lastexport' => __('Last Export', 'Shopp'), 'custom' => __('Custom Dates', 'Shopp')); $exports = array('tab' => __('Tab-separated.txt', 'Shopp'), 'csv' => __('Comma-separated.csv', 'Shopp'), 'xls' => __('Microsoft® Excel.xls', 'Shopp')); $formatPref = $Shopp->Settings->get('customerexport_format'); if (!$formatPref) { $formatPref = 'tab'; } $columns = array_merge(Customer::exportcolumns(), Billing::exportcolumns(), Shipping::exportcolumns()); $selected = $Shopp->Settings->get('customerexport_columns'); if (empty($selected)) { $selected = array_keys($columns); } $authentication = $Shopp->Settings->get('account_system'); include "{$this->basepath}/core/ui/customers/customers.php"; }
/** * @depends testCustomerCreate * @group ecommerce */ public function testCustomerDelete($customer_existing) { $this->mockResponse($this->success_customer_delete_response()); $customer = Customer::delete($customer_existing->token); $this->assertNotNull($customer->token); $this->assertNotNull($customer->email); $this->assertFalse($customer->is_active); }
public function uninstallDB() { // Delete NetEven employee $employee = new Employee((int) Gateway::getConfig('ID_EMPLOYEE_NETEVEN')); $employee->delete(); // Delete NetEven customer $customer = new Customer((int) Gateway::getConfig('ID_CUSTOMER_NETEVEN')); $customer->delete(); // Removing tables from the database $result = Db::getInstance()->Execute(' DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'orders_gateway`, `' . _DB_PREFIX_ . 'orders_gateway_order_state`, `' . _DB_PREFIX_ . 'orders_gateway_customer`, `' . _DB_PREFIX_ . 'orders_gateway_configuration`, `' . _DB_PREFIX_ . 'orders_gateway_feature_link`, `' . _DB_PREFIX_ . 'orders_gateway_feature` '); if (!$result) { return false; } return true; }
<?php session_start(); require "../includes/checkPermission.php"; require "../../deny/connector.php"; require "class/class.Customer.php"; require "../includes/injection.php"; $_SESSION['CUSDELETE'] = ""; $cusid = sqlInjection($_GET['cID']); $str = "select cus_id from tblorder where cus_id={$cusid} "; $result = mysql_query($str); if (mysql_num_rows($result) > 0) { $_SESSION['CUSDELETE'] = "<font color=red face=Verdana>Không thể xóa Khách hàng vì đang có đơn đặt hàng liên quan<br>Hãy xóa đơn đặt hàng liên quan trước khi xóa Khách hàng</font>"; } else { $cus = new Customer(); $cus->delete($cusid); $_SESSION['CUSDELETE'] = ""; } //echo $cusid; echo "<meta http-equiv='refresh' content='0;url=../admincp.php?opt=listcustomer'>"; //header("location: ../admincp.php?opt=listcustomer"); //exit();