bhq@iemsoft.cn
2018-11-27 3e083bc512141a008fecae0c6cfe3e6e9b9e2c3d
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
<?php
 
/**
 *  专题前台
 */
 
define('IN_ECS', true);
 
require(dirname(__FILE__) . '/includes/init.php');
 
if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}
 
if (empty($_SESSION['user_id'])){
    $back_act = "apply_index.php";
    if (!empty($_SERVER['QUERY_STRING']))
    {
      $back_act = 'apply.php?' . strip_tags($_SERVER['QUERY_STRING']);
    }
    show_message('请先登陆!', array('返回上一页','点击去登陆'), array($back_act, 'user.php'), 'info');
}
 
$userid = $_SESSION['user_id'];
 
$shownum = (isset($_REQUEST['shownum'])) ? intval($_REQUEST['shownum']) : 0;
 
$upload_size_limit = $_CFG['upload_size_limit'] == '-1' ? ini_get('upload_max_filesize') : $_CFG['upload_size_limit'];
 
if(isset($_POST['do']) && $_POST['do']){
    unset($apply,$save);
    if($shownum == 1){
        if($_POST['company'])
        {
        $save['company_name'] = isset($_POST['company_name']) ? trim(addslashes(htmlspecialchars($_POST['company_name']))) : ''; 
        $save['country'] = isset($_POST['country']) ? intval($_POST['country']) : 1; 
        $save['province'] = isset($_POST['province']) ? intval($_POST['province']) : 1; 
        $save['city'] = isset($_POST['city']) ? intval($_POST['city']) : 1; 
        $save['district'] = isset($_POST['district']) ? intval($_POST['district']) : 1; 
        $save['address'] = isset($_POST['address']) ? trim(addslashes(htmlspecialchars($_POST['address']))) : '';
        $save['tel'] = isset($_POST['tel']) ? trim(addslashes(htmlspecialchars($_POST['tel']))) : '';
        $save['guimo'] = isset($_POST['guimo']) ? trim(addslashes(htmlspecialchars($_POST['guimo']))) : '';
        $save['email'] = isset($_POST['email']) ? trim($_POST['email']) : '';
        $save['company_type'] = isset($_POST['company_type']) ? trim($_POST['company_type']) : '';
        $save['contacts_name'] = isset($_POST['contacts_name']) ? trim(addslashes(htmlspecialchars($_POST['contacts_name']))) : '';
        $save['contacts_phone'] = isset($_POST['contacts_phone']) ? trim(addslashes(htmlspecialchars($_POST['contacts_phone']))) : '';
        $save['business_licence_number'] = isset($_POST['business_licence_number']) ? trim(addslashes(htmlspecialchars($_POST['business_licence_number']))) : '';
        $save['business_sphere'] = isset($_POST['business_sphere']) ? trim(addslashes(htmlspecialchars($_POST['business_sphere']))) : '';
        $save['organization_code'] = isset($_POST['organization_code']) ? trim(addslashes(htmlspecialchars($_POST['organization_code']))) : '';
        
        if (isset($_FILES['zhizhao']) && $_FILES['zhizhao']['tmp_name'] != '' &&  isset($_FILES['zhizhao']['tmp_name']) && $_FILES['zhizhao']['tmp_name'] != 'none')
        {
            if($_FILES['zhizhao']['size'] / 1024 > $upload_size_limit)
            {
                $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                $err->show($_LANG['back_up_page']);
            }
            $zhizhao_img = upload_file($_FILES['zhizhao'], 'supplier');
            if ($zhizhao_img === false)
            {
                $err->add('营业执照号电子版图片上传失败!');
                $err->show($_LANG['back_up_page']);
            }
            else
            {
               $save['zhizhao'] = $zhizhao_img;
            }
        }
        if (isset($_FILES['organization_code_electronic']) && $_FILES['organization_code_electronic']['tmp_name'] != '' &&  isset($_FILES['organization_code_electronic']['tmp_name']) && $_FILES['organization_code_electronic']['tmp_name'] != 'none')
        {
            if($_FILES['organization_code_electronic']['size'] / 1024 > $upload_size_limit)
            {
                $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                $err->show($_LANG['back_up_page']);
            }
            $organization_code_electronic_img = upload_file($_FILES['organization_code_electronic'], 'supplier');
            if ($organization_code_electronic_img === false)
            {
                $err->add('组织机构代码证电子版图片上传失败!');
                $err->show($_LANG['back_up_page']);
            }
            else
            {
                $save['organization_code_electronic'] = $organization_code_electronic_img;
            }
        }
        if (isset($_FILES['general_taxpayer']) && $_FILES['general_taxpayer']['tmp_name'] != '' &&  isset($_FILES['general_taxpayer']['tmp_name']) && $_FILES['general_taxpayer']['tmp_name'] != 'none')
        {
            if($_FILES['general_taxpayer']['size'] / 1024 > $upload_size_limit)
            {
                $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                $err->show($_LANG['back_up_page']);
            }
            $general_taxpayer_img = upload_file($_FILES['general_taxpayer'], 'supplier');
            if ($general_taxpayer_img === false)
            {
                $err->add('组织机构代码证电子版图片上传失败!');
                $err->show($_LANG['back_up_page']);
            }
            else
            {
                $save['general_taxpayer'] = $general_taxpayer_img;
            }
        }
        $save['applynum'] = 1;//公司信息认证一
        
        //必填项验证
        $save1 = array_filter($save);
        if(count($save1)!=count($save)){
            show_message('请认真填写必填申请资料!', '返回', 'apply.php', 'wrong');
            }
             if ($db->autoExecute($ecs->table('supplier'), $save, 'UPDATE', 'user_id='.$userid) !== false){
                header("location:apply.php");
                exit;
             }else{
                show_message('操作失败!', '返回', 'apply.php', 'wrong');
             }
        }
        if($_POST['person'])
        {
            $save['company_name'] = isset($_POST['company_name']) ? trim(addslashes(htmlspecialchars($_POST['company_name']))) : ''; 
            $save['country'] = isset($_POST['country']) ? intval($_POST['country']) : 1; 
            $save['province'] = isset($_POST['province']) ? intval($_POST['province']) : 1; 
            $save['city'] = isset($_POST['city']) ? intval($_POST['city']) : 1; 
            $save['district'] = isset($_POST['district']) ? intval($_POST['district']) : 1; 
            $save['address'] = isset($_POST['address']) ? trim(addslashes(htmlspecialchars($_POST['address']))) : '';
            
            $save['contacts_name'] = isset($_POST['contacts_name']) ? trim(addslashes(htmlspecialchars($_POST['contacts_name']))) : '';
            $save['contacts_phone'] = isset($_POST['contacts_phone']) ? trim(addslashes(htmlspecialchars($_POST['contacts_phone']))) : '';
            $save['email'] = isset($_POST['email']) ? trim($_POST['email']) : '';
 
            $save['id_card_no'] = isset($_POST['id_card_no']) ? trim(addslashes(htmlspecialchars($_POST['id_card_no']))) : '';
 
            $save['bank_account_name'] = isset($_POST['bank_account_name']) ? trim(addslashes(htmlspecialchars($_POST['bank_account_name']))) : '';
            $save['bank_account_number'] = isset($_POST['bank_account_number']) ? trim(addslashes(htmlspecialchars($_POST['bank_account_number']))) : '';
            $save['bank_name'] = isset($_POST['bank_name']) ? trim(addslashes(htmlspecialchars($_POST['bank_name']))) : '';
            $save['bank_code'] = isset($_POST['bank_code']) ? trim(addslashes(htmlspecialchars($_POST['bank_code']))) : '';
            
            if (isset($_FILES['handheld_idcard']) && $_FILES['handheld_idcard']['tmp_name'] != '' &&  isset($_FILES['handheld_idcard']['tmp_name']) && $_FILES['handheld_idcard']['tmp_name'] != 'none')
            {
                if($_FILES['handheld_idcard']['size'] / 1024 > $upload_size_limit)
                {
                    $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                    $err->show($_LANG['back_up_page']);
                }
                $handheld_idcard_img = upload_file($_FILES['handheld_idcard'], 'supplier');
                if ($handheld_idcard_img === false)
                {
                    $err->add('手持身份证照片上传失败!');
                    $err->show($_LANG['back_up_page']);
                }
                else
                {
                    $save['handheld_idcard'] = $handheld_idcard_img;
                }
            }
            if (isset($_FILES['idcard_front']) && $_FILES['idcard_front']['tmp_name'] != '' &&  isset($_FILES['idcard_front']['tmp_name']) && $_FILES['idcard_front']['tmp_name'] != 'none')
            {
                if($_FILES['idcard_front']['size'] / 1024 > $upload_size_limit)
                {
                    $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                    $err->show($_LANG['back_up_page']);
                }
                $idcard_front_img = upload_file($_FILES['idcard_front'], 'supplier');
                if ($idcard_front_img === false)
                {
                    $err->add('身份证正面照片上传失败!');
                    $err->show($_LANG['back_up_page']);
                }
                else
                {
                    $save['idcard_front'] = $idcard_front_img;
                }
            }
            if (isset($_FILES['idcard_reverse']) && $_FILES['idcard_reverse']['tmp_name'] != '' &&  isset($_FILES['idcard_reverse']['tmp_name']) && $_FILES['idcard_reverse']['tmp_name'] != 'none')
            {
                if($_FILES['idcard_reverse']['size'] / 1024 > $upload_size_limit)
                {
                    $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                    $err->show($_LANG['back_up_page']);
                }
                $idcard_reverse_img = upload_file($_FILES['idcard_reverse'], 'supplier');
                if ($idcard_reverse_img === false)
                {
                    $err->add('身份证反面照片上传失败!');
                    $err->show($_LANG['back_up_page']);
                }
                else
                {
                    $save['idcard_reverse'] = $idcard_reverse_img;
                }
            }
            
            $save['applynum'] = 2;//公司信息认证一
            
            //必填项验证
            $save1 = array_filter($save);
            if(count($save1)!=count($save)){
                show_message('请认真填写必填申请资料!', '返回', 'apply.php', 'wrong');
            }
            
             if ($db->autoExecute($ecs->table('supplier'), $save, 'UPDATE', 'user_id='.$userid) !== false){
                header("location:apply.php");
                exit;
             }else{
                show_message('操作失败!', '返回', 'apply.php', 'wrong');
             }
        }
        
    }elseif($shownum == 2){
        
        $save['bank_account_name'] = isset($_POST['bank_account_name']) ? trim(addslashes(htmlspecialchars($_POST['bank_account_name']))) : '';
        $save['bank_account_number'] = isset($_POST['bank_account_number']) ? trim(addslashes(htmlspecialchars($_POST['bank_account_number']))) : '';
        $save['bank_name'] = isset($_POST['bank_name']) ? trim(addslashes(htmlspecialchars($_POST['bank_name']))) : '';
        $save['bank_code'] = isset($_POST['bank_code']) ? trim(addslashes(htmlspecialchars($_POST['bank_code']))) : '';
        $save['settlement_bank_account_name'] = isset($_POST['settlement_bank_account_name']) ? trim(addslashes(htmlspecialchars($_POST['settlement_bank_account_name']))) : '';
        $save['settlement_bank_account_number'] = isset($_POST['settlement_bank_account_number']) ? trim(addslashes(htmlspecialchars($_POST['settlement_bank_account_number']))) : '';
        $save['settlement_bank_name'] = isset($_POST['settlement_bank_name']) ? trim(addslashes(htmlspecialchars($_POST['settlement_bank_name']))) : '';
        $save['settlement_bank_code'] = isset($_POST['settlement_bank_code']) ? trim(addslashes(htmlspecialchars($_POST['settlement_bank_code']))) : '';
        $save['tax_registration_certificate'] = isset($_POST['tax_registration_certificate']) ? trim(addslashes(htmlspecialchars($_POST['tax_registration_certificate']))) : '';
        $save['taxpayer_id'] = isset($_POST['taxpayer_id']) ? trim(addslashes(htmlspecialchars($_POST['taxpayer_id']))) : '';
        
        if (isset($_FILES['bank_licence_electronic']) && $_FILES['bank_licence_electronic']['tmp_name'] != '' &&  isset($_FILES['bank_licence_electronic']['tmp_name']) && $_FILES['bank_licence_electronic']['tmp_name'] != 'none')
        {
            if($_FILES['bank_licence_electronic']['size'] / 1024 > $upload_size_limit)
            {
                $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                $err->show($_LANG['back_up_page']);
            }
            $bank_licence_electronic_img = upload_file($_FILES['bank_licence_electronic'], 'supplier');
            if ($bank_licence_electronic_img === false)
            {
                $err->add('开户银行许可证电子版图片上传失败!');
                $err->show($_LANG['back_up_page']);
            }
            else
            {
                $save['bank_licence_electronic'] = $bank_licence_electronic_img;
            }
        }
        if (isset($_FILES['tax_registration_certificate_electronic']) && $_FILES['tax_registration_certificate_electronic']['tmp_name'] != '' &&  isset($_FILES['tax_registration_certificate_electronic']['tmp_name']) && $_FILES['tax_registration_certificate_electronic']['tmp_name'] != 'none')
        {
            if($_FILES['tax_registration_certificate_electronic']['size'] / 1024 > $upload_size_limit)
            {
                $err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
                $err->show($_LANG['back_up_page']);
            }
            $tax_registration_certificate_electronic_img = upload_file($_FILES['tax_registration_certificate_electronic'], 'supplier');
            if ($tax_registration_certificate_electronic_img === false)
            {
                $err->add('税务登记证号电子版图片上传失败!');
                $err->show($_LANG['back_up_page']);
            }
            else
            {
                $save['tax_registration_certificate_electronic'] = $tax_registration_certificate_electronic_img;
            }
        }
        
        $save['applynum'] = 2;//公司信息认证二
        
        //必填项验证
        $save1 = array_filter($save);
        if(count($save1)!=count($save)){
            show_message('请认真填写必填申请资料!', '返回', 'apply.php', 'wrong');
        }
        
         if ($db->autoExecute($ecs->table('supplier'), $save, 'UPDATE', 'user_id='.$userid) !== false){
             header("location:apply.php");
             exit;
         }else{
             show_message('操作失败!', '返回', 'apply.php', 'wrong');
         }
        
    }elseif($shownum == 3){
        $save['supplier_name'] = isset($_POST['supplier_name']) ? trim(addslashes(htmlspecialchars($_POST['supplier_name']))) : ''; 
        $save['rank_id'] = isset($_POST['rank_id']) ? intval($_POST['rank_id']) : 0; 
        $save['type_id'] = isset($_POST['type_id']) ? intval($_POST['type_id']) : 0; 
        
        $save['applynum'] = 3;//店铺信息设置
        
        //必填项验证
        $save1 = array_filter($save);
        if(count($save1)!=count($save)){
            show_message('请认真填写必填申请资料!', '返回', 'apply.php', 'wrong');
        }
        
         if ($db->autoExecute($ecs->table('supplier'), $save, 'UPDATE', 'user_id='.$userid) !== false){
             header("location:apply.php");
             exit;
         }else{
             show_message('操作失败!', '返回', 'apply.php', 'wrong');
         }
        
    }else{//同意入驻协议
        
        
        if(isset($_POST['input_apply_agreement']) && intval($_POST['input_apply_agreement']) > 0){
            
            $sql = "select * from ".$ecs->table('supplier')." where user_id=".$userid." limit 1";
            $info = $db->getRow($sql);
            
            $apply['user_id'] = $userid;
            $apply['status'] = 0;
            $apply['applynum'] = 0;//同意入驻协议
            if($info){
                if ($db->autoExecute($ecs->table('supplier'), $apply, 'UPDATE', 'user_id='.$userid) !== false){
                     header("location:apply.php");
                     exit;
                 }else{
                     show_message('请点击同意入驻协议!', '返回', 'apply.php', 'wrong');
                 }
            }else{
                 if ($db->autoExecute($ecs->table('supplier'), $apply) !== false){
                     header("location:apply.php");
                     exit;
                 }else{
                     show_message('请点击同意入驻协议!', '返回', 'apply.php', 'wrong');
                 }
            }
        }else{
            $err->add('请点击同意入驻协议!');
            $err->show($_LANG['back_up_page']);
        }
    }
}
 
 
if (!$smarty->is_cached($templates, $cache_id))
 
    /* 模板赋值 */
    assign_template();
    $position = assign_ur_here();
    $smarty->assign('page_title',       $position['title']);       // 页面标题
    $smarty->assign('ur_here',          $position['ur_here'] . '> ' . $topic['title']);     // 当前位置
    
}
$smarty->assign('piclimit',$upload_size_limit);
$smarty->assign('userid',intval($_SESSION['user_id']));
$smarty->display('apply.dwt');
 
?>