/** * Display a phone number as a hyperlink with the tel protocol * * @param string $value The number to display. * * @return string */ public static function phoneUrl($value) { if (empty($value)) { return ''; } $plainValue = preg_replace('/[^0-9x\\#*]/', null, $value); try { $formattedValue = phone_format($plainValue, 'US'); } catch (Exception $e) { $formattedValue = $plainValue; } return sprintf('<a href="tel://%s">%s</a>', $plainValue, $formattedValue); }
public function run() { // we remove all the files in the config folder $files = glob(storage_path('app/settings/*')); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } // we create the folder if it doesn't exist if (!is_dir($storage_path = storage_path('app/settings'))) { if (!is_dir($path = storage_path('app'))) { mkdir($path); } mkdir($path . '/settings'); } $logo_dark = ImageManager::optimizeAndResize(database_path('seeds/files/settings/logo-una-dark.png'), config('image.settings.logo.name.dark'), config('image.settings.logo.extension'), config('image.settings.storage_path'), config('image.settings.logo.sizes'), false); $logo_light = ImageManager::optimizeAndResize(database_path('seeds/files/settings/logo-una-light.png'), config('image.settings.logo.name.light'), config('image.settings.logo.extension'), config('image.settings.storage_path'), config('image.settings.logo.sizes'), false); // we insert base settings $inputs = ['app_name_fr' => 'Club Université Nantes Aviron (UNA)', 'app_name_en' => 'Nantes University Rowing club', 'app_slogan_fr' => 'Le plus grand club universitaire de France.', 'app_slogan_en' => 'The biggest university rowing club from France.', 'breadcrumbs' => true, 'multilingual' => false, 'phone_number' => phone_format('0954014810', 'FR', PhoneNumberFormat::INTERNATIONAL), 'contact_email' => '*****@*****.**', 'support_email' => '*****@*****.**', 'address' => '2 rue de la Houssinière', 'zip_code' => '44300', 'city' => 'Nantes', 'rss' => true, 'loading_spinner' => '<i class="fa fa-spinner fa-spin"></i>', 'success_icon' => '<i class="fa fa-thumbs-up"></i>', 'error_icon' => '<i class="fa fa-thumbs-down"></i>', 'info_icon' => '<i class="fa fa-bullhorn"></i>', 'facebook' => 'https://www.facebook.com/UniversiteNantesAviron', 'twitter' => 'https://twitter.com/UNAClub', 'google_plus' => 'https://plus.google.com/+Univ-nantes-avironFr', 'youtube' => 'https://www.youtube.com/channel/UCOeYQGBxGMGqW-DyfK2fVCQ', 'logo_dark' => $logo_dark, 'logo_light' => $logo_light]; file_put_contents(storage_path('app/settings/settings.json'), json_encode($inputs)); // we place the default favicon File::copy(database_path('seeds/files/settings/favicon.ico'), public_path('favicon.ico')); }
?> </td> --> <td scope="row"><?php echo get_state($lt->cd_state); ?> </td> <td scope="row"><?php echo $lt->cd_name; ?> </td> <td scope="row"><?php echo phone_format($lt->cd_tel); ?> </td> <td scope="row"><?php echo phone_format($lt->cd_hp); ?> </td> <td scope="row"><?php echo $lt->cd_day_cnt; ?> +<?php echo $lt->cd_device_day_cnt; ?> /<?php echo $lt->cd_day_limit; ?> </td> </tr> <?php }
protected function formatPhone($phone_number) { $locale = strtoupper(app()->getLocale()); $phoneUtil = PhoneNumberUtil::getInstance(); try { $phone = $phoneUtil->parse($phone_number, $locale); $is_valid = $phoneUtil->isValidNumber($phone, $locale); if ($is_valid) { return phone_format($phone_number, $locale, PhoneNumberFormat::INTERNATIONAL); } else { return $phone_number; } } catch (Exception $e) { return $phone_number; } }
enum('NA', 'Not Required', 'Mortgage Arranged', 'Requires Mortgage') */ $db_data["cli_oldnotes"] = serialize($additional_requirements); $db_data["cli_method"] = 'Import'; // telephone numbers must be placed in tel table, and linked to current client $ord = 1; if (strlen($row["Tel"] > 3)) { $db_data_tel[$row["Client_ID"]][] = array('tel_number' => phone_format($row["Tel"]), 'tel_type' => 'Home', 'tel_cli' => $row["Client_ID"], 'tel_ord' => $ord); $ord++; } if (strlen($row["Fax"] > 3)) { $db_data_tel[$row["Client_ID"]][] = array('tel_number' => phone_format($row["Fax"]), 'tel_type' => 'Fax', 'tel_cli' => $row["Client_ID"], 'tel_ord' => $ord); $ord++; } if (strlen($row["Mobile"] > 3)) { $db_data_tel[$row["Client_ID"]][] = array('tel_number' => phone_format($row["Mobile"]), 'tel_type' => 'Mobile', 'tel_cli' => $row["Client_ID"], 'tel_ord' => $ord); $ord++; } $db_dimension[$counter]["client"] = $db_data; $db_dimension[$counter]["tel"] = $db_data_tel; unset($db_data, $db_data_tel); #print_r($db_data); $counter++; } } // inserting into new table require_once "../inx/db.inc.php"; require_once "../inx/postcode.inc.php"; require_once "../inx/postcode.class.inc.php"; foreach ($db_dimension as $key => $values) { // decided to skip part-names, so anything with a ? is now ignored
function convert_field($value, $datatype = '') { //echo "BEFORE: ".$value."\n"; $value = trim($value); if ($datatype == 'phone') { $value = phone_format($value); } else { if ($datatype == 'date') { $value = mysql_date($value); } else { if ($datatype == 'time') { $value = mysql_time($value); } else { if ($datatype == 'int') { if ($value || $value === 0 || $value === "0") { $value = intval($value); } else { $value = NULL; } } else { if ($datatype == 'float') { if ($value || $value === 0) { $value = floatval($value); } else { $value = NULL; } } else { if ($datatype == 'double') { if ($value || $value === 0) { $value = doubleval($value); } else { $value = NULL; } } else { if ($datatype == 'url') { $value = prep_url($value); } } } } } } } //echo "AFTER: ".$value." DATATYPE: ".$datatype."\n"; return $value; }
$db_data['tel_type'] = $_POST["tel" . $tel_count . "type"]; $db_data['tel_con'] = $con_id; db_query($db_data, "UPDATE", "tel", "tel_id", $val['id']); } } } // check if new phone has been entrered // new phones perhaps should go at the top, reordering the rest down by 1 ? for the time being, they are put at the bottom if ($telephone) { $ord = count($telephone) + 1; } else { $ord = 1; } if ($_POST["telnew"]) { if (phone_validate($_POST["telnew"])) { $db_data = array('tel_number' => phone_format($_POST["telnew"]), 'tel_type' => $_POST["telnewtype"], 'tel_con' => $con_id, 'tel_ord' => $ord); db_query($db_data, "INSERT", "tel", "tel_id"); unset($db_data); } else { $errors[] = 'Please enter a valid phone number'; } } } elseif ($_POST["form2"]) { $viewForm = 2; // addresses from postcode lookup will already be stored in table, and will provide pro_pro_id // this needs to be stored in the link table pro2cli if ($_POST["pro_pro_id"]) { $pro_id = $_POST["pro_pro_id"]; $db_data["p2c_pro"] = $pro_id; $db_data["p2c_con"] = $_POST["con_id"]; $db_data["p2c_type"] = $_POST["p2c_type"];
function save_call($external_input) { global $version, $client_db; $input = new ClientCard(); $input = $external_input; if (!is_session_alive($input->session_id)) { return -1; } $number = phone_format(preg_replace("/[^0-9]/", "", $input->input_number)); $number1 = phone_format(preg_replace("/[^0-9]/", "", $input->phone1)); $number2 = phone_format(preg_replace("/[^0-9]/", "", $input->phone2)); $number3 = phone_format(preg_replace("/[^0-9]/", "", $input->phone3)); $number4 = phone_format(preg_replace("/[^0-9]/", "", $input->fax)); if (trim($number) == '') { return -3; } $search_phone = debugging_values("SELECT id FROM `" . $client_db . "`.`clients" . $version . "` WHERE (main_number LIKE '" . $number . "' OR phone1 LIKE '" . $number . "' OR phone2 LIKE '" . $number . "' OR phone3 LIKE '" . $number . "' OR fax LIKE '" . $number . "')", 1, 1); if (count($search_phone) == 0) { debugging_values("INSERT INTO `" . $client_db . "`.`clients" . $version . "`(`id`, `name`, `contact`, `city`, `adress`, `phone1`, `phone2`, `phone3`, `fax`, `emails`, `dopinfo`, `creation_date`, `last_call`, `info`, `main_number`,\n\t\t`client_id`, `agreement_num`, `agreement_type`, `agreement_beg`, `agreement_end`, `discount_ins`, `discount_mat`, `internal`, `client_code`, `ttk`)\n VALUES (NULL, '" . mysql_escape_string($input->client_name) . "', '" . mysql_escape_string($input->contact_name) . "',\n '" . mysql_escape_string($input->city) . "', '" . mysql_escape_string($input->adress) . "',\n '" . str_replace('%', '', $number1) . "', '" . str_replace('%', '', $number2) . "', '" . str_replace('%', '', $number3) . "', '" . str_replace('%', '', $number4) . "',\n '" . mysql_escape_string($input->emails) . "', '" . mysql_escape_string($input->dopinfo) . "',\n NOW(), NOW(), 1, '" . str_replace('%', '', $number) . "',\n '" . mysql_escape_string($input->client_id) . "', '" . mysql_escape_string($input->agreement_num) . "',\n '" . mysql_escape_string($input->agreement_type) . "', '" . mysql_escape_string($input->agreement_beg) . "',\n '" . mysql_escape_string($input->agreement_end) . "', '" . mysql_escape_string($input->discount_ins) . "',\n '" . mysql_escape_string($input->discount_mat) . "', '0', \n '" . mysql_escape_string($input->client_code) . "', '" . mysql_escape_string($input->ttk) . "')", 1, 1); $client_id = mysql_insert_id(); if (mysql_errno()) { return -5; } } else { $client_id = $search_phone[0]['id']; debugging_values("UPDATE `" . $client_db . "`.`clients" . $version . "` SET\n\t\t name = '" . mysql_escape_string($input->client_name) . "',\n\t\t contact = '" . mysql_escape_string($input->contact_name) . "',\n\t\t city = '" . mysql_escape_string($input->city) . "',\n\t\t adress = '" . mysql_escape_string($input->adress) . "',\n\t\t phone1 = '" . str_replace('%', '', $number1) . "',\n\t\t phone2 = '" . str_replace('%', '', $number2) . "',\n\t\t phone3 = '" . str_replace('%', '', $number3) . "',\n\t\t fax = '" . str_replace('%', '', $number4) . "',\n\t\t emails = '" . mysql_escape_string($input->emails) . "',\n\t\t dopinfo = '" . mysql_escape_string($input->dopinfo) . "',\n\t\t last_call = NOW(),\n\t\t client_id = '" . mysql_escape_string($input->client_id) . "',\n\t\t agreement_num = '" . mysql_escape_string($input->agreement_num) . "',\n\t\t agreement_type = '" . mysql_escape_string($input->agreement_type) . "',\n\t\t agreement_beg = '" . mysql_escape_string($input->agreement_beg) . "',\n\t\t agreement_end = '" . mysql_escape_string($input->agreement_end) . "',\n\t\t discount_ins = '" . mysql_escape_string($input->discount_ins) . "',\n\t\t discount_mat = '" . mysql_escape_string($input->discount_mat) . "',\n\t\t client_code = '" . mysql_escape_string($input->client_code) . "',\n\t\t ttk = '" . mysql_escape_string($input->ttk) . "'\n\t\t WHERE (main_number LIKE '" . $number . "' OR phone1 LIKE '" . $number . "' OR phone2 LIKE '" . $number . "' OR phone3 LIKE '" . $number . "' OR fax LIKE '" . $number . "')", 1, 1); } $uid = debugging_values("SELECT unique_id FROM `" . $client_db . "`.`calls_temp` WHERE number LIKE '" . mysql_escape_string($input->input_number) . "' ORDER BY id DESC LIMIT 1", 1, 1); if (count($uid) == 0) { $unique_id = ''; } else { $unique_id = $uid[0]['unique_id']; } debugging_values("INSERT INTO `" . $client_db . "`.`calls" . $version . "` (`id`, `client_id`, `call_date`, `comment`, `operator`, `unique_id`) VALUES\n\t (NULL,\n\t '" . $client_id . "',\n\t NOW(),\n\t '" . mysql_escape_string($input->call_comment) . "',\n\t '" . mysql_escape_string($input->operator) . "',\n\t '" . $unique_id . "')", 1, 1); if (mysql_errno()) { return -5; } else { return 0; } }
} $args = array('post_type' => 'locations', 'tax_query' => array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $slug)), 'orderby' => $orderby, 'order' => $order, 'nopaging' => true); $loop = new WP_Query($args); ?> <div class="row limited-width"> <?php while ($loop->have_posts()) { $loop->the_post(); ?> <?php $todayIs = strtolower(date('l')); $nowTime = strtotime(date('H:i')); // Format the phone number $phone = phone_format(get_field('phone')); // Split up the tags field $tags = explode(',', get_field('tags')); $number_tags = count($tags); ?> <?php /* Add tags as class to the location box for filtering with JS */ $theTags = get_field('tags'); $tagClasses = strtolower(preg_replace('/[\\s]/', '', $theTags)); $tagClasses = preg_replace('[,]', ' ', $tagClasses); $status = get_field('status'); /* Possible Statuses: cool : Cool opening-soon : Opening Soon
public function update(Request $request) { // we check the current user permission if (!Permission::hasPermission('settings.update')) { // we redirect the current user to the settings view if he has the required permission if (Sentinel::getUser()->hasAccess('settings.view')) { return redirect()->route('settings.view'); } else { // or we redirect the current user to the home page return redirect()->route('dashboard.index'); } } // we clear the cache Artisan::call('cache:clear'); Artisan::call('config:clear'); // we sanitize the entries $request->replace(InputSanitizer::sanitize($request->all())); // if the boolean field is not given, we set it to false $request->merge(['breadcrumb' => $request->get('breadcrumb', false)]); $request->merge(['multilingual' => $request->get('multilingual', false)]); $request->merge(['rss' => $request->get('rss', false)]); // we get the inputs $inputs = $request->except('_token', '_method'); // we set the rules according to the multilingual config $rules = ['app_name_fr' => 'required|string', 'app_slogan_fr' => 'string', 'breadcrumbs' => 'boolean', 'multilingual' => 'boolean', 'phone_number' => 'phone:FR', 'contact_email' => 'required|email', 'support_email' => 'required|email', 'address' => 'string', 'zip_code' => 'digits:5', 'city' => 'string', 'facebook' => 'url', 'twitter' => 'url', 'google_plus' => 'url', 'youtube' => 'url', 'linkedin' => 'url', 'pinterest' => 'url', 'rss' => 'boolean', 'favicon' => 'mimes:ico|image_size:16,16', 'logo_light' => 'image|mimes:png|image_size:>=300,*', 'logo_dark' => 'image|mimes:png|image_size:>=300,*', 'loading_spinner' => 'string', 'success_icon' => 'string', 'error_icon' => 'string', 'info_icon' => 'string', 'google_analytics_script' => 'string', 'google_analytics_view_id' => 'numeric', 'google_analytics_json' => 'mimes:json']; if (config('settings.multilingual')) { $rules['app_name_en'] = 'required|string'; $rules['app_slogan_en'] = 'string'; } // we check the inputs validity if (!Validation::check($inputs, $rules)) { // we flash the request $request->flash(); return redirect()->back(); } // we save the settings try { // we format the number into its international equivalent if (isset($inputs['phone_number']) && !empty($inputs['phone_number'])) { $inputs['phone_number'] = $formatted_phone_number = phone_format($inputs['phone_number'], 'FR', PhoneNumberFormat::INTERNATIONAL); } // we put the favicon at the root of the project if ($favicon = $request->file('favicon')) { $favicon->move('./', 'favicon.ico'); } // logo light treatment if ($logo_light = $request->file('logo_light')) { // if a previous version of the image is found, we delete it if ($current_logo_light = config('settings.logo_light')) { ImageManager::remove($current_logo_light, config('image.settings.storage_path'), config('image.settings.logo.sizes')); } // we optimize, resize and save the image $file_name = ImageManager::optimizeAndResize($logo_light->getRealPath(), config('image.settings.logo.name.light'), $logo_light->getClientOriginalExtension(), config('image.settings.storage_path'), config('image.settings.logo.sizes')); // we add the image name to the inputs for saving $inputs['logo_light'] = $file_name; } elseif (config('settings.logo_light')) { $inputs['logo_light'] = config('settings.logo_light'); } // logo dark treatment if ($logo_dark = $request->file('logo_dark')) { // if a previous version of the image is found, we delete it if ($current_logo_dark = config('settings.logo_dark')) { ImageManager::remove($current_logo_dark, config('image.settings.storage_path'), config('image.settings.logo.sizes')); } // we optimize, resize and save the image $file_name = ImageManager::optimizeAndResize($logo_dark->getRealPath(), config('image.settings.logo.name.dark'), $logo_dark->getClientOriginalExtension(), config('image.settings.storage_path'), config('image.settings.logo.sizes')); // we add the image name to the inputs for saving $inputs['logo_dark'] = $file_name; } elseif (config('settings.logo_dark')) { $inputs['logo_dark'] = config('settings.logo_dark'); } // we create or replace the google analytics view id in the env file Env::createOrReplace('ANALYTICS_VIEW_ID', $inputs['google_analytics_view_id']); unset($inputs['google_analytics_view_id']); // google analytics credential json treatment if ($google_analytics_credentials_json = $request->file('google_analytics_credentials_json')) { // if a previous version of the file is found, we delete it if ($current_google_analytics_credentials_json = env('ANALYTICS_CREDENTIALS_JSON')) { FileManager::remove($current_google_analytics_credentials_json, config('file.settings.storage_path')); } // we save the file $file_name = FileManager::storeAndRename($google_analytics_credentials_json->getRealPath(), config('file.settings.google_analytics_credentials_json.name'), $google_analytics_credentials_json->getClientOriginalExtension(), config('file.settings.storage_path')); // we create or replace the google analytics credential json path in the env file Env::createOrReplace('ANALYTICS_CREDENTIALS_JSON', $file_name); unset($inputs['google_analytics_credentials_json']); } // we update the json file file_put_contents(storage_path('app/settings/settings.json'), json_encode($inputs)); // we notify the current user Modal::alert([trans('settings.message.update.success')], 'success'); // we renew the config cache if (config('app.env') !== 'local') { Artisan::call('route:cache'); Artisan::call('config:cache'); } return redirect()->back(); } catch (Exception $e) { // we flash the request $request->flash(); // we log the error CustomLog::error($e); // we notify the current user Modal::alert([trans('settings.message.update.failure'), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error'); // we renew the config cache Artisan::call('config:cache'); return redirect()->back(); } }
unset($db_data_tel); } if (strlen($row["WorkTelephone"] > 3)) { $db_data_tel = array('tel_number' => phone_format($row["WorkTelephone"]), 'tel_type' => 'Work', 'tel_cli' => $cli_id, 'tel_ord' => $ord); db_query($db_data_tel, "INSERT", "tel", "tel_id"); $ord++; unset($db_data_tel); } if (strlen($row["Facsimile"] > 3)) { $db_data_tel = array('tel_number' => phone_format($row["Facsimile"]), 'tel_type' => 'Fax', 'tel_cli' => $cli_id, 'tel_ord' => $ord); db_query($db_data_tel, "INSERT", "tel", "tel_id"); $ord++; unset($db_data_tel); } if (strlen($row["Mobile"] > 3)) { $db_data_tel = array('tel_number' => phone_format($row["Mobile"]), 'tel_type' => 'Mobile', 'tel_cli' => $cli_id, 'tel_ord' => $ord); db_query($db_data_tel, "INSERT", "tel", "tel_id"); $ord++; unset($db_data_tel); } } unset($db_data, $db_data_tel); #print_r($db_data); $counter++; } } $db_data_import["imp_source"] = 'figthedog'; $db_data_import["imp_report"] = serialize($duplicates); $db_data_import["imp_skipped"] = serialize($skipped); db_query($db_data_import, "INSERT", "import", "imp_id"); }
public function getPhoneNumberAttribute() { return phone_format($this->phone, 'US', 'E164'); }
public function export($data, $field) { $fieldname = strval($field['name']); return phone_format($data->{$fieldname}); }
?> </td> <td scope="row"><?php echo $lt->pf_port; ?> </td> <td scope="row"><?php echo $lt->pf_name; ?> </td> <td scope="row"><?php echo phone_format($lt->pf_tel); ?> </td> <td scope="row"><?php echo phone_format($lt->pf_hp); ?> </td> <td scope="row"><?php echo $lt->pf_status; ?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <th colspan="12" style="text-align:left">
/** * Сохранение данных заявки * с предварительной валидацией данных * */ public function store(PublicOrder $publicOrder, Request $request) { Session::reflash(); $input = $request->all(); $validateData = $this->validateData($input); $validation = Validator::make($validateData['input'], $validateData['rules'], $validateData['messages']); if ($validation->fails()) { return redirect()->route('validateError')->withInput()->withErrors($validation); } $validateData['input']['phone'] = phone_format($validateData['input']['phone'], 'RU'); $publicOrder->saveOrder($validateData['input']); $this->orderEmail($validateData['input']); return view('public.thanks', ['input' => $validateData['input']]); }
public function testPhoneFormatHelperFunction() { // Test landline number without format parameter. $actual = phone_format('016123456', 'BE'); $expected = '+32 16 12 34 56'; $this->assertEquals($expected, $actual); // Test landline number with format parameter. $actual = phone_format('016123456', 'BE', \libphonenumber\PhoneNumberFormat::NATIONAL); $expected = '016 12 34 56'; $this->assertEquals($expected, $actual); // Test mobile number without format parameter. $actual = phone_format('0499123456', 'BE'); $expected = '+32 499 12 34 56'; $this->assertEquals($expected, $actual); // Test mobile number with format parameter. $actual = phone_format('0499123456', 'BE', \libphonenumber\PhoneNumberFormat::NATIONAL); $expected = '0499 12 34 56'; $this->assertEquals($expected, $actual); }
?> </td> <td scope="row"><img src="<?php echo $lt->gc_imgurl; ?> " width="200" height="*"></td> <td scope="row"><?php echo $lt->gc_ismms; ?> </td> <td scope="row"><?php echo phone_format($lt->gc_receiver); ?> </td> <td scope="row"><?php echo phone_format($lt->gc_sender); ?> </td> <td scope="row"><?php echo $lt->gc_result; ?> </td> <td scope="row"><?php echo $lt->gc_datetime; ?> </td> <td scope="row"><a href="javascript:chg_store(<?php echo $lt->gc_stno; ?> );"><?php echo $lt->gc_stno;
if ($results['Errors'] && $results2['Errors']) { $errors = join_arrays(array($results['Errors'], $results2['Errors'])); echo error_message($errors, urlencode($return)); exit; } elseif ($results['Errors']) { echo error_message($results['Errors'], urlencode($return)); exit; } elseif ($results2['Errors']) { echo error_message($results2['Errors'], urlencode($return)); exit; } // no errors, continue unset($formData1["cli_tel"]); $db_data['cli_created'] = $date_mysql; $cli_id = db_query($db_data, "INSERT", "client", "cli_id"); $db_dataTel = array('tel_number' => phone_format($_POST["telnew"]), 'tel_type' => $_POST["telnewtype"], 'tel_cli' => $cli_id, 'tel_ord' => 1); db_query($db_dataTel, "INSERT", "tel", "tel_id"); unset($db_dataTel); if ($_POST["pro_pro_id"]) { $pro_id = $_POST["pro_pro_id"]; $db_data3["p2c_pro"] = $pro_id; $db_data3["p2c_cli"] = $cli_id; $db_data3["p2c_type"] = $_POST["p2c_type"]; db_query($db_data3, "INSERT", "pro2cli", "p2c_id"); } else { // if the manual input form is used, put values into array and insert into property table // all manual entries are inserted with -1 as pcid, and should be checked by admin until a script does it automatically // here, in fuure, we should check table for existing properties to prevent duplicates $db_data2["pro_pcid"] = '-1'; $pro_id = db_query($db_data2, "INSERT", "property", "pro_id"); // notify admin of manual address input
function field_phone($name, $value, $code = false) { $content = ''; if (($this->is_form or $this->is_add or $this->is_edit) and $this->access == 2) { $content .= '<div class="relative"><span class="phone-code">+7</span><input type="text"' . (($this->is_add or isset($this->access_fields[$name])) ? ' name="fields[' . $name . ']"' : '') . ' value="' . ((($this->is_add or isset($this->access_fields[$name])) and isset($_POST['fields'])) ? isset($_POST['fields'][$name]) ? str_replace('+7', '', $_POST['fields'][$name]) : '' : ($value ? str_replace('+7', '', $value) : '')) . '" maxlength="10"' . (($this->is_add or isset($this->access_fields[$name])) ? '' : ' disabled') . ' class="string min phone' . (($this->is_add or isset($this->access_fields[$name])) ? '' : ' disabled') . '" /></div>'; $content .= isset($this->error[$name]) ? '<div id="error-' . $name . '" class="error">' . $this->error[$name] . '</div>' : ''; } else { $content .= (isset($this->access_fields[$name]) or $this->access == 2) ? phone_format($value) . ($code ? ' <span style="color: #999999; padding: 0px 0px 0px 8px;">(' . phone_code($value) . ')</span>' : '') : ''; } return $content; }
/** * @param $id * @param Request $request * @return mixed */ public function update($id, Request $request) { // we get the user if (!($user = Sentinel::findById($id))) { Modal::alert([trans('users.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error'); // we redirect the current user to the users list if he has the required permission if (Sentinel::getUser()->hasAccess('users.list')) { return redirect()->route('users.index'); } else { // or we redirect the current user to the home page return redirect()->route('dashboard.index'); } } // if the updated user is not the current user if ($user->id !== Sentinel::getUser()->id) { // we check the current user permission if (!Permission::hasPermission('users.update')) { // we redirect the current user to the user list if he has the required permission if (Sentinel::getUser()->hasAccess('users.view')) { return redirect()->route('users.edit', ['id' => $id]); } else { // or we redirect the current user to the home page return redirect()->route('dashboard.index'); } } } // we check if the current user has a role position high enough to edit the user $edited_user_role = $user->roles->first(); $current_user_role = Sentinel::getUser()->roles->first(); if ($edited_user_role && $current_user_role && $edited_user_role->position < $current_user_role->position) { Modal::alert([trans('users.message.permission.denied', ['action' => trans('users.message.permission.action.edit')])], 'error'); return redirect()->back(); } // we check if the chosen role is not higher than the role of the current user $new_user_role = Sentinel::findRoleById($request->get('role')); $current_user_role = Sentinel::getUser()->roles->first(); if ($new_user_role && $current_user_role && $new_user_role->position < $current_user_role->position) { // we flash the request $request->flashExcept('photo'); // we notify the user Modal::alert([trans('users.message.permission.denied', ['action' => trans('users.message.permission.action.edit')])], 'error'); return redirect()->back(); } // if the remove_photo field is not given, we set it to false $request->merge(['remove_photo' => $request->get('remove_photo', false)]); // we sanitize the entries $request->replace(InputSanitizer::sanitize($request->all())); try { // we convert the en/fr date to the database format if ($birth_date = $request->get('birth_date')) { $request->merge(['birth_date' => Carbon::createFromFormat('d/m/Y', $birth_date)->format('Y-m-d')]); } } catch (Exception $e) { // we log the error CustomLog::error($e); } // we set the validation rules $rules = ['photo' => 'image|mimes:jpg,jpeg,png|image_size:>=145,>=160', 'remove_photo' => 'required|boolean', 'gender' => 'in:' . implode(',', array_keys(config('user.gender'))), 'last_name' => 'required|string', 'first_name' => 'required|string', 'birth_date' => 'date_format:Y-m-d', 'phone_number' => 'phone:FR', 'email' => 'required|email|unique:users,email,' . $id, 'address' => 'string', 'zip_code' => 'digits:5', 'city' => 'string', 'country' => 'string', 'password' => 'min:' . config('password.min.length') . '|confirmed']; // according if we update the current profile account or a user profile if ($user->id !== Sentinel::getUser()->id) { $rules['role'] = 'required|numeric|exists:roles,id'; $rules['active'] = 'boolean'; $rules['status_id'] = 'required|numeric|in:' . implode(',', array_keys(config('user.status'))); $rules['board_id'] = 'numeric|in:' . implode(',', array_keys(config('user.board'))); } // we sort the rules by keys ksort($rules); // we check the inputs validity if (!Validation::check($request->all(), $rules)) { // we flash the request $request->flashExcept('photo'); return redirect()->back(); } try { // we update the user Sentinel::update($user, $request->except('password', 'photo')); // we format the number into its international equivalent if ($phone_number = $request->get('phone_number')) { Sentinel::update($user, ['phone_number' => phone_format($phone_number, 'FR', PhoneNumberFormat::INTERNATIONAL)]); } // we store the photo if ($photo = $request->file('photo')) { // we optimize, resize and save the image $file_name = ImageManager::optimizeAndResize($photo->getRealPath(), $user->imageName('photo'), $photo->getClientOriginalExtension(), $user->storagePath(), $user->availableSizes('photo')); // we update the user Sentinel::update($user, ['photo' => $file_name]); } elseif (!$request->get('photo') && !$user->photo || $request->get('remove_photo')) { // we set the una logo as the user image $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false); // we update the user Sentinel::update($user, ['photo' => $file_name]); } // we update the user password if ($password = $request->get('password')) { Sentinel::update($user, ['password' => $password]); } // if we're updating the profile of another user if ($user->id !== Sentinel::getUser()->id) { // we check is the user is attached to roles $current_roles = $user->roles; // we detach each roles found foreach ($current_roles as $role) { $role->users()->detach($user); } // we attach the new role $role = Sentinel::findRoleById($request->get('role')); $role->users()->attach($user); // if the order is to activate the user if ($request->get('active')) { // we activate the user if (!($activation = Activation::completed($user))) { $activation = Activation::create($user); } Activation::complete($user, $activation->code); } else { // or we deactivate him Activation::remove($user); } // we notify the current user Modal::alert([trans('users.message.update.success', ['name' => $user->first_name . ' ' . $user->last_name])], 'success'); return redirect()->back(); } // we notify the current user Modal::alert([trans('users.message.account.success')], 'success'); return redirect()->back(); } catch (Exception $e) { // we flash the request $request->flashExcept('photo'); // we log the error CustomLog::error($e); // we notify the current user Modal::alert([trans('users.message.update.failure', ['name' => $user->first_name . ' ' . $user->last_name]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error'); return redirect()->back(); } }
?> </td> <td scope="row"><img src="<?php echo $lt->mm_imgurl; ?> " width="200" height="*"></td> <td scope="row"><?php echo $lt->mm_type; ?> </td> <td scope="row"><?php echo phone_format($lt->mm_receiver); ?> </td> <td scope="row"><?php echo phone_format($lt->mm_sender); ?> </td> <td scope="row"><?php echo $lt->mm_result; ?> </td> <td scope="row"><?php echo $lt->mm_datetime; ?> </td> <td scope="row"><?php echo $lt->mm_daily_cnt; ?> </td> <td scope="row"><?php
public function intlphoneNumber($phoneNumber, $countryCode) { $data = (object) json_decode(file_get_contents("https://restcountries.eu/rest/v1/alpha/" . strtolower($countryCode))); $phoneCode = "+" . $data->callingCodes[0]; $phone = phone_format($phoneNumber, $countryCode, PhoneNumberFormat::E164); $f_phone = str_replace($phoneCode, $phoneCode . ".", $phone); return $f_phone; }
echo $lt->at_no; ?> </td> <td scope="row"><?php echo $lt->at_subject; ?> <br><?php echo nl2br($lt->at_content); ?> </td> <td scope="row"><?php echo phone_format($lt->at_receiver); ?> </td> <td scope="row"><?php echo phone_format($lt->at_sender); ?> </td> <td scope="row"><?php echo $lt->at_result; ?> </td> <td scope="row"><?php echo $result_code; ?> </td> <td scope="row"><?php echo $lt->at_datetime; ?> </td> </tr>