function deleteAction() { $id = AF::get($_POST, 'id', 0); $modelsID = explode(',', $id); $errors = FALSE; foreach ($modelsID as $id) { $model = new Address(); $model->model_uset_id = $this->user->user_id; if ($model->findByPk($id)) { $model->delete($id); } else { $errors = TRUE; } if ($model->getErrors()) { $errors = TRUE; } unset($model); } if (isset($_POST['ajax'])) { AF::setJsonHeaders('json'); if ($errors) { Message::echoJsonError(__('address_not_deleted')); } else { Message::echoJsonSuccess(__('address_deleted')); } } $this->redirect(); }
/** * clear DB */ public function __destruct() { /** * delete customer */ if ($this->getPlugin()->getContext() && $this->_isDummyCustomer) { $this->getPlugin()->getContext()->customer->delete(); // "delete" function calls deleteByIdCustomer. // In version 1.4.x.x this logic only deletes discounts defined to an user, but not the user itself. // It's needed to delete the user entry manually if (version_compare(_PS_VERSION_, '1.5.0', '<')) { Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'customer` WHERE `id_customer` = ' . (int) $this->getPlugin()->getContext()->customer->id); } } /** * delete delivery address */ if ($this->_deliveryAddress && $this->_deliveryAddress->id) { $this->_deliveryAddress->delete(); } /** * delete invoice address */ if ($this->_invoiceAddress && $this->_invoiceAddress->id) { $this->_invoiceAddress->delete(); } /** * delete cart */ if ($this->getPlugin()->getContext()->cart->id) { $this->getPlugin()->getContext()->cart->delete(); } }
/** * @todo Implement testDelete(). */ public function testDelete() { $this->testSave(); $id = $this->object->getId(); $this->object->delete(); $obj = new Address($id); $this->assertEquals($obj, new Address()); }
public function delete() { $addresses = $this->getAddresses((int) Configuration::get('PS_LANG_DEFAULT')); foreach ($addresses as $address) { $obj = new Address((int) $address['id_address']); $obj->delete(); } Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'customer_group` WHERE `id_customer` = ' . (int) $this->id); Discount::deleteByIdCustomer((int) $this->id); return parent::delete(); }
public function delete() { $address = new Address($this->id_address); if (!$address->delete()) { return false; } if (parent::delete()) { CartRule::cleanProductRuleIntegrity('manufacturers', $this->id); return $this->deleteImage(); } }
/** * Method used for control delete operation. */ public function deleteAction($id) { $model = new Address(); if ($model->delete($id) === false) { $this->_result['error'] = true; $this->_result['errorMessage'] = 'Record not deleted.'; header('HTTP/1.1 204 No Content'); } else { $this->_result['data'] = 'DELETED.'; } $this->renderResult(); }
public function save(Address $address, $token) { if (!$this->authorizeChange($address, $token)) { return false; } $address->id_customer = $this->customer->id; if ($address->isUsed()) { $old_address = new Address($address->id); $address->id = $address->id_address = null; return $address->save() && $old_address->delete(); } return $address->save(); }
public function update($nullValues = false) { $this->birthday = empty($this->years) ? $this->birthday : (int) $this->years . '-' . (int) $this->months . '-' . (int) $this->days; if ($this->newsletter && !Validate::isDate($this->newsletter_date_add)) { $this->newsletter_date_add = date('Y-m-d H:i:s'); } if (isset(Context::getContext()->controller) && Context::getContext()->controller->controller_type == 'admin') { $this->updateGroup($this->groupBox); } if ($this->deleted) { $addresses = $this->getAddresses((int) Configuration::get('PS_LANG_DEFAULT')); foreach ($addresses as $address) { $obj = new Address((int) $address['id_address']); $obj->delete(); } } return parent::update(true); }
public function delete() { $address = new Address($this->id_address); if (!$address->delete()) { return false; } return parent::delete(); }
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; }
public static function getCarriersByCountry($id_country, $id_state, $zipcode, $exiting_cart, $id_customer) { // Create temporary Address $addr_temp = new Address(); $addr_temp->id_customer = $id_customer; $addr_temp->id_country = $id_country; $addr_temp->id_state = $id_state; $addr_temp->postcode = $zipcode; // Populate required attributes // Note: Some carrier needs the whole address // the '.' will do the job $addr_temp->firstname = "."; $addr_temp->lastname = "."; $addr_temp->address1 = "."; $addr_temp->city = "."; $addr_temp->alias = "TEMPORARY_ADDRESS_TO_DELETE"; $addr_temp->save(); $cart = new Cart(); $cart->id_currency = $exiting_cart->id_currency; $cart->id_customer = $exiting_cart->id_customer; $cart->id_lang = $exiting_cart->id_lang; $cart->id_address_delivery = $addr_temp->id; $cart->add(); $products = $exiting_cart->getProducts(); foreach ($products as $key => $product) { $cart->updateQty($product['quantity'], $product['id_product'], $product['id_product_attribute']); } $carriers = $cart->simulateCarriersOutput(null, true); //delete temporary objects $addr_temp->delete(); $cart->delete(); return $carriers; }
public function delete() { $addresses = $this->getAddresses(intval(Configuration::get('PS_LANG_DEFAULT'))); foreach ($addresses as $address) { $obj = new Address(intval($address['id_address'])); $obj->delete(); } return parent::delete(); }
/** * 添加顾客 */ 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)); }
public function getCarriersListByIdZone($id_country, $id_state = 0, $zipcode = 0) { global $cart, $smarty, $cookie; // cookie saving/updating $cookie->id_country = $id_country; if ($id_state != 0) { $cookie->id_state = $id_state; } if ($zipcode !== 0) { $cookie->postcode = $zipcode; } $id_zone = 0; if ($id_state != 0) { $id_zone = State::getIdZone($id_state); } if (!$id_zone) { $id_zone = Country::getIdZone($id_country); } // Need to set the infos for carrier module ! $cookie->id_country = $id_country; $cookie->id_state = $id_state; $cookie->postcode = $zipcode; $carriers = array(); if ($this->addAddress($id_country, $zipcode)) { // Back up the current id_address_delivery $current_id_address_delivery = $cart->id_address_delivery; // Get the new one created $cart->id_address_delivery = Configuration::get(CarrierCompare::VIRTUAL_ADDRESS); $cart->id_customer = Configuration::get(CarrierCompare::VIRTUAL_CUSTOMER); // Get carriers with good id_zone $carriers = Carrier::getCarriersForOrder((int) $id_zone); // Delete Address and restore id_address_delivery $address = new Address((int) Configuration::get(CarrierCompare::VIRTUAL_ADDRESS)); $address->delete(); $cart->id_address_delivery = $current_id_address_delivery; } return count($carriers) ? $carriers : array(); }
} } else { $reload = 0; $mesg = $address->error; $_GET["action"]= "edit"; } } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->supprimer) { $address = new Address($db); $result = $address->delete($_GET["id"], $socid); if ($result == 0) { Header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); exit ; } else { $reload = 0; $_GET["action"]=''; } } /** *
$nameElem = $newCategorieName; $address->update($elem, $nameElem, $adressNameChangeCategorie); echo "Categorie"; } if (!empty($phone)) { $adressNameChangePhone = $addressName; if (!empty($addressNewName)) { $adressNameChangePhone = $addressNewName; } $elem = "phone"; $nameElem = $phone; $address->update($elem, $nameElem, $adressNameChangePhone); } } } } } } } } else { if (isset($_POST["delete"]) and $_POST["delete"] === "true" and isset($_POST["name"]) and isset($_POST["categorie"])) { $name = strip_tags($_POST["name"]); $categorie = strip_tags($_POST["categorie"]); $address->delete($name, $categorie); $addressList->delete($name); echo "successDelete"; } } } break; }
public function delete() { if (!count(Order::getCustomerOrders((int) $this->id))) { $addresses = $this->getAddresses((int) Configuration::get('PS_LANG_DEFAULT')); foreach ($addresses as $address) { $obj = new Address((int) $address['id_address']); $obj->delete(); } } Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'customer_group` WHERE `id_customer` = ' . (int) $this->id); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'message WHERE id_customer=' . (int) $this->id); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'specific_price WHERE id_customer=' . (int) $this->id); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'compare WHERE id_customer=' . (int) $this->id); $carts = Db::getInstance()->executes('SELECT id_cart FROM ' . _DB_PREFIX_ . 'cart WHERE id_customer=' . (int) $this->id); if ($carts) { foreach ($carts as $cart) { Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cart WHERE id_cart=' . (int) $cart['id_cart']); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart=' . (int) $cart['id_cart']); } } $cts = Db::getInstance()->executes('SELECT id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread WHERE id_customer=' . (int) $this->id); if ($cts) { foreach ($cts as $ct) { Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customer_thread WHERE id_customer_thread=' . (int) $ct['id_customer_thread']); Db::getInstance()->execute('DELETE FROM ' . _DB_PREFIX_ . 'customer_message WHERE id_customer_thread=' . (int) $ct['id_customer_thread']); } } CartRule::deleteByIdCustomer((int) $this->id); return parent::delete(); }
Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); Flight::route('PUT /v1/main/address/@id', function ($id) { try { $object = Address::update($id); Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); Flight::route('DELETE /v1/main/address/@id', function ($id) { try { $object = Address::delete($id); Flight::ok($object); } catch (Exception $exception) { Flight::error($exception); } }); //============================================================================= //Collection //============================================================================= Flight::route('GET /v1/main/collection', function () { $company = Flight::request()->query->company; try { if ($company) { $array = Collection::selectByCompany($company); } else { $array = Collection::selectAll();
protected function checkForTemporarySessionVarsAndKillThem() { $need_update = false; if (isset($this->context->cart->id_address_delivery)) { $check_address = new Address((int) $this->context->cart->id_address_delivery); if ($check_address->lastname == 'amzLastname' || $check_address->firstname == 'amzFirstname' || $check_address->address1 == 'amzAddress1') { $check_address->delete(); $this->context->cart->id_address_delivery = 0; $sql = 'UPDATE `' . _DB_PREFIX_ . 'cart_product` SET `id_address_delivery` = NULL WHERE `id_cart` = ' . (int) $this->context->cart->id; Db::getInstance()->execute($sql); $sql = 'UPDATE `' . _DB_PREFIX_ . 'customization` SET `id_address_delivery` = NULL WHERE `id_cart` = ' . (int) $this->context->cart->id; Db::getInstance()->execute($sql); $need_update = true; } } if (isset($this->context->cart->id_address_invoice)) { $check_address = new Address((int) $this->context->cart->id_address_invoice); if ($check_address->lastname == 'amzLastname' || $check_address->firstname == 'amzFirstname' || $check_address->address1 == 'amzAddress1') { $check_address->delete(); $this->context->cart->id_address_invoice = 0; $sql = 'UPDATE `' . _DB_PREFIX_ . 'cart_product` SET `id_address_delivery` = NULL WHERE `id_cart` = ' . (int) $this->context->cart->id; Db::getInstance()->execute($sql); $sql = 'UPDATE `' . _DB_PREFIX_ . 'customization` SET `id_address_delivery` = NULL WHERE `id_cart` = ' . (int) $this->context->cart->id; Db::getInstance()->execute($sql); $need_update = true; } } if ($need_update) { $this->context->cart->update(); } }
exit; } else { header("Location: " . $_SERVER['PHP_SELF'] . "?socid=" . $socid); exit; } } } else { $reload = 0; $mesg = $object->error; $actino = "edit"; } } } } else { if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { $result = $object->delete($id, $socid); if ($result == 0) { header("Location: " . $_SERVER['PHP_SELF'] . "?socid=" . $socid); exit; } else { $reload = 0; $action = ''; } } } /** * * */ llxHeader(); $form = new Form($db);
<?php ob_start(); require_once "includes/functions.php"; $address = new Address(); $countries = $address->listAllCountries(); if (array_key_exists('delete_address', $_POST)) { $_POST['insert_id'] = $address->delete(); $url = "location: portfolio.php?insert_id=" . $_POST['insert_id']; header($url); } if (array_key_exists('modify_address', $_POST)) { $addressFromAddressId = $address->getAddressFromAddressId($_POST['address_id']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/main.css"/> <script language="javascript" type="text/javascript"> var county_iso = "<?php print $addressFromAddressId['countryIso']; ?> " var state = "<?php print $addressFromAddressId['state']; ?> " </script>