public static function formData($id = null) { global $lC_Database, $lC_Language, $_module; $lC_Language->loadIniFile('customers.php'); $result = array(); $Qgroups = $lC_Database->query('select customers_group_id, customers_group_name from :table_customers_groups where language_id = :language_id order by customers_group_name'); $Qgroups->bindTable(':table_customers_groups', TABLE_CUSTOMERS_GROUPS); $Qgroups->bindInt(':language_id', $lC_Language->getID()); $Qgroups->execute(); $groups_array = array(); while ($Qgroups->next()) { $groups_array[$Qgroups->value('customers_group_id')] = $Qgroups->value('customers_group_name'); } $result['groupsArray'] = $groups_array; if ($id != null) { $result['customerData'] = lC_Customers_Admin::getData($id); $Qaddresses = lC_Customers_Admin::getAddressBookData($id); $cnt = 0; $result['addressBook'] = ''; $body .= '<ul class="list spaced">'; while ($Qaddresses->next()) { $primary = $result['customerData']['customers_default_address_id'] == $Qaddresses->valueInt('address_book_id') ? 'true' : 'false'; $body .= '<li class="">'; $body .= '<span class="button-group compact float-right">' . ' <a href="' . ((int) ($_SESSION['admin']['access'][$_module] < 3) ? '#' : 'javascript://" onclick="editAddress(\'' . $Qaddresses->valueInt('address_book_id') . '\', \'' . $primary . '\')') . '" class="button icon-pencil' . ((int) ($_SESSION['admin']['access'][$_module] < 3) ? ' disabled' : NULL) . '">' . $lC_Language->get('icon_edit') . '</a>' . ' <a href="' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? '#' : 'javascript://" onclick="deleteAddress(\'' . $Qaddresses->valueInt('address_book_id') . '\')') . '" class="button icon-trash with-tooltip' . ((int) ($_SESSION['admin']['access'][$_module] < 4) ? ' disabled' : NULL) . '" title="' . $lC_Language->get('icon_delete') . '"></a>' . '</span>'; if (ACCOUNT_GENDER > -1) { switch ($Qaddresses->value('gender')) { case 'm': $body .= '<span>' . lc_icon_admin('male.png') . '</span>'; break; case 'f': $body .= '<span>' . lc_icon_admin('female.png') . '</span>'; break; default: $body .= '<span>' . lc_icon_admin('people.png') . '</span>'; break; } } else { $body .= '<span>' . lc_icon_admin('people.png') . '</span>'; } $body .= '<span class="small-margin-left">' . lC_Address::format($Qaddresses->toArray(), ' <br /> ') . '</span>'; if ($primary == 'true') { $body .= '<small class="tag small-margin-left purple-gradient glossy" style="position:absolute; top:12px; right:88px;">' . $lC_Language->get('primary_address') . '</small>'; } $body .= '<span class="icon-phone icon-blue" style="position:absolute; top:17px; left:200px;">'; if (!lc_empty($Qaddresses->valueProtected('telephone_number'))) { $body .= $Qaddresses->valueProtected('telephone_number'); } else { $body .= '<small class="tag silver-gradient glossy"><i>' . $lC_Language->get('no_telephone_number') . '</i></small>'; } $body .= '</span>'; $body .= '<span class="icon-printer icon-orange" style="position:absolute; top:46px; left:200px;">'; if (!lc_empty($Qaddresses->valueProtected('fax_number'))) { $body .= $Qaddresses->valueProtected('fax_number'); } else { $body .= '<small class="tag silver-gradient glossy"><i>' . $lC_Language->get('no_fax_number') . '</i></small>'; } $body .= '</span>'; $body .= '</li>'; $cnt++; } $body .= '</ul>'; $result['addressBook'] = $body; // set default country to store country $country_id = STORE_COUNTRY; $Qzones = $lC_Database->query('select zone_name from :table_zones where zone_country_id = :zone_country_id order by zone_name'); $Qzones->bindTable(':table_zones', TABLE_ZONES); $Qzones->bindInt(':zone_country_id', $country_id); $Qzones->execute(); $zones_array = array(); while ($Qzones->next()) { $zones_array[] = array('id' => $Qzones->value('zone_name'), 'text' => $Qzones->value('zone_name')); } $result['abState'] = lc_draw_pull_down_menu('ab_state', $zones_array, null, 'class="input with-small-padding" style="width:73%;"'); } $countries_array = array(); foreach (lC_Address::getCountries() as $country) { $countries_array[$country['id']] = $country['name']; } $result['countriesArray'] = $countries_array; return $result; }
public static function getAddressEntry() { $result = lC_Customers_Admin::getAddressBookData((int) $_GET['cid'], (int) $_GET['abid']); $result['rpcStatus'] = RPC_STATUS_SUCCESS; echo json_encode($result); }