/var/www/hkosl.com/ifapc/html_20210817/IFAPC2021/application/controllers/Application_bak.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
<?php
require_once APPPATH 'core/MY_Controller_2.php';

class 
Application extends MY_Controller_2
{
    public function 
__construct()
    {
        
// set $this->table and $this->model
        
parent::__construct(__CLASS__);

        if (!
check_member_login($_SESSION['member_id'])) {
            
$_SESSION['back'] = 'application';
            
redirect(front_url('login'));
        }

        
$this->updated_single_language_fields = array(
            
'category_id' => __('Category'),
            
'nominee_title' => __('Title'),
            
'nominee_birth_date' => __('Date of Birth'),
            
'nominee_birth_place' => __('Place of Birth'),
            
'nominee_tel' => __('Contact Tel./ Moile No.'),
            
'nominee_wechat' => __('Wechat Account'),
            
'nominee_assistant_title' => __('Assistant Title'),
            
'nominee_assistant_email' => __('Assistant Email'),
            
'nominee_assistant_tel' => __('Assistant Phone No.'),

            
'company_name' => __('Name of Present Company Name'),
            
'company_address' => __('Address of Present Company Name'),
            
'company_position' => __('Present Position'),
            
'company_position_years' => __('Number of years in present position'),
            
'company_is_founder' => __('Is the nominee a founder of current company?'),
            
'company_is_family_business' => __('Is it a family business?'),
            
'company_founded_year' => __('What year was the company founded'),
            
'company_industry' => __('Industry'),
            
'company_website' => __('Company website'),
            
'company_is_listed' => __('Is the company listed?'),
            
'company_stock_code' => __('Stock code'),

            
'narrative_enterprise' => __('Enterprise Management and Development') . ' (' __('by bullet points') . ')',
            
'narrative_industry' => __('Industry Influence and achievement') . ' (' __('by bullet points') . ')',
            
'narrative_contribution' => __('Contribution for the Greater Bay Area Development') . ' (' __('by bullet points') . ')',
            
'narrative_corporate' => __('Corporate and Social Responsibility') . ' (' __('by bullet points') . ')',
            
'narrative_personal' => __('Personal Reputation and Recognition') . ' (' __('by bullet points') . ')',

            
'terms_is_declaration' => 'Declaration',
            
'terms_is_not_attend' => 'Not Attend',

            
'nominator_title' => __('Title'),
            
'nominator_job_title' => __('Job Title'),
            
'nominator_company' => __('Company Name'),
            
'nominator_tel' => __('Phone No.'),
            
'nominator_address' => __('Correspondence Address'),
            
'nominator_reason' => __('Reason for nomination'),
        );
        
$tmp = array(
            
'nominee_email' => __('Nominee Email'),
            
'nominator_email' => __('Nominator Email'),

            
'organization_name' => __('Name of Organization'),
            
'participation_year' => __('Year of Participation'),
            
'involvement' => __('Community Service Involvement'),
            
'achievement' => __('Achievement and Contributions'),
        );
        
$this->single_language_fields array_merge($this->updated_single_language_fields$tmp);

        
$this->updated_multiple_language_fields = array(
            
'nominee_name_' => __('Name'),
            
'nominee_assistant_name_' => __('Assistant Name'),

            
'nominator_name_' => __('Name'),
        );
        
$this->multiple_language_fields $this->updated_multiple_language_fields;

        
$this->single_language_validate_fields = array(
            
'nominee_title' => 'required|in_list[ms,mrs,miss,dr]',
            
'category_id' => 'required',
            
'nominee_birth_date' => 'required|callback_validate_date_of_birth',
            
'nominee_birth_place' => 'required',
            
'nominee_tel' => 'required|callback_validate_phone',
            
'nominee_wechat' => 'required',
            
'nominee_assistant_title' => 'required|in_list[mr,ms,miss]',
            
'nominee_assistant_email' => 'required|valid_email',
            
'nominee_assistant_tel' => 'required|callback_validate_phone',

            
'company_name' => 'required',
            
'company_address' => 'required',
            
'company_position' => 'required',
            
'company_position_years' => 'required|greater_than_equal_to[0]',
            
'company_is_founder' => 'required|in_list[1,0]',
            
'company_is_family_business' => 'required|in_list[1,0]',
            
'company_founded_year' => 'required|callback_validate_year',
            
'company_industry' => 'required',
            
'company_website' => 'required|valid_url',
            
'company_is_listed' => 'required|in_list[1,0]',
            
'company_stock_code' => 'callback_validate_company_stock_code',

            
'organization_name' => 'callback_validate_required_service[organization_name]',
            
'participation_year' => 'callback_validate_required_service[participation_year]',
            
'involvement' => 'callback_validate_required_service[involvement]',
            
'achievement' => 'callback_validate_required_service[achievement]',

            
'narrative_enterprise' => 'required',
            
'narrative_industry' => 'required',
            
'narrative_contribution' => 'required',
            
'narrative_corporate' => 'required',
            
'narrative_personal' => 'required',

            
'terms_is_declaration' => 'required|in_list[1,0]',
            
'terms_is_attend' => 'in_list[1,0]',

            
'nominator_title' => 'required|in_list[mr,mrs,ms,miss,dr]',
            
'nominator_job_title' => 'required',
            
'nominator_company' => 'required',
            
'nominator_tel' => 'required|callback_validate_phone',
            
'nominator_address' => 'required',
            
'nominator_reason' => 'required',

        );
        
$this->multiple_language_validate_fields = array(
            
'nominee_name_' => 'required',
            
'nominee_assistant_name_' => 'required',

            
'nominator_name_' => 'required',
        );

        
$this->validate_massages['validate_date_of_birth'] = __('Please enter validated ') . ' %s';
        
$this->validate_massages['validate_phone'] = __('Please enter validated ') . ' %s';
        
$this->validate_massages['validate_year'] = __('Please enter validated ') . ' %s';
        
$this->validate_massages['validate_company_stock_code'] = __('Please enter validated ') . ' %s';
        
$this->validate_massages['validate_required_service'] = __('Please enter validated ') . ' %s';

        
$this->single_language_encpytion_fields = array(
            
'nominee_birth_place''nominee_tel''nominee_wechat''nominee_assistant_tel''company_name''company_address''company_position''company_industry''company_website''narrative_enterprise''narrative_industry''narrative_contribution''narrative_corporate''narrative_personal''nominator_job_title''nominator_company''nominator_tel''nominator_address''nominator_reason',
        );
        
$this->multiple_language_encpytion_fields = array(
            
'nominee_name_''nominee_assistant_name_''company_position_years''nominee_name_''nominator_name_',
        );
        
// $this->fields_permission[$field][0]: nomminee, $this->fields_permission[$field][1]: nommintor
        // 1: view, 2: update
        // premission = view | update
        
$this->fields_permission = array(
            
'category_id' => '13',
            
'nominee_title' => '31',
            
'nominee_name_' => '31',
            
'nominee_birth_date' => '30',
            
'nominee_birth_place' => '30',
            
'nominee_email' => '11',
            
'nominee_tel' => '30',
            
'nominee_wechat' => '30',
            
'nominee_assistant_title' => '31',
            
'nominee_assistant_name_' => '31',
            
'nominee_assistant_email' => '31',
            
'nominee_assistant_tel' => '30',

            
'company_name' => '31',
            
'company_address' => '30',
            
'company_position' => '31',
            
'company_position_years' => '30',
            
'company_is_founder' => '30',
            
'company_is_family_business' => '30',
            
'company_founded_year' => '31',
            
'company_industry' => '31',
            
'company_website' => '31',
            
'company_is_listed' => '31',
            
'company_stock_code' => '31',

            
'organization_name' => '31',
            
'participation_year' => '30',
            
'involvement' => '31',
            
'achievement' => '31',

            
'narrative_enterprise' => '31',
            
'narrative_industry' => '31',
            
'narrative_contribution' => '31',
            
'narrative_corporate' => '31',
            
'narrative_personal' => '31',

            
'terms_is_declaration' => '31',
            
'terms_is_not_attend' => '31',

            
'nominator_title' => '13',
            
'nominator_name_' => '13',
            
'nominator_job_title' => '13',
            
'nominator_company' => '13',
            
'nominator_email' => '11',
            
'nominator_tel' => '03',
            
'nominator_address' => '03',
            
'nominator_reason' => '13',
        );

    }

    public function 
index()
    {
        
$this->load->vars('model'$this->model->get_related_data());
        
$this->allow_methods = array('index');
        
parent::index();
    }

    public function 
create()
    {
        
$this->single_language_validate_fields = array(
            
'nominee_email' => 'required|valid_email',
            
'nominator_email' => 'required|valid_email|differs[nominee_email]',
        );

        
$this->allow_methods = array('create');
        
$this->view_page 'application_member_form';
        
parent::create();
    }

    public function 
modify($id)
    {
        
$this->allow_methods = array('modify');

        if (
count($certain $this->model->get_certain($id)) == || !in_array($_SESSION['member_id'], [$certain['nominee_member_id'], $certain['nominator_member_id']])) {
            
$_SESSION['msg_type'] = 'error';
            
$_SESSION['error_msg'] = __('The application is not available.');
            
$_SESSION['msg_back_url'] = front_url('application');
            
redirect(front_url('message'));
        }

        
$this->load->vars('categories'Category_model::get_data());
        
$this->load->vars('fields_permission'$this->fields_permission);
        
$this->load->vars('services'Application_service_model::get_data_by_field_with_value(['application_id' => $id]));

        
parent::modify($id);
    }

    public function 
change_email($id)
    {
        
$this->load->vars('id'$id);

        if (!
count($application Application_model::get_certain($id)) || $application['owner_member_id'] != $_SESSION['member_id']) {
            
$_SESSION['msg_type'] = 'error';
            
$_SESSION['error_msg'] = __('Have not permissions.');
            
redirect(front_url('message'));
        }

        if (empty(
$this->input->post('nominee_email')) && empty($this->input->post('nominator_email'))) {
            
$this->load->vars('nominee_email'Member_model::get_certain($application['nominee_member_id'])['email']);
            
$this->load->vars('nominee_submitted'$application['nominee_submitted']);
            
$this->load->vars('nominator_email'Member_model::get_certain($application['nominator_member_id'])['email']);
            
$this->load->vars('nominator_submitted'$application['nominator_submitted']);
            
$this->load->view('main/change_email_form');
            return;
        } else {
            
$this->form_validation->set_rules('nominee_email'__('Nominee Email'), 'trim|required|valid_email');
            
$this->form_validation->set_rules('nominator_email'__('Nominator Email'), 'trim|required|valid_email|differs[nominee_email]');

            if (
$this->form_validation->run() == false || !empty($_SESSION['error_msg'])) {
                
$this->load->vars('nominee_email'Member_model::get_certain($application['nominee_member_id'])['email']);
                
$this->load->vars('nominee_submitted'$application['nominee_submitted']);
                
$this->load->vars('nominator_email'Member_model::get_certain($application['nominator_member_id'])['email']);
                
$this->load->vars('nominator_submitted'$application['nominator_submitted']);
                
$this->load->view('main/change_email_form');
                return;
            } else {
                
$fields = array('nominee_email''nominator_email');
                
$updated_email false;
                foreach (
$fields as $field) {
                    
$membership substr($field0, -strlen('_email'));

                    
$post_email trim($this->input->post($field));
                    if (empty(
$post_email) || !$this->valid_email($post_email) || $post_email == Member_model::get_certain($application[$membership '_member_id'])['email'] || $application[$membership '_submitted']) {
                        continue;
                    }

                    
$updated_email true;

                    
$member_data = array('email' => $post_email);
                    if (!
count(Member_model::where('email'$post_email)->where('deleted'0)->get())) {
                        
$new_password substr(md5(uniqid(mt_rand(), true)), 06);

                        
$member_data['password'] = $this->encryption->encrypt($new_password);
                        
$member_data['verified'] = 1;

                        
Member_model::create()->update($member_data);
                    }
                    
$data[$membership '_member_id'] = Member_model::where('email'$post_email)->where('deleted'0)->get()[0]['id'];

                    
$fields_permission_index $membership == 'nominee' 1;

                    
$deleted_service false;
                    foreach (
$this->fields_permission as $field => $permissions) {
                        if (
$permissions[$fields_permission_index] & 2) {
                            if(
in_array($field, ['organization_name''participation_year''involvement''achievement'])){
                                if (!
$deleted_service) {                                    
                                    
$deleted_service true;
                                    
$delete_data = array(
                                        
"deleted" => 1,
                                        
"deleted_at" => date('Y-m-d H:i:s'),
                                    );
                                    
Application_service_model::where('application_id'$id)->where('deleted'0)->update($delete_data);
                                }                                
                            } else if (!
in_array($field, ['nominee_email''nominator_email'])) {
                                if(
substr($field, -1) == '_') {
                                    foreach (
$this->languages as $lang => $language) {
                                        
$data[$field $lang] = '';
                                    }
                                } else {                                   
                                    
$data[$field] = '';
                                }
                            }
                        }
                    }
                }

                if (
$updated_email) {
                    
$data['nominee_submitted'] = $data['nominator_submitted'] = 0;
                }

                if (!empty(
$data)) {
                    
Application_model::where('id'$id)->update($data);
                }
            }
        }

        
redirect(front_url('application'));
    }

    public function 
save_form($id)
    {
        
$this->run_validation false;
        
$this->submit_form($id);
    }

    private function 
concat_service()
    {
        
$service_fields = array('organization_name''participation_year''involvement''achievement');
        
$count count($this->input->post($service_fields[0]));

        
$return = array();
        
$j 0;
        for (
$i 0$i $count$i++) {
            
$have_value false;
            foreach (
$service_fields as $field) {
                if (!empty(
$this->input->post($field)[$i])) {
                    
$have_value true;
                    break;
                }
            }
            if (
$have_value) {
                foreach (
$service_fields as $field) {
                    
$return[$j][$field] = $this->input->post($field)[$i];
                }
                
$j++;
            }
        }
        return 
$return;
    }

    protected function 
update_other_tables($id$current_update_data$action)
    {
        
$application $this->model->get_certain($id);

        if (
$_SESSION['member_id'] == $application['nominee_member_id']) {
            
$membership 'nominee';
        } else if (
$_SESSION['member_id'] == $application['nominator_member_id']) {
            
$membership 'nominator';
        }

        
$delete_data = array(
            
"deleted" => 1,
            
"deleted_by" => $_SESSION['sys_user_id'],
            
"deleted_at" => date('Y-m-d H:i:s'),
            
"deleted_by" => $_SESSION['member_id'],
        );

        if (
$membership == 'nominee') {
            
Application_service_model::where('application_id'$id)->update($delete_data);
            
$services $this->concat_service();
            
$service_datat = array(
                
"application_id" => $id,
            );
            foreach (
$services as $i => $row) {
                
$row['application_id'] = $id;
                
$row['sort'] = ++$i;
                
Application_service_model::create()->update($row);
            }
        }
    }

    public function 
submit_form($id null)
    {
        
$this->allow_methods = array('submit_form');

        if (empty(
$id)) {
            
$this->single_language_validate_fields = array(
                
'nominee_email' => 'required|valid_email',
                
'nominator_email' => 'required|valid_email|differs[nominee_email]',
            );
            
$this->multiple_language_validate_fields = array();

            
$this->submit_bypass true;
        } else {
            
$_POST['terms_is_declaration'] = $this->input->post('terms_is_declaration') == 'on' 0;
            
$_POST['terms_is_not_attend'] = $this->input->post('terms_is_not_attend') == 'on' 0;

            if (
count($certain $this->model->get_certain($id)) == 0) {
                
$_SESSION['msg_type'] = 'error';
                
$_SESSION['error_msg'] = __('The application is not available.');
                
$_SESSION['msg_back_url'] = front_url('application');
                
redirect(front_url('message'));
            }

            if (
$_SESSION['member_id'] == $certain['nominee_member_id']) {
                
$fields_permission_index 0;
                
$membership 'nominee';
            } else if (
$_SESSION['member_id'] == $certain['nominator_member_id']) {
                
$fields_permission_index 1;
                
$membership 'nominator';
            } else {
                
$_SESSION['msg_type'] = 'error';
                
$_SESSION['error_msg'] = __('You have not permission.');
                
$_SESSION['msg_back_url'] = front_url('application');
                
redirect(front_url('message'));
            }

            if (
$certain[$membership '_submitted'] == 1) {
                
$_SESSION['msg_type'] = 'error';
                
$_SESSION['error_msg'] = __('You have already submitted this application.');
                
$_SESSION['msg_back_url'] = front_url('application');
                
redirect(front_url('message'));
            } else {
                foreach (
$this->fields_permission as $field => $permissions) {
                    if (!(
$permissions[$fields_permission_index] & 2)) {
                        unset(
$this->updated_single_language_fields[$field]);
                        unset(
$this->updated_multiple_language_fields[$field]);

                        unset(
$this->single_language_validate_fields[$field]);
                        unset(
$this->multiple_language_validate_fields[$field]);
                    }
                }
            }

            if (
$this->run_validation) {
                
$this->post_services $this->concat_service();
                
// client clicked [Submit] not [Save]
                
$this->additional_submit_data[$membership '_submitted'] = 1;
            }
        }

        
parent::submit_form($id);
    }

    protected function 
submit_bypass($data$id null)
    {
        if (empty(
$id)) {
            
$this->allow_methods = array('send_email');

            
$fields = array('nominee_email''nominator_email');
            foreach (
$fields as $field) {
                
$post_email trim($this->input->post($field));

                
$member_data = array('email' => $post_email);
                if (!
count(Member_model::where('email'$post_email)->where('deleted'0)->get())) {
                    
$new_password substr(md5(uniqid(mt_rand(), true)), 06);
                    
$token bin2hex(random_bytes(16));

                    
$member_data['token'] = $this->encryption->encrypt($token);
                    
$member_data['password'] = $this->encryption->encrypt($new_password);

                    
$member Member_model::create();
                    
$member->update($member_data);

                    
$member_data['new_password'] = $new_password;
                    
$member_data['token'] = $token;
                    
$member_data['id'] = $member['id'];

                    
$member_data['registration'] = true;
                }
                
$member_data['field'] = substr($field0, -strlen('_email'));
                
$this->application_email($member_data);

                
$application_data[$member_data['field'] . '_member_id'] = Member_model::where('email'$post_email)->where('deleted'0)->get()[0]['id'];
            }

            
$latest_no Application_no_model::create()->id;
            
$application_data['reference_no'] = 'REF' date('ym') . str_pad($latest_no6"0"STR_PAD_LEFT);
            
$application_data['owner_member_id'] = $_SESSION['member_id'];
            
$this->model->create()->update($application_data);
        }
        
redirect(front_url($this->table));
    }

    protected function 
registration_email($data)
    {
        
$body '';
        
$body .= '<tr>';
        
$body .= '    <td align="center"><h1>' __('Welcome') . '</h1>';
        
$body .= '</tr>';
        
$body .= '<tr>';
        
$body .= '    <td>Login Password:' $data['new_password'] . '</h3>';
        
$body .= '</tr>';
        
$body .= '<tr>';
        
$body .= '    <td><h3>' __('Please confirm your account by clicking the link below') . ':</h3>';
        
$body .= '</tr>';
        
$body .= '<tr>';
        
$body .= '    <td><h5><a href="' front_url('member/verify/') . $data['id'] . '/' $data['token'] . '" target="_blank">' __('Confirm Email') . '</a></h5></td>';
        
$body .= '</tr>';

        
$this->send_email($data['email'], __('Verification of registration'), $body);
    }

    protected function 
application_email($data)
    {
        
$body '';
        
$body .= '<tr>';
        
$body .= '    <td align="center"><h1>' __($data['field']) . '</h1>';
        
$body .= '</tr>';
        if (
$data['registration']) {
            
$body .= '<tr>';
            
$body .= '    <td>Login Password:' $data['new_password'] . '</h3>';
            
$body .= '</tr>';
            
$body .= '<tr>';
            
$body .= '    <td><h3>' __('You are ' $data['field'] . ', please confirm your account by clicking the link below') . ':</h3>';
            
$body .= '</tr>';
            
$body .= '<tr>';
            
$body .= '    <td><h5><a href="' front_url('member/verify/') . $data['id'] . '/' $data['token'] . '" target="_blank">' __('Confirm Email') . '</a></h5></td>';
            
$body .= '</tr>';
        } else {
            
$body .= '<tr>';
            
$body .= '    <td><h3>' __('You are ' $data['field'] . ', please check detail by clicking the link below') . ':</h3>';
            
$body .= '</tr>';
            
$body .= '<tr>';
            
$body .= '    <td><h5><a href="' front_url('application') . '" target="_blank">' __('Check detail') . '</a></h5></td>';
            
$body .= '</tr>';
        }

        
$this->send_email($data['email'], __($data['field'] . ' of GBA'), $body);
    }

    public function 
validate_date_of_birth($str)
    {
        if (!empty(
$str)) {
            
$date = new DateTime();
            
$format 'Y-m-d';
            
$input_date DateTime::createFromFormat($format$str);

            
//120 years
            
return $input_date->format($format) == $str && $input_date <= $date && $date->format('U') - $input_date->format('U') < 3786824202;
        }
        return 
true;
    }

    public function 
validate_phone($str)
    {
        if (!empty(
$str)) {
            
$pattern '/^\(*\+*\d{0,3}\)*[- ]*\d{4}\s*\d{4,15}$/';
            return (bool) 
preg_match($pattern$str);
        }
        return 
true;
    }

    public function 
validate_year($str)
    {
        if (!empty(
$str)) {
            
$pattern '/^\d{4}$/';
            return (bool) 
preg_match($pattern$str) && $str <= date('Y');
        }
        return 
true;
    }

    public function 
validate_required_service($str$field)
    {
        foreach (
$this->post_services as $row) {
            if (empty(
$row[$field]) || ($field == 'participation_year' && !$this->validate_year($row[$field]))) {
                return 
false;
            }
        }
        return 
true;
    }

    public function 
validate_company_stock_code($str)
    {
        
$company_is_listed $this->input->post('company_is_listed');
        if ((
$company_is_listed && empty($str)) || (!$company_is_listed && !empty($str))) {
            return 
false;
        }
        return 
true;
    }

}