$name = $_POST['name']; $surname = $_POST['surname']; $street = $_POST['street']; $number = $_POST['number']; $postalcode = $_POST['postalcode']; $city = $_POST['city']; if (isset($_POST['ccn'])) { $ccn = $_POST['ccn']; } else { $ccn = NULL; } if (isset($_POST['phone_number_1'])) { $phone_number_1 = $_POST['phone_number_1']; } else { $phone_number_1 = NULL; } if (isset($_POST['phone_number_2'])) { $phone_number_2 = $_POST['phone_number_2']; } else { $phone_number_2 = NULL; } $exists = CustomerExists($at); if (!$exists) { $customer_id = AddCustomer($at, $name, $surname, $street, $number, $postalcode, $city, $ccn, $phone_number_1, $phone_number_2); header('Location: customers_add.php?success=true'); } else { header('Location: customers_add.php?exists=true'); } } else { header('Location: customers_add.php?missing=true'); }
/** * Edit a customer page * * Method will construct the edit customer page * * @access public * @param string $MsgDesc The optional message to display * @param string $MsgStatus The optional status of the message * @param bool $PreservePost TRUE to use the REQUEST variable, FALSE to read from the database. Default is FALSE * @return Void */ public function EditCustomerStep1($MsgDesc = "", $MsgStatus = "", $PreservePost=false) { if ($MsgDesc != "") { $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus); } $flashMessages = GetFlashMessages(); if(is_array($flashMessages) && !empty($flashMessages)) { $GLOBALS['Message'] = ''; foreach($flashMessages as $flashMessage) { $GLOBALS['Message'] .= MessageBox($flashMessage['message'], $flashMessage['type']); } } // Show the form to edit a customer $customerId = isc_html_escape((int)$_GET['customerId']); // Make sure the customer exists if (!CustomerExists($customerId)) { // The customer doesn't exist if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Edit_Customers)) { $this->ManageCustomers(GetLang('CustomerDoesntExist'), MSG_ERROR); } else { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR); } return; } if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Add_Customer)) { $GLOBALS['CustomerAddressAddDisabled'] = 'DISABLED'; } if (!$GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Delete_Customers)) { $GLOBALS['CustomerAddressDeleteDisabled'] = 'DISABLED'; } if (GetConfig('CurrencyLocation') == 'right') { $GLOBALS['CurrencyTokenLeft'] = ''; $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken'); } else { $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken'); $GLOBALS['CurrencyTokenRight'] = ''; } if ($PreservePost == true) { $customer = $this->_GetCustomerData(0); } else { $customer = $this->_GetCustomerData($customerId); } if (isset($_REQUEST['currentTab'])) { $GLOBALS['CurrentTab'] = (int)$_REQUEST['currentTab']; } else { $GLOBALS['CurrentTab'] = 0; } $query = "SELECT * FROM [|PREFIX|]shipping_addresses WHERE shipcustomerid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int)$customerId) . "'"; if ($GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['ISC_CLASS_DB']->Query($query))) { $GLOBALS['CustomerAddressEmptyShow'] = 'none'; } else { $GLOBALS['CustomerAddressEmptyHide'] = 'none'; } $GLOBALS['FormAction'] = "editCustomer2"; $GLOBALS['CustomerId'] = $customerId; $GLOBALS['Title'] = GetLang('EditCustomerTitle'); $GLOBALS['Intro'] = GetLang('EditCustomerIntro'); $GLOBALS['CustomerAddressListWarning'] = GetLang('CustomerAddressNoAddresses'); $GLOBALS['CustomerFirstName'] = $customer['custconfirstname']; $GLOBALS['CustomerLastName'] = $customer['custconlastname']; $GLOBALS['CustomerCompany'] = $customer['custconcompany']; $GLOBALS['CustomerEmail'] = $customer['custconemail']; $GLOBALS['CustomerPhone'] = $customer['custconphone']; $GLOBALS['CustomerStoreCredit'] = FormatPrice($customer['custstorecredit'], false, false); $GLOBALS['CustomerGroupId'] = $customer['custgroupid']; $GLOBALS['CustomerGroupOptions'] = $this->GetCustomerGroupsAsOptions($customer['custgroupid']); $GLOBALS['CustomerShippingAddressGrid'] = $this->ManageCustomerAddressGrid(); $GLOBALS['PasswordRequired'] = ' '; $GLOBALS['PasswordLabel'] = GetLang('CustomerNewPassword'); $GLOBALS['PasswordHelp'] = GetLang('CustomerNewPasswordHelp'); $GLOBALS['PasswordConfirmHelp'] = GetLang('CustomerNewPasswordConfirmHelp'); $GLOBALS['PasswordConfirmError'] = GetLang('CustomerNewPasswordConfirmError'); $GLOBALS['PasswordConfirmRequired'] = ' '; $GLOBALS['CustomFieldsAccountFormId'] = FORMFIELDS_FORM_ACCOUNT; $GLOBALS['CustomFields'] = ''; /** * Custom fields */ if (gzte11(ISC_MEDIUMPRINT)) { if ($PreservePost) { $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, true); } else if (isset($customer['custformsessionid']) && isId($customer['custformsessionid'])) { $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, false, $customer['custformsessionid']); } else { $fields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT); } foreach (array_keys($fields) as $fieldId) { if ($fields[$fieldId]->record['formfieldprivateid'] !== '') { continue; } $GLOBALS['CustomFields'] .= $fields[$fieldId]->loadForFrontend() . "\n"; } } /** * Add this to generate our JS event script */ $GLOBALS['FormFieldEventData'] = $GLOBALS['ISC_CLASS_FORM']->buildRequiredJS(); $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndContinueEditing'); $GLOBALS['CancelMessage'] = GetLang('ConfirmCancelCustomer'); $this->template->display('customer.form.tpl'); }
/** * Does customer exists? * * Method will return TRUE/FLSE depending if the customer exists * * @access public * @param int $customerId The customer ID * @return bool TRUE if the customer exists, FALASE otherwise */ public function exists($customerId) { if (!isId($customerId) || !CustomerExists($customerId)) { return false; } return true; }