public function run() { DB::table('addresses')->delete(); Address::create(['address' => 'mtqSqRAGB7EuPtgCwvMtX74S2tvTapDWD6', 'user_id' => 1]); Address::create(['address' => 'n21cjTZa59QcMBXFvoKx2WoRotBV9mErnJ', 'user_id' => 1]); Address::create(['address' => 'mxKRETCDzCuLVLiw9MieJb8xFi1WhkQ9wY', 'user_id' => 1]); }
/** * (non-PHPdoc) * @see DetailsPageAbstract::saveItem() */ public function saveItem($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($param->CallbackParameter->id)) { throw new Exception('Invalid supplier ID passed in!'); } $supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id); if (!$supplier instanceof Supplier) { throw new Exception('Invalid supplier passed in!'); } $contactName = trim($param->CallbackParameter->address->contactName); $contactNo = trim($param->CallbackParameter->address->contactNo); $street = trim($param->CallbackParameter->address->street); $city = trim($param->CallbackParameter->address->city); $region = trim($param->CallbackParameter->address->region); $postCode = trim($param->CallbackParameter->address->postCode); $country = trim($param->CallbackParameter->address->country); $address = $supplier->getAddress(); $supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save(); $results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : ''); $results['item'] = $supplier->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage() . $ex->getTraceAsString(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
public function run() { // $faker->seed(1234); for ($x = 0; $x < 1000; $x++) { Address::create(array('address' => '1688 Los Berros Rd', 'lng' => rand(-120, 120), 'lat' => rand(-120, 120), 'depth' => rand(0, 100), 'flow_rate' => rand(0, 100), 'year_dug' => rand(0, 200), 'user_id' => rand(0, 1000))); } $this->command->info('Person table seeded using Faker ...'); }
/** * Store a newly created address in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Address::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Address::create($data); return Redirect::route('addresses.index'); }
public function addAddress($params, $default = false) { $address = Address::create($params); $this->addresses()->save($address); if ($default) { $this->address()->associate($address); $this->save(); } }
public function run() { // not to delete in production just in case lol if (App::environment('production')) { DB::table('addresses')->delete(); } Address::create(['address' => 'mtqSqRAGB7EuPtgCwvMtX74S2tvTapDWD6', 'user_id' => 1]); Address::create(['address' => 'n21cjTZa59QcMBXFvoKx2WoRotBV9mErnJ', 'user_id' => 1]); Address::create(['address' => 'mxKRETCDzCuLVLiw9MieJb8xFi1WhkQ9wY', 'user_id' => 1]); }
/** * Get location of user * * @param Address $address location */ public function getAddress() { $address = null; if ($data = $this->getLocationData()) { $address = Address::create(); $address->update($data); $address->ID = 0; //ensure not in db } return $address; }
public function run() { $customers = array(array('last_name' => 'Jones', 'first_name' => 'Tim', 'telephone1' => '(918) 555 1212', 'email' => '*****@*****.**', 'password' => Hash::make('password'), 'admin_ind' => TRUE), array('last_name' => 'User', 'first_name' => 'Joe', 'telephone1' => '(918) 555 1212', 'email' => '*****@*****.**', 'password' => Hash::make('password'), 'admin_ind' => FALSE), array('last_name' => 'vincent', 'first_name' => 'jan michael', 'telephone1' => '(918) 555 7890', 'email' => '*****@*****.**', 'password' => Hash::make('password'), 'admin_ind' => FALSE)); $addresses = array(array('addr1' => '123 My Street', 'city' => 'Owasso', 'state' => 'OK', 'postal_code' => '74055', 'country' => 'USA'), array('addr1' => '123 Joe\'s Street', 'city' => 'Owasso', 'state' => 'OK', 'postal_code' => '74055', 'country' => 'USA'), array('addr1' => '456 Oak Street', 'city' => 'Tulsa', 'state' => 'OK', 'postal_code' => '74102', 'country' => 'USA'), array('addr1' => '888 Yellow Lane', 'addr2' => 'c/o Sacramento Church of Christ', 'city' => 'Sacramento', 'state' => 'CA', 'postal_code' => '99999', 'country' => 'USA')); foreach ($customers as $customer) { $customer['password_confirmation'] = $customer['password']; $newcust = Customer::create($customer); //var_dump($customer); // Choose a random address from the list and insert it for the new customer. $address = $addresses[mt_rand(0, count($addresses) - 1)]; $address['customer_id'] = $newcust->id; Address::create($address); } }
public function testRequiredFields() { // create address instance that lacks some required fields (Address) $address = Address::create(array('Country' => 'NZ', 'State' => 'Wellington', 'City' => 'TeAro')); $writeFailed = false; try { $address->write(); } catch (Exception $ex) { $writeFailed = true; } $this->assertTrue($writeFailed, "Address should not be writable, since it doesn't contain all required fields"); // Create an Address that satisfies the baseline required fields, but not the ones that were added via subclass. $address = ExtendedTestAddress::create(array('Country' => 'NZ', 'State' => 'Wellington', 'City' => 'TeAro', 'Address' => '23 Blah Street')); $writeFailed = false; try { $address->write(); } catch (Exception $ex) { $writeFailed = true; } $this->assertTrue($writeFailed, "Address should not be writable, since it doesn't contain required fields added via subclass"); }
/** * Factory method to create a Contact object from an array * @param array $props - Associative array of initial properties to set * @return Contact */ public static function create(array $props) { $contact = new Contact(); $contact->id = parent::getValue($props, "id"); $contact->status = parent::getValue($props, "status"); $contact->first_name = parent::getValue($props, "first_name"); $contact->middle_name = parent::getValue($props, "middle_name"); $contact->last_name = parent::getValue($props, "last_name"); $contact->confirmed = parent::getValue($props, "confirmed"); $contact->source = parent::getValue($props, "source"); foreach ($props['email_addresses'] as $email_address) { $contact->email_addresses[] = EmailAddress::create($email_address); } $contact->prefix_name = parent::getValue($props, "prefix_name"); $contact->job_title = parent::getValue($props, "job_title"); foreach ($props['addresses'] as $address) { $contact->addresses[] = Address::create($address); } foreach ($props['notes'] as $note) { $contact->notes[] = Note::create($note); } $contact->company_name = parent::getValue($props, "company_name"); $contact->home_phone = parent::getValue($props, "home_phone"); $contact->work_phone = parent::getValue($props, "work_phone"); $contact->cell_phone = parent::getValue($props, "cell_phone"); $contact->fax = parent::getValue($props, "fax"); foreach ($props['custom_fields'] as $custom_field) { $contact->custom_fields[] = CustomField::create($custom_field); } foreach ($props['lists'] as $contact_list) { $contact->lists[] = ContactList::create($contact_list); } $contact->source_details = parent::getValue($props, "source_details"); return $contact; }
/** * saveOrder * * @param unknown $sender * @param unknown $param * * @throws Exception * */ public function saveOrder($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $customer = Customer::get(trim($param->CallbackParameter->customer->id)); if (!$customer instanceof Customer) { throw new Exception('Invalid Customer passed in!'); } if (!isset($param->CallbackParameter->applyTo) || ($applyTo = trim($param->CallbackParameter->applyTo)) === '' || !in_array($applyTo, CreditNote::getApplyToTypes())) { throw new Exception('Invalid Apply To passed in!'); } if (isset($param->CallbackParameter->creditNoteId) && ($creditNote = CreditNote::get(trim($param->CallbackParameter->creditNoteId))) instanceof CreditNote) { $creditNote = $creditNote; } else { if (isset($param->CallbackParameter->orderId) && ($order = Order::get(trim($param->CallbackParameter->orderId))) instanceof Order) { $creditNote = CreditNote::createFromOrder($order, $customer, trim($param->CallbackParameter->description)); } else { $creditNote = CreditNote::create($customer, trim($param->CallbackParameter->description)); } } $creditNote->setShippingValue(isset($param->CallbackParameter->totalShippingCost) ? StringUtilsAbstract::getValueFromCurrency($param->CallbackParameter->totalShippingCost) : 0); if (isset($param->CallbackParameter->shippingAddr)) { $shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo); $customer->setShippingAddress($shippAddress); } $printItAfterSave = false; if (isset($param->CallbackParameter->printIt)) { $printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false; } if (isset($param->CallbackParameter->comments)) { $comments = trim($param->CallbackParameter->comments); $creditNote->addComment($comments, Comments::TYPE_SALES); } $totalPaymentDue = $creditNote->getShippingValue(); $hasShipped = $creditNote->getOrder() instanceof Order && Shippment::countByCriteria('orderId = ?', array($creditNote->getOrder()->getId())) > 0; $creditNoteItemsMap = array(); foreach ($param->CallbackParameter->items as $item) { if (!($product = Product::get(trim($item->product->id))) instanceof Product) { throw new Exception('Invalid Product passed in!'); } $unitPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice)); $qtyOrdered = trim($item->qtyOrdered); $totalPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->totalPrice)); $itemDescription = trim($item->itemDescription); $active = trim($item->valid); $totalPaymentDue += $totalPrice; if (is_numeric($item->creditNoteItemId) && !CreditNoteItem::get(trim($item->creditNoteItemId)) instanceof CreditNoteItem) { throw new Exception('Invalid Credit Note Item passed in'); } $unitCost = $product->getUnitCost(); $orderItem = null; if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) { $unitCost = $orderItem->getUnitCost(); } $creditNoteItem = is_numeric($item->creditNoteItemId) ? CreditNoteItem::get(trim($item->creditNoteItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setUnitPrice($unitPrice)->setItemDescription($itemDescription)->setUnitCost($unitCost)->setTotalPrice($totalPrice)->save() : ($orderItem instanceof OrderItem ? CreditNoteItem::createFromOrderItem($creditNote, $orderItem, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice) : CreditNoteItem::create($creditNote, $product, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice)); if (intval($creditNoteItem->getActive()) === 1) { if (!isset($creditNoteItemsMap[$product->getId()])) { $creditNoteItemsMap[$product->getId()] = 0; } $creditNoteItemsMap[$product->getId()] += $qtyOrdered; } //if we are not creating from a order, or there are shippments for this order then if (!$creditNote->getOrder() instanceof Order || $hasShipped === true) { switch (trim($item->stockData)) { case 'StockOnHand': $product->returnedIntoSOH($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem); break; case 'StockOnRMA': $product->returnedIntoRMA($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem); break; default: throw new Exception('System Error: NO where to transfer the stock: ' . trim($item->stockData) . ' for product(SKU=' . $product->getSku() . ').'); } } else { //revert all the shipped stock foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isShipped = 1', array($creditNote->getOrder()->getId())) as $orderItem) { $orderItem->setIsShipped(false)->save(); } //revert all the picked stock foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isPicked = 1', array($creditNote->getOrder()->getId())) as $orderItem) { $orderItem->setIsPicked(false)->save(); } } } if (($paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId))) instanceof PaymentMethod) { $creditNote->setTotalPaid($totalPaidAmount = $param->CallbackParameter->totalPaidAmount)->addPayment($paymentMethod, $totalPaidAmount); } $creditNote->setTotalValue($totalPaymentDue)->setApplyTo($applyTo)->save(); //if need to check half credited orders if ($creditNote->getOrder() instanceof Order && $hasShipped === false) { $orderItemMap = array(); foreach ($order->getOrderItems() as $orderItem) { $productId = $orderItem->getProduct()->getId(); if (!isset($orderItemMap[$productId])) { $orderItemMap[$productId] = 0; } $orderItemMap[$productId] += $orderItem->getQtyOrdered(); } //figure out the difference foreach ($creditNoteItemsMap as $productId => $qty) { if (isset($orderItemMap[$productId])) { if ($orderItemMap[$productId] <= $qty) { //credited more than orderred unset($orderItemMap[$productId]); } else { //credited less then ordered $orderItemMap[$productId] = $orderItemMap[$productId] - $qty; } } } $orderItemMap = array_filter($orderItemMap); if (count($orderItemMap) > 0) { //there are difference $creditNote->creditFullOrder(); $newOrder = Order::create($creditNote->getOrder()->getCustomer(), $creditNote->getOrder()->getType() === 'INVOICE' ? Order::TYPE_ORDER : $creditNote->getOrder()->getType(), null, 'Spliting order because of partial credit note(CreditNoteNo:.' . $creditNote->getCreditNoteNo() . ') created', null, $creditNote->getOrder()->getOrderDate(), false, $creditNote->getOrder()->getShippingAddr(), $creditNote->getOrder()->getBillingAddr(), $creditNote->getOrder()->getPassPaymentCheck(), $creditNote->getOrder()->getPONo(), $creditNote->getOrder())->addComment('Created because of partial credit from '); $totalAmount = 0; foreach ($orderItemMap as $productId => $qty) { $orderItems = OrderItem::getAllByCriteria('productId = ? and orderId = ?', array($productId, $creditNote->getOrder()->getId()), true, 1, 1); if (count($orderItems) > 0) { $totalAmount += $orderItems[0]->getUnitPrice() * $qty; } $newOrder->addItem($orderItems[0]->getProduct(), $orderItems[0]->getUnitPrice(), $qty, $orderItems[0]->getTotalPrice(), $orderItems[0]->getMageOrderId(), $orderItems[0]->getEta(), $orderItems[0]->getItemDescription()); } if (count($shippingMethods = $creditNote->getOrder()->getInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD)) > 0) { $newOrder->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD, $shippingMethods[0], true); } if (count($shippingCost = $creditNote->getOrder()->getInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_COST)) > 0) { $newOrder->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_COST, $shippingCost[0], true); $totalAmount += StringUtilsAbstract::getValueFromCurrency($shippingCost[0]); } $results['newOrder'] = $newOrder->setTotalAmount($totalAmount)->save()->getJson(); $creditNote->getOrder()->setStatus(OrderStatus::get(OrderStatus::ID_CANCELLED))->save()->addComment('This ' . $creditNote->getOrder()->getType() . ' is CANCELED, because of partial credit (CreditNoteNo:<a href="/creditnote/' . $creditNote->getId() . '.html" target="_BLANK">' . $creditNote->getCreditNoteNo() . '</a>) is created and a new ' . $newOrder->getType() . ' (<a href="/orderdetails/' . $newOrder->getId() . '.html?blanklayout=1">' . $newOrder->getOrderNo() . '</a>) is created for the diference.', Comments::TYPE_MEMO); } else { $creditNote->getOrder()->setStatus(OrderStatus::get(OrderStatus::ID_CANCELLED))->save()->addComment('This ' . $creditNote->getOrder()->getType() . ' is CANCELED, because of full credit (CreditNoteNo:<a href="/creditnote/' . $creditNote->getId() . '.html" target="_BLANK">' . $creditNote->getCreditNoteNo() . '</a>) is created.', Comments::TYPE_MEMO); } } $results['item'] = $creditNote->getJson(); $results['redirectURL'] = '/creditnote/' . $creditNote->getId() . '.html?' . $_SERVER['QUERY_STRING']; if ($printItAfterSave === true) { $results['printURL'] = '/print/creditnote/' . $creditNote->getId() . '.html?pdf=1'; } Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage() . '<pre>' . $ex->getTraceAsString() . '</pre>'; } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
$address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:''); $address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:''); $address->address = $_POST["address"]; $address->cp = $_POST["zipcode"]; $address->ville = $_POST["town"]; $address->pays_id = $_POST["pays_id"]; $address->tel = $_POST["tel"]; $address->fax = $_POST["fax"]; $address->note = $_POST["note"]; if ($_POST["action"] == 'add') { $socid = $_POST["socid"]; $origin = $_POST["origin"]; $originid = $_POST["originid"]; $result = $address->create($socid, $user); if ($result >= 0) { if ($origin == commande) { Header("Location: ../commande/fiche.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); exit; } elseif ($origin == propal) { Header("Location: ../comm/propal.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); exit; } else {
/** * Store a newly created resource in storage. * * @return Response */ public function store() { die(Input::get('tab_index')); $input = Input::all(); // STEP 1 : validate data (pendding) $validator = Validator::make($input, Customer::$rules); if (!$validator->passes()) { return Redirect::back()->withErrors($validator)->withInput(); } // STEP 2 : build objects // Customer Stuff $customerData = array(); $customerData['name_fiscal'] = $input['name_fiscal']; // $customerData['name_commercial'] = $input['name_commercial']; // $customerData['firstname'] = $input['firstname']; // $customerData['lastname'] = $input['lastname']; // $customerData['email'] = $input['email']; $customerData['website'] = Input::get('website', ''); $customerData['identification'] = Input::get('identification', ''); // $customerData['phone'] = $input['phone']; // $customerData['phone_mobile'] = $input['phone_mobile']; // $customerData['fax'] = $input['fax']; $customerData['outstanding_amount_allowed'] = Input::get('outstanding_amount_allowed', Configuration::get('DEF_OUTSTANDING_AMOUNT')); $customerData['outstanding_amount'] = 0; $customerData['unresolved_amount'] = 0; $customerData['notes'] = Input::get('notes', ''); $customerData['accept_einvoice'] = Input::get('accept_einvoice', 0); $customerData['accept_einvoice'] = intval($customerData['accept_einvoice']) > 0 ? 1 : 0; $customerData['blocked'] = 0; $customerData['active'] = Input::get('activce', 1); $customerData['active'] = intval($customerData['active']) > 0 ? 1 : 0; // Customer Relations! $customerData['salesrep_id'] = 0; $customerData['currency_id'] = 0; $customerData['customer_group_id'] = 0; $customerData['payment_method_id'] = 0; $customerData['sequence_id'] = 0; $customerData['carrier_id'] = 0; $customerData['price_list_id'] = 0; $customerData['direct_debit_account_id'] = 0; $customerData['invoicing_address_id'] = 0; $customerData['shipping_address_id'] = 0; // Addresses Stuff $addressInvData = array(); $addressInvData['alias'] = 'Dirección Principal'; $addressInvData['model_name'] = 'Customer'; $addressInvData['name_commercial'] = Input::get('name_commercial', ''); $addressInvData['address1'] = Input::get('address1', ''); $addressInvData['address2'] = Input::get('address2', ''); $addressInvData['postcode'] = Input::get('postcode', ''); $addressInvData['city'] = Input::get('city', ''); $addressInvData['state'] = Input::get('state', ''); $addressInvData['country'] = Input::get('country', Configuration::get('DEF_COUNTRY_NAME')); $addressInvData['firstname'] = Input::get('firstname', ''); $addressInvData['lastname'] = Input::get('lastname', ''); $addressInvData['email'] = Input::get('email', ''); $addressInvData['phone'] = Input::get('phone', ''); $addressInvData['phone_mobile'] = Input::get('phone_mobile', ''); $addressInvData['fax'] = Input::get('fax', ''); $addressInvData['notes'] = ''; $addressInvData['active'] = 1; $addressInvData['latitude'] = 0; $addressInvData['longitude'] = 0; // Address Relations! $addressInvData['owner_id'] = 0; $addressInvData['state_id'] = 0; $addressInvData['country_id'] = 0; $addressShipData = array(); // $addressShipData[''] = $input['ship_address_']; $customer = Customer::create($customerData); $addressInv = Address::create($addressInvData); $addressInv->Customer()->associate($customer); $customer->addresses()->save($addressInv); $customer->invoicing_address_id = $addressInv->id; $customer->shipping_address_id = $addressInv->id; $customer->save(); // $customer->touch(); // See: http://stackoverflow.com/questions/16740973/one-to-many-relationship-inserts-2-records-into-table // Kind of different... /* return Redirect::route('customers.create') ->withInput() ->with('message_error', 'Esta txuta!'); */ // return Redirect::to('customers/' . $customer->id . '/edit') return Redirect::to('customers')->with('success', 'El Cliente se ha creado correctamente.'); // return Redirect::route('customers.create') // ->with('message_error', 'Esta txuta!'); /* $v = Validator::make($input, Customer::$rules); if ($v->passes()) { $this->customer->create($input); return Redirect::route('admin.customers.index') ->with('message_info', 'El registro se ha creado correctamente: '. $input['name'].' - '.$input['percent'].'%'); } return Redirect::route('admin.customers.create') ->withInput() ->withErrors($v) ->with('message_error', 'There were validation errors'); */ }
/** * Update the specified outlet in storage. * * @param int $id * @return Response */ public function update($outlet) { $data = Input::except('summary'); $description = Input::only('full_description', 'summary'); $validator = Validator::make($data = Input::all(), Outlet::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } if ($outlet->description_id) { $desc = OutletDescription::where('id', $outlet->description_id)->update($description); } else { $desc = OutletDescription::create($description); $data['description_id'] = $desc->id; } $addressData = array('city_id' => $data['city_id'], 'address' => $data['address']); if ($outlet->address_id) { $address = Address::where('id', $outlet->address_id)->update($addressData); } else { $address = Address::create($addressData); $data['address_id'] = $address->id; } unset($data['full_description']); unset($data['address']); $data['status'] = 'active'; if ($outlet->update($data)) { return Redirect::to('outlet')->with('success', Lang::get('site/outlets/messages.update.success')); } return Redirect::route('outlet.edit')->with('error', Lang::get('site/outlets/messages.update.error')); }
public function saveaddress($data, $form) { $member = $this->getMember(); $address = Address::create(); $form->saveInto($address); $address->MemberID = $member->ID; // Add value for Country if missing (due readonly field in form) if ($country = SiteConfig::current_site_config()->getSingleCountry()) { $address->Country = $country; } $address->write(); if (!$member->DefaultShippingAddressID) { $member->DefaultShippingAddressID = $address->ID; $member->write(); } if (!$member->DefaultBillingAddressID) { $member->DefaultBillingAddressID = $address->ID; $member->write(); } $form->sessionMessage(_t("CreateAddressForm.AddressSaved", "Your address has been saved"), "good"); $this->extend('updateCreateAddressFormResponse', $form, $data, $response); return $response ?: $this->redirect($this->Link('addressbook')); }
/** * saveOrder * * @param unknown $sender * @param unknown $param * * @throws Exception * */ public function saveOrder($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $customer = Customer::get(trim($param->CallbackParameter->customer->id)); if (!$customer instanceof Customer) { throw new Exception('Invalid Customer passed in!'); } if (!isset($param->CallbackParameter->type) || ($type = trim($param->CallbackParameter->type)) === '' || !in_array($type, Order::getAllTypes())) { throw new Exception('Invalid type passed in!'); } $order = null; if (isset($param->CallbackParameter->orderId) && ($orderId = trim($param->CallbackParameter->orderId)) !== '') { if (!($order = Order::get($orderId)) instanceof Order) { throw new Exception('Invalid Order to edit!'); } } $orderCloneFrom = null; if (isset($param->CallbackParameter->orderCloneFromId) && ($orderCloneFromId = trim($param->CallbackParameter->orderCloneFromId)) !== '') { if (!($orderCloneFrom = Order::get($orderCloneFromId)) instanceof Order) { throw new Exception('Invalid Order to clone from!'); } } $shipped = isset($param->CallbackParameter->shipped) && intval($param->CallbackParameter->shipped) === 1; $poNo = isset($param->CallbackParameter->poNo) && trim($param->CallbackParameter->poNo) !== '' ? trim($param->CallbackParameter->poNo) : ''; if (isset($param->CallbackParameter->shippingAddr)) { $shippAddress = $order instanceof Order ? $order->getShippingAddr() : null; $shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo, $param->CallbackParameter->shippingAddr->companyName, $shippAddress); } else { $shippAddress = $customer->getShippingAddress(); } $printItAfterSave = false; if (isset($param->CallbackParameter->printIt)) { $printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false; } if (!$order instanceof Order) { $order = Order::create($customer, $type, null, '', OrderStatus::get(OrderStatus::ID_NEW), new UDate(), false, $shippAddress, $customer->getBillingAddress(), false, $poNo, $orderCloneFrom); } else { $order->setType($type)->setPONo($poNo)->save(); } $totalPaymentDue = 0; if (trim($param->CallbackParameter->paymentMethodId)) { $paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId)); if (!$paymentMethod instanceof PaymentMethod) { throw new Exception('Invalid PaymentMethod passed in!'); } $totalPaidAmount = trim($param->CallbackParameter->totalPaidAmount); $order->addPayment($paymentMethod, $totalPaidAmount); $order = Order::get($order->getId()); $order->addInfo(OrderInfoType::ID_MAGE_ORDER_PAYMENT_METHOD, $paymentMethod->getName(), true); if ($shipped === true) { $order->setType(Order::TYPE_INVOICE); } } else { $paymentMethod = ''; $totalPaidAmount = 0; } foreach ($param->CallbackParameter->items as $item) { $product = Product::get(trim($item->product->id)); if (!$product instanceof Product) { throw new Exception('Invalid Product passed in!'); } if (isset($item->active) && intval($item->active) === 1 && intval($product->getActive()) !== 1 && $type === Order::TYPE_INVOICE) { throw new Exception('Product(SKU:' . $product->getSku() . ') is DEACTIVATED, please change it to be proper product before converting it to a ' . $type . '!'); } $unitPrice = trim($item->unitPrice); $qtyOrdered = trim($item->qtyOrdered); $totalPrice = trim($item->totalPrice); $itemDescription = trim($item->itemDescription); if (intval($item->active) === 1) { $totalPaymentDue += $totalPrice; if ($orderCloneFrom instanceof Order || !($orderItem = OrderItem::get($item->id)) instanceof OrderItem) { $orderItem = OrderItem::create($order, $product, $unitPrice, $qtyOrdered, $totalPrice, 0, null, $itemDescription); } else { $orderItem->setActive(intval($item->active))->setProduct($product)->setUnitPrice($unitPrice)->setQtyOrdered($qtyOrdered)->setTotalPrice($totalPrice)->setItemDescription($itemDescription)->save(); $existingSellingItems = SellingItem::getAllByCriteria('orderItemId = ?', array($orderItem->getId())); foreach ($existingSellingItems as $sellingItem) { //DELETING ALL SERIAL NUMBER BEFORE ADDING $sellingItem->setActive(false)->save(); } } $orderItem = OrderItem::get($orderItem->getId())->reCalMarginFromProduct()->resetCostNMarginFromKits()->save(); } else { if ($orderCloneFrom instanceof Order) { continue; } elseif (($orderItem = OrderItem::get($item->id)) instanceof OrderItem) { $orderItem->setActive(false)->save(); } } if (isset($item->serials) && count($item->serials) > 0) { foreach ($item->serials as $serialNo) { $orderItem->addSellingItem($serialNo)->save(); } } if ($shipped === true) { $orderItem->setIsPicked(true)->save(); } } if (isset($param->CallbackParameter->courierId)) { $totalShippingCost = 0; $courier = null; if (is_numeric($courierId = trim($param->CallbackParameter->courierId))) { $courier = Courier::get($courierId); if (!$courier instanceof Courier) { throw new Exception('Invalid Courier passed in!'); } $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD, $courier->getName(), true); } else { $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_METHOD, $courierId, true); } if (isset($param->CallbackParameter->totalShippingCost)) { $totalShippingCost = StringUtilsAbstract::getValueFromCurrency(trim($param->CallbackParameter->totalShippingCost)); $order->addInfo(OrderInfoType::ID_MAGE_ORDER_SHIPPING_COST, StringUtilsAbstract::getCurrency($totalShippingCost), true); } if ($shipped === true) { if (!$courier instanceof Courier) { $courier = Courier::get(Courier::ID_LOCAL_PICKUP); } Shippment::create($shippAddress, $courier, '', new UDate(), $order, ''); } } else { $courier = ''; $totalShippingCost = 0; } $totalPaymentDue += $totalShippingCost; $comments = isset($param->CallbackParameter->comments) ? trim($param->CallbackParameter->comments) : ''; $order = $order->addComment($comments, Comments::TYPE_SALES)->setTotalPaid($totalPaidAmount); if ($shipped === true) { $order->setStatus(OrderStatus::get(OrderStatus::ID_SHIPPED)); } $order->setTotalAmount($totalPaymentDue)->save(); if (isset($param->CallbackParameter->newMemo) && ($newMemo = trim($param->CallbackParameter->newMemo)) !== '') { $order->addComment($newMemo, Comments::TYPE_MEMO); } $results['item'] = $order->getJson(); if ($printItAfterSave === true) { $results['printURL'] = '/print/order/' . $order->getId() . '.html?pdf=1'; } $results['redirectURL'] = '/order/' . $order->getId() . '.html' . (trim($_SERVER['QUERY_STRING']) === '' ? '' : '?' . $_SERVER['QUERY_STRING']); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
/** * saveOrder * * @param unknown $sender * @param unknown $param * * @throws Exception * */ public function saveOrder($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $customer = Customer::get(trim($param->CallbackParameter->customer->id)); if (!$customer instanceof Customer) { throw new Exception('Invalid Customer passed in!'); } if (!isset($param->CallbackParameter->status) || ($status = trim($param->CallbackParameter->status)) === '' || !in_array($status, RMA::getAllStatuses())) { throw new Exception('Invalid Status passed in!'); } if (isset($param->CallbackParameter->RMA) && !($RMA = RMA::get(trim($param->CallbackParameter->RMA->id))) instanceof RMA) { throw new Exception('Invalid RMA To passed in!'); } $RMA = isset($param->CallbackParameter->RMA) && ($RMA = RMA::get(trim($param->CallbackParameter->RMA->id))->setDescription(trim($param->CallbackParameter->description))) instanceof RMA ? $RMA : RMA::create($customer, trim($param->CallbackParameter->description)); if (isset($param->CallbackParameter->order) && ($order = Order::get(trim($param->CallbackParameter->order->id))) instanceof Order) { $RMA->setOrder($order); } if (isset($param->CallbackParameter->shippingAddr)) { $shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo, $param->CallbackParameter->shippingAddr->companyName); $customer->setShippingAddress($shippAddress); } $printItAfterSave = false; if (isset($param->CallbackParameter->printIt)) { $printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false; } if (isset($param->CallbackParameter->comments)) { $comments = trim($param->CallbackParameter->comments); $RMA->addComment($comments, Comments::TYPE_SALES); } $totalPaymentDue = 0; foreach ($param->CallbackParameter->items as $item) { $product = Product::get(trim($item->product->id)); if (!$product instanceof Product) { throw new Exception('Invalid Product passed in!'); } $unitPrice = trim($item->unitPrice); $qtyOrdered = trim($item->qtyOrdered); $totalPrice = trim($item->totalPrice); $itemDescription = trim($item->itemDescription); $active = trim($item->valid); $totalPaymentDue += $totalPrice; if (is_numeric($item->RMAItemId) && !RMAItem::get(trim($item->RMAItemId)) instanceof RMAItem) { throw new Exception('Invalid RMA Item passed in'); } $RMAItem = is_numeric($item->RMAItemId) ? RMAItem::get(trim($item->RMAItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setItemDescription($itemDescription) : RMAItem::create($RMA, $product, $qtyOrdered, $itemDescription); if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) { $RMAItem->setOrderItem($orderItem)->setUnitCost($orderItem->getUnitCost()); } if (isset($item->RMAItemId) && ($RMAItem = RMAItem::get(trim($item->RMAItemId))) instanceof RMAItem && $product->getUnitCost() != 0) { $RMAItem->setUnitCost($RMAItem->getUnitCost())->save(); } else { $RMAItem->setUnitCost($product->getUnitCost())->save(); } $RMAItem->save(); } $RMA->setTotalValue($totalPaymentDue)->setStatus($status)->save(); $results['item'] = $RMA->getJson(); // if($printItAfterSave === true) // $results['printURL'] = '/print/rma/' . $RMA->getId() . '.html?pdf=1'; Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); // $errors[] = $ex->getMessage(); $errors[] = $ex->getTraceAsString(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
$client->c_middle_name = $c_middle_name; $client->c_last_name = $c_last_name; $client->c_age = $c_age; $client->c_email = $c_email; $client->c_contact_cellphone = $c_contact_cellphone; $client->c_contact_telephone = $c_contact_telephone; if ($client->create()) { $client_id = $database->insert_id(); } $address = new Address(); $address->c_id = $client_id; $address->addressline = $addressline; $address->city = $city; $address->stateprovince = $stateprovince; $address->countryregion = $countryregion; if ($address->create()) { redirect_to('index.php'); } } else { $c_first_name = ""; $c_middle_name = ""; $c_last_name = ""; $c_age = ""; $c_email = ""; $contact_cellphone = ""; $contact_telephone = ""; //Address $addressline = ""; $city = ""; $stateprovince = ""; $countryregion = "";
/** * Edits a user * @var User * @return \Illuminate\Http\RedirectResponse */ public function postEdit(User $user) { $oldUser = clone $user; $user->username = Input::get('username'); $user->email = Input::get('email'); $user->phone_number = Input::get('phone_number'); $password = Input::get('password'); $passwordConfirmation = Input::get('password_confirmation'); if (!empty($password)) { if ($password != $passwordConfirmation) { // Redirect to the new user page $error = Lang::get('admin/users/messages.password_does_not_match'); return Redirect::to('user')->with('error', $error); } else { $user->password = $password; $user->password_confirmation = $passwordConfirmation; } } $data = array('city_id' => Input::get('city_id'), 'address' => Input::get('address')); if ($user->address_id) { Address::where('id', $user->address_id)->update($data); } else { $address = Address::create($data); $user['address_id'] = $address->id; } if ($this->userRepo->save($user)) { return Redirect::to('user/profile/' . $user->username)->with('success', Lang::get('user/user.user_account_updated')); } else { $error = $user->errors()->all(':message'); return Redirect::to('user')->withInput(Input::except('password', 'password_confirmation'))->with('error', $error); } }
/** * (non-PHPdoc) * @see DetailsPageAbstract::saveItem() */ public function saveItem($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); $name = trim($param->CallbackParameter->name); $id = !is_numeric($param->CallbackParameter->id) ? '' : trim($param->CallbackParameter->id); $active = !is_numeric($param->CallbackParameter->id) ? '' : trim($param->CallbackParameter->active); $email = trim($param->CallbackParameter->email); $contactNo = trim($param->CallbackParameter->contactNo); $billingCompanyName = trim($param->CallbackParameter->billingCompanyName); $billingName = trim($param->CallbackParameter->billingName); $billingContactNo = trim($param->CallbackParameter->billingContactNo); $billingStreet = trim($param->CallbackParameter->billingStreet); $billingCity = trim($param->CallbackParameter->billingCity); $billingState = trim($param->CallbackParameter->billingState); $billingCountry = trim($param->CallbackParameter->billingCountry); $billingPostcode = trim($param->CallbackParameter->billingPosecode); $shippingCompanyName = trim($param->CallbackParameter->shippingCompanyName); $shippingName = trim($param->CallbackParameter->shippingName); $shippingContactNo = trim($param->CallbackParameter->shippingContactNo); $shippingStreet = trim($param->CallbackParameter->shippingStreet); $shippingCity = trim($param->CallbackParameter->shippingCity); $shippingState = trim($param->CallbackParameter->shippingState); $shippingCountry = trim($param->CallbackParameter->shippingCountry); $shippingPosecode = trim($param->CallbackParameter->shippingPosecode); if (is_numeric($param->CallbackParameter->id)) { $customer = Customer::get(trim($param->CallbackParameter->id)); if (!$customer instanceof Customer) { throw new Exception('Invalid Customer passed in!'); } $customer->setName($name)->setEmail($email)->setContactNo($contactNo)->setActive($active); $billingAddress = $customer->getBillingAddress(); if ($billingAddress instanceof Address) { $billingAddress->setStreet($billingStreet)->setCity($billingCity)->setRegion($billingState)->setCountry($billingCountry)->setPostCode($billingPostcode)->setContactName($billingName)->setContactNo($billingContactNo)->setCompanyName($billingCompanyName)->save(); } else { if (trim($billingStreet) !== '' || trim($billingCity) !== '' || trim($billingState) !== '' || trim($billingCountry) !== '' || trim($billingPostcode) !== '' || trim($billingName) !== '' || trim($billingContactNo) !== '' || trim($billingCompanyName) !== '') { $customer->setBillingAddress(Address::create($billingStreet, $billingCity, $billingState, $billingCountry, $billingPostcode, $billingName, $billingContactNo, $billingCompanyName)); } } $shippingAddress = $customer->getShippingAddress(); if ($shippingAddress instanceof Address && $billingAddress instanceof Address && $shippingAddress->getId() !== $billingAddress->getId()) { $shippingAddress->setStreet($shippingStreet)->setCity($shippingCity)->setRegion($shippingState)->setCountry($shippingCountry)->setPostCode($shippingPosecode)->setContactName($shippingName)->setContactNo($shippingContactNo)->setCompanyName($shippingCompanyName)->save(); } else { if (trim($shippingStreet) !== '' || trim($shippingCity) !== '' || trim($shippingState) !== '' || trim($shippingCountry) !== '' || trim($shippingPosecode) !== '' || trim($shippingName) !== '' || trim($shippingContactNo) !== '' || trim($shippingCompanyName) !== '') { $customer->setShippingAddress(Address::create($shippingStreet, $shippingCity, $shippingState, $shippingCountry, $shippingPosecode, $shippingName, $shippingContactNo, $shippingCompanyName)); } } $customer->save(); } else { if (trim($billingStreet) === '' && trim($billingCity) === '' && trim($billingState) === '' && trim($billingCountry) === '' && trim($billingPostcode) === '' && trim($billingName) === '' && trim($billingContactNo) === '' && trim($billingCompanyName) === '') { $billingAdressFull = null; } else { $billingAdressFull = Address::create($billingStreet, $billingCity, $billingState, $billingCountry, $billingPostcode, $billingName, $billingContactNo, $billingCompanyName); } if (trim($shippingStreet) === '' && trim($shippingCity) === '' && trim($shippingState) === '' && trim($shippingCountry) === '' && trim($shippingPosecode) === '' && trim($shippingName) === '' && trim($shippingContactNo) === '' && trim($shippingCompanyName) === '') { $shippingAdressFull = null; } else { $shippingAdressFull = Address::create($shippingStreet, $shippingCity, $shippingState, $shippingCountry, $shippingPosecode, $shippingName, $shippingContactNo, $shippingCompanyName); } $customer = Customer::create($name, $contactNo, $email, $billingAdressFull, false, '', $shippingAdressFull); if (!$customer instanceof Customer) { throw new Exception('Error creating customer!'); } } $results['url'] = '/customer/' . $customer->getId() . '.html'; $results['item'] = $customer->getJson(); Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage() . $ex->getTraceAsString(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
/** * Store a newly created resource in storage. * * @return Response */ public function storeAddress() { // Validate the inputs $validator = Validator::make(Input::all(), Address::$rules); // Check if the form validates with success if ($validator->passes()) { // Get the inputs, with some exceptions $data = Input::except('csrf_token'); if (Address::create($data)) { // Redirect to the new country page return Redirect::to('address')->with('success', Lang::get('site/address/messages.create.success')); } // Redirect to the new country page return Redirect::to('address/create')->with('error', Lang::get('site/address/messages.create.error')); } // Form validation failed return Redirect::to('address/create')->withInput()->withErrors($validator); }
/** * Update the address * * @param unknown $sender * @param unknown $param * * @throws Exception */ public function updateAddress($sender, $param) { $results = $errors = array(); try { Dao::beginTransaction(); if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) { throw new Exception('System Error: invalid order provided!'); } if (!isset($param->CallbackParameter->id)) { throw new Exception('System Error: invalid address provided!'); } if (!isset($param->CallbackParameter->type) || ($type = trim($param->CallbackParameter->type)) === '') { throw new Exception('System Error: invalid address type provided!'); } $getter = 'get' . ucfirst($type) . 'Addr'; $address = $order->{$getter}(); $originalAddressFull = $address instanceof Address ? $address->getFull() : ''; $address = Address::create(trim($param->CallbackParameter->street), trim($param->CallbackParameter->city), trim($param->CallbackParameter->region), trim($param->CallbackParameter->country), trim($param->CallbackParameter->postCode), trim($param->CallbackParameter->contactName), trim($param->CallbackParameter->contactNo), trim($param->CallbackParameter->companyName), $address); if ($address instanceof Address) { $setter = 'set' . ucfirst($type) . 'Addr'; $msg = 'Changed ' . trim($param->CallbackParameter->title) . ' from "' . $originalAddressFull . '" to "' . $address->getFull() . '"'; $order->{$setter}($address)->save()->addComment($msg, Comments::TYPE_NORMAL)->addLog($msg, Log::TYPE_SYSTEM); $address->addLog($msg, Log::TYPE_SYSTEM, '', __CLASS__ . '::' . __FUNCTION__); $results['item'] = $address->getJson(); } else { $results['item'] = array(); } Dao::commitTransaction(); } catch (Exception $ex) { Dao::rollbackTransaction(); $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
public function setData(Order $order, array $data) { if (!isset($data['Use'])) { parent::setData($order, $data); return; } $member = Member::currentUser() ?: $order->Member(); if (strpos($data['Use'], 'address-') === 0) { $address = Address::get()->byID(substr($data['Use'], 8)); if (!$address) { throw new ValidationException('That address does not exist'); } if (isset($data[$data['Use']]) && isset($data[$data['Use']]['saveAsNew']) && $data[$data['Use']]['saveAsNew']) { if (!$address->canCreate()) { throw new ValidationException('You do not have permission to add a new address'); } $address = $address->duplicate(); } else { if (isset($data[$data['Use']]) && !$address->canEdit() && $address->MemberID != $member->ID) { throw new ValidationException('You do not have permission to use this address'); } } } else { if (!singleton('Address')->canCreate()) { throw new ValidationException('You do not have permission to add a new address'); } $address = Address::create(); } if (isset($data[$data['Use']])) { $address->castedUpdate($data[$data['Use']]); // FIX for missing name fields $fields = array_intersect_key($data, array_flip(['FirstName', 'Surname', 'Name', 'Email'])); foreach ($fields as $field => $value) { if (!$address->{$field}) { $address->{$field} = $value; } } if ($country = ShopConfig::current()->SingleCountry) { $address->Country = $country; } if ($this->addtoaddressbook) { $address->MemberID = $member->ID; } $address->write(); if (isset($data[$data['Use']]['useAsDefaultShipping']) && $data[$data['Use']]['useAsDefaultShipping']) { $member->DefaultShippingAddressID = $address->ID; } if (isset($data[$data['Use']]['useAsDefaultBilling']) && $data[$data['Use']]['useAsDefaultBilling']) { $member->DefaultBillingAddressID = $address->ID; } if ($member->isChanged()) { $member->write(); } } if ($address->exists()) { if ($this->addresstype === 'Shipping') { ShopUserInfo::singleton()->setAddress($address); Zone::cache_zone_ids($address); } $order->{$this->addresstype . 'AddressID'} = $address->ID; if (!$order->BillingAddressID) { $order->BillingAddressID = $address->ID; } $order->write(); $order->extend('onSet' . $this->addresstype . 'Address', $address); } }
/** * Create a new address using post array data * * @param array $data * @return object $address or null */ public function createAddress($data = null) { if (is_null($data)) { $data = \Input::all(); } if (Auth::user()->check()) { $address = Address::where($data)->first(); if ($address) { return $address; } } return Address::create($data); }
exit; } if ($action == 'add' || $action == 'update') { $object->socid = $socid; $object->label = $_POST["label"] != $langs->trans('RequiredField') ? $_POST["label"] : ''; $object->name = $_POST["name"] != $langs->trans('RequiredField') ? $_POST["name"] : ''; $object->address = $_POST["address"]; $object->zip = $_POST["zipcode"]; $object->town = $_POST["town"]; $object->country_id = $_POST["country_id"]; $object->phone = $_POST["phone"]; $object->fax = $_POST["fax"]; $object->note = $_POST["note"]; // Add new address if ($action == 'add') { $result = $object->create($socid, $user); if ($result >= 0) { if (!empty($backtopage)) { header("Location: " . $backtopage); exit; } else { if ($origin == 'commande') { header("Location: ../commande/contact.php?action=editdelivery_adress&socid=" . $socid . "&id=" . $originid); exit; } elseif ($origin == 'propal') { header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=" . $socid . "&id=" . $originid); exit; } elseif ($origin == 'shipment') { header("Location: ../expedition/fiche.php?id=" . $originid); exit; } else {
public function run() { Address::create(['user_id' => 1, 'line_1' => '160 Rothbury Terrace', 'line_2' => '', 'city' => 'Newcastle', 'postcode' => 'NE6 5DD', 'country' => 'England']); }
/** * Creating an address ojbect from Magento * * @param stdClass $addressObj The stdclass of the address object * * @return Address */ private function _createAddr($addressObj, &$exsitAddr = null) { return Address::create(isset($addressObj->street) ? preg_replace('/\\s+/', ', ', trim($addressObj->street)) : '', trim(isset($addressObj->city) ? trim($addressObj->city) : ''), isset($addressObj->region) ? trim($addressObj->region) : '', trim(isset($addressObj->country_id) ? trim($addressObj->country_id) : ''), trim(isset($addressObj->postcode) ? trim($addressObj->postcode) : ''), trim(trim(isset($addressObj->firstname) ? trim($addressObj->firstname) : '') . ' ' . trim(isset($addressObj->lastname) ? trim($addressObj->lastname) : '')), trim(isset($addressObj->telephone) ? trim($addressObj->telephone) : ''), trim(isset($addressObj->company) ? trim($addressObj->company) : ''), $exsitAddr); }
if (isset($_POST["lat"]) && isset($_POST["lng"])) { $lat = strip_tags($_POST["lat"]); $lng = strip_tags($_POST["lng"]); } if (isset($_POST["placeId"])) { $placeId = strip_tags($_POST["placeId"]); } if (isset($_POST["phone"])) { $phone = strip_tags($_POST["phone"]); } if (isset($_POST["list"]) && !empty($_POST["list"])) { $list = strip_tags($_POST["list"]); $addressList->create($name, $list); } // Création de l'adresse avec la catégorie correspondante $address->create($categorie, $location, $name, $lat, $lng, $phone, $placeId); } } } } else { if (isset($_POST["phone"]) && isset($_POST["newname"]) && isset($_POST["newcategorie"])) { $phone = strip_tags($_POST["phone"]); $addressName = strip_tags($_POST["name"]); $addressNewName = strip_tags($_POST["newname"]); $categorieName = strip_tags($_POST["categorie"]); $newCategorieName = strip_tags($_POST["newcategorie"]); if (!empty($addressNewName) and (strlen($addressNewName) < 3 or strlen($addressNewName) > 50)) { echo "errorCharNewName"; } else { if (!empty($phone) and (strlen($phone) < 3 or strlen($phone) > 30)) { echo "errorCharNewPhone";