~gt/sahana-agasti/relief-experiments

« back to all changes in this revision

Viewing changes to mod/dvr/edt_grp.inc

  • Committer: turtle
  • Date: 2009-11-10 23:51:44 UTC
  • Revision ID: turtle@turtle-laptop-20091110235144-lvhvgwfm053jvq5q
first relief codebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * 
 
5
 * Functions to edit a group in DVR
 
6
 * 
 
7
 *
 
8
 *  PHP version 4 and 5
 
9
 *
 
10
 * LICENSE: This source file is subject to LGPL license
 
11
 * that is available through the world-wide-web at the following URI:
 
12
 * http://www.gnu.org/copyleft/lesser.html
 
13
 *
 
14
 * @author     Isuru Samaraweera  
 
15
 * @author     Sheran Corera
 
16
 * @copyright  Lanka Software Foundation - http://www.opensource.lk
 
17
 * @package    module
 
18
 * @subpackage dvr
 
19
 * @license    http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
 
20
 *
 
21
 */
 
22
 
 
23
include_once ('lib.inc');
 
24
//include_once ('add_new_indv.inc');
 
25
include_once ($global['approot'] . '/inc/lib_form.inc');
 
26
include_once ($global['approot'] . '/inc/lib_validate.inc');
 
27
include_once ($global['approot'] . '/inc/lib_errors.inc');
 
28
include_once ($global['approot'] . '/inc/lib_image.inc');
 
29
include_once ($global['approot'] . '/mod/or/lib_or.inc');
 
30
include_once ($global['approot'] . '/inc/lib_uuid.inc');
 
31
include_once ($global['approot'] . '/mod/dvr/data_access.inc');
 
32
 
 
33
//get the value from database
 
34
function get_dvr_populate_group_major_details() {
 
35
        $head_details = get_group_type_and_head_details($_GET['groupid']);
 
36
 
 
37
        //print 'head details are' . $head_details->fields['group_type'];
 
38
        $_SESSION['dvr']['group']['id'] = $_GET['groupid'];
 
39
        $_SESSION['dvr']['group']['typ_of_grp'] = $head_details->fields['group_type'];
 
40
        $_SESSION['dvr']['group']['full_name'] = $head_details->fields['full_name'];
 
41
        $_SESSION['dvr']['group']['family_name'] = $head_details->fields['family_name'];
 
42
        $_SESSION['dvr']['group']['local_name'] = $head_details->fields['l10n_name'];
 
43
        $_SESSION['dvr']['group']['nic'] = $head_details->fields['nic'];
 
44
        $_SESSION['dvr']['group']['headid'] = $head_details->fields['head_id'];
 
45
        
 
46
        $_SESSION['dvr']['group']['displaced_loc'] = _shn_dvr_get_groupdisplaced_location($_SESSION['dvr']['group']['id']);
 
47
        $_SESSION['dvr']['group']['current_loc'] = _shn_dvr_get_groupcurrent_location($_SESSION['dvr']['group']['id']);
 
48
        
 
49
//var_dump($_SESSION['dvr']['group']['id'].'............'.$_SESSION['dvr']['group']['headid']);
 
50
        $contact_details = get_contacts($_SESSION['dvr']['group']['headid']);
 
51
        while (!$contact_details->EOF) {
 
52
 
 
53
                $contacttype = $contact_details->fields['opt_contact_type'];
 
54
                $contactvalue = $contact_details->fields['contact_value'];
 
55
 
 
56
                if ($contacttype == 'address') {
 
57
                        $_SESSION['dvr']['group']['address'] = $contactvalue;
 
58
                } else
 
59
                        if ($contacttype == 'email') {
 
60
                                $_SESSION['dvr']['group']['email'] = $contactvalue;
 
61
                        } else
 
62
                                if ($contacttype == 'mobile') {
 
63
                                        $_SESSION['dvr']['group']['mobile'] = $contactvalue;
 
64
                                } else
 
65
                                        if ($contacttype == 'telephone') {
 
66
                                                $_SESSION['dvr']['group']['telephone'] = $contactvalue;
 
67
                                        }
 
68
                $contact_details->MoveNext();
 
69
        }
 
70
 
 
71
        $group_content = get_group_description($_GET['groupid']);
 
72
        $_SESSION['dvr']['group']['adlt_mls'] = $group_content->fields['no_of_adult_males'];
 
73
        $_SESSION['dvr']['group']['adlt_fmls'] = $group_content->fields['no_of_adult_females'];
 
74
        $_SESSION['dvr']['group']['chldrn'] = $group_content->fields['no_of_children'];
 
75
        $_SESSION['dvr']['group']['dsplcd'] = $group_content->fields['no_displaced'];
 
76
        $_SESSION['dvr']['group']['mising'] = $group_content->fields['no_missing'];
 
77
        $_SESSION['dvr']['group']['dead'] = $group_content->fields['no_dead'];
 
78
        $_SESSION['dvr']['group']['rehbd'] = $group_content->fields['no_rehabilitated'];
 
79
        $_SESSION['dvr']['group']['opt_dvr_service'] = $group_content->fields['checklist'];
 
80
//print 'got'.$_SESSION['dvr']['group']['opt_dvr_service'];
 
81
        $_SESSION['dvr']['group']['other'] = $group_content->fields['description'];
 
82
 
 
83
}
 
84
 
 
85
//add group type and group head details
 
86
function shn_dvr_edit_grouptype_and_head_details_start($errors = false) {
 
87
        if ($_SESSION['dvr']['editgroup']['edit_clicked']  == false | $_SESSION['dvr']['editgroup']['edit_clicked']==null)
 
88
                get_dvr_populate_group_major_details();
 
89
        _shn_dvr_print_header(_t("Edit Group"));
 
90
        shn_dvr_grouptype_and_head_details($errors);
 
91
}
 
92
 
 
93
//error handling
 
94
function _shn_dvr_group_validate_error() {
 
95
        clean_errors();
 
96
        $error_flag = false;
 
97
 
 
98
        $gt = $_POST['opt_group_type'];
 
99
        $full_name = $_POST['full_name'];
 
100
 
 
101
/*      if (!isset ($_SESSION['dvr']['group']['headid'])) {
 
102
                $_SESSION['dvr']['group']['headid'] = shn_create_uuid();
 
103
 
 
104
        }*/
 
105
 
 
106
        if (trim($gt) == null | trim($gt) == '===') {
 
107
                add_error(_t("Please  select the group type"));
 
108
                $error_flag = true;
 
109
        }
 
110
        if (trim($full_name) == null | trim($full_name) == '') {
 
111
                add_error(_t("Please fill the full name"));
 
112
                $error_flag = true;
 
113
        }
 
114
 
 
115
    $email=$_POST['email'];
 
116
    if(!shn_valid_email($email,false))
 
117
    {
 
118
        add_error(_t("Invalid Email entered")); 
 
119
        $error_flag = true;
 
120
 
 
121
    }
 
122
    $adltmales=$_POST['adlt_mls'];
 
123
        $adltfmales=$_POST['adlt_fmls'];
 
124
        $chldrn=$_POST['chldrn'];
 
125
        
 
126
        $dsplcd=$_POST['dsplcd'];
 
127
        $misng= $_POST['misng'];
 
128
    $dead=      $_POST['dead'];
 
129
    $rehbd=      $_POST['rehbd'];
 
130
        
 
131
        if($adltmales!=null)
 
132
        {
 
133
            if(!shn_valid_number($adltmales))
 
134
            {
 
135
                    add_error(_("Adult male count should be a number"));
 
136
                        $error_flag = true;
 
137
            }
 
138
        }       
 
139
        if($adltfmales!=null)
 
140
        {
 
141
            if(!shn_valid_number($adltfmales))
 
142
            {
 
143
                    add_error(_("Adult female count should be a number"));
 
144
                        $error_flag = true;
 
145
            }
 
146
        }
 
147
        if($chldrn!=null)
 
148
        {
 
149
            if(!shn_valid_number($chldrn))
 
150
            {
 
151
                    add_error(_("Children count should be a number"));
 
152
                        $error_flag = true;
 
153
            }   
 
154
        }
 
155
        if($dsplcd!=null)
 
156
        {
 
157
            if(!shn_valid_number($dsplcd))
 
158
            {
 
159
                    add_error(_("Displaced count should be a number"));
 
160
                        $error_flag = true;
 
161
            }
 
162
        }
 
163
        if($misng!=null)
 
164
        {
 
165
            if(!shn_valid_number($misng))
 
166
            {
 
167
                    add_error(_("Missing people count should be a number"));
 
168
                        $error_flag = true;
 
169
            }   
 
170
        }
 
171
        if($dead!=null)
 
172
        {
 
173
            if(!shn_valid_number($dead))
 
174
            {
 
175
                    add_error(_("Death count should be a number"));
 
176
                $error_flag = true;
 
177
            }   
 
178
        }
 
179
        if($rehbd!=null)
 
180
        {
 
181
            if(!shn_valid_number($rehbd))
 
182
            {
 
183
                    add_error(_("Rehabilitated count should be a number"));
 
184
                        $error_flag = true;
 
185
            }   
 
186
        }       
 
187
 
 
188
        if ($_FILES['picture']['error'] != UPLOAD_ERR_NO_FILE) {
 
189
                $info = getimagesize($_FILES['picture']['tmp_name']);
 
190
                //check the image type 
 
191
 
 
192
                if (!$info) {
 
193
                        add_error(_t("Invalid Image Type Please try again"));
 
194
                        $error_flag = true;
 
195
                }
 
196
 
 
197
        }
 
198
 
 
199
        return $error_flag;
 
200
}
 
201
 
 
202
function shn_dvr_set_group_major_details() {
 
203
 
 
204
        global $global;
 
205
        global $conf;
 
206
 
 
207
        $_SESSION['dvr']['group']['typ_of_grp'] = $_POST['opt_group_type'];
 
208
        $_SESSION['dvr']['group']['full_name'] = $_POST['full_name'];
 
209
        $_SESSION['dvr']['group']['family_name'] = $_POST['family_name'];
 
210
        $_SESSION['dvr']['group']['local_name'] = $_POST['local_name'];
 
211
        $_SESSION['dvr']['group']['nic'] = $_POST['nic'];
 
212
        $_SESSION['dvr']['group']['picture'] = $_POST['picture'];
 
213
 
 
214
        $_SESSION['dvr']['group']['mobile'] = $_POST['mobile'];
 
215
        $_SESSION['dvr']['group']['telephone'] = $_POST['telephone'];
 
216
        $_SESSION['dvr']['group']['email'] = $_POST['email'];
 
217
        $_SESSION['dvr']['group']['address'] = $_POST['address'];
 
218
        $_SESSION['dvr']['group']['adlt_mls'] = $_POST['adlt_mls'];
 
219
        $_SESSION['dvr']['group']['adlt_fmls'] = $_POST['adlt_fmls'];
 
220
        $_SESSION['dvr']['group']['chldrn'] = $_POST['chldrn'];
 
221
        $_SESSION['dvr']['group']['dsplcd'] = $_POST['dsplcd'];
 
222
        $_SESSION['dvr']['group']['mising'] = $_POST['misng'];
 
223
        $_SESSION['dvr']['group']['dead'] = $_POST['dead'];
 
224
        $_SESSION['dvr']['group']['rehbd'] = $_POST['rehbd'];
 
225
 
 
226
 
 
227
    $loc = shn_location_get_form_submit_loc();
 
228
    $_SESSION['dvr']['group']['displaced_loc']=$loc;
 
229
 
 
230
        if ($_FILES['picture']['error'] != UPLOAD_ERR_NO_FILE) {
 
231
                $info = getimagesize($_FILES['picture']['tmp_name']);
 
232
                //check the image type 
 
233
                if ($info) {
 
234
                        list ($ignore, $ext) = split("\/", $info['mime']);
 
235
 
 
236
                        //check for save handler
 
237
 
 
238
                        $size = filesize($_FILES['picture']['tmp_name']);
 
239
                        $pic = fread(fopen($_FILES['picture']['tmp_name'], "r"), $size);
 
240
                        $_SESSION['dvr']['group']['image'] = $pic;
 
241
                        $_SESSION['dvr']['group']['image_type'] = $ext;
 
242
                        $_SESSION['dvr']['group']['image_height'] = $info[1];
 
243
                        $_SESSION['dvr']['group']['image_width'] = $info[0];
 
244
 
 
245
                }
 
246
 
 
247
                $ext = '.' . $ext;
 
248
                $upload_dir = $global['approot'] . 'www/tmp/';
 
249
                $uploadfile = $upload_dir . 'ori_'. $_SESSION['dvr']['group']['headid'] . $ext;
 
250
                move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile);
 
251
                $desc_path = $upload_dir . 'thumb_' . $_SESSION['dvr']['group']['headid'] . $ext;
 
252
                //resize the image size
 
253
                shn_image_resize($uploadfile, $desc_path, 100, 100);
 
254
 
 
255
        }
 
256
}
 
257
 
 
258
//group type and head details
 
259
function shn_dvr_grouptype_and_head_details($errors = false) {
 
260
        if ($errors)
 
261
                display_errors();
 
262
 
 
263
        shn_form_fopen("edit_group", null, array (
 
264
                'req_message' => true,
 
265
                'enctype' => 'enctype="multipart/form-data"'
 
266
        ));
 
267
?>
 
268
    <?php
 
269
        shn_form_hidden(array (
 
270
                'seq' => 'chk'
 
271
        ));
 
272
        //select the group type
 
273
        shn_form_fsopen(_t("Select Group Type"));
 
274
        print '<div class="info">';
 
275
        print _t("Please select a Group that describes you well");
 
276
        print '<br />';
 
277
//echo $_SESSION['dvr']['group']['displaced_loc'];
 
278
        print '<br />';
 
279
        print '</div>';
 
280
        print '<br />';
 
281
//echo $_SESSION['dvr']['group']['current_loc'];
 
282
        //$extra_opts['sort'] = ;
 
283
        $extra_opts['help'] = _t("Please Select the group type if you want to change the type");
 
284
        $extra_opts['req'] = true;
 
285
        $extra_opts['value'] = $_SESSION['dvr']['group']['typ_of_grp'];
 
286
        $extra_opts['sort'] = 'option_code';
 
287
 
 
288
        shn_form_opt_select('opt_group_type', _t("Type of Group"), '', $extra_opts);
 
289
 
 
290
        shn_form_fsclose();
 
291
        //group head information
 
292
        shn_form_fsopen(_t("Head Of Group"));
 
293
 
 
294
        print '<br />';
 
295
 
 
296
        $extra_opts['value'] = $_SESSION['dvr']['group']['full_name'];
 
297
        $extra_opts['help'] = _t("Enter the Full Name of the head of the group.(Required)");
 
298
        $extra_opts['req'] = true;
 
299
 
 
300
        shn_form_text(_t("Full Name"), 'full_name', null, $extra_opts);
 
301
 
 
302
        $extra_opts['value'] = $_SESSION['dvr']['group']['family_name'];
 
303
        $extra_opts['help'] = _t("Enter the Family Name.");
 
304
        $extra_opts['req'] = false;
 
305
 
 
306
        shn_form_text(_t("Family Name"), 'family_name', null, $extra_opts);
 
307
 
 
308
        $extra_opts['value'] = $_SESSION['dvr']['group']['local_name'];
 
309
        $extra_opts['help'] = _t("Enter the local Name.");
 
310
        $extra_opts['req'] = false;
 
311
 
 
312
        shn_form_text(_t("Local Name"), 'local_name', null, $extra_opts);
 
313
 
 
314
        $extra_opts['value'] = $_SESSION['dvr']['group']['nic'];
 
315
        $extra_opts['help'] = _t("Enter the National Identity Card Number if available. (Optional)");
 
316
        $extra_opts['req'] = false;
 
317
    shn_form_text(_t("NIC No"), 'nic', null, $extra_opts);
 
318
 
 
319
/*      shn_form_label(_t("Current Photograph"), $_SESSION['dvr']['group']['picture']);
 
320
?>
 
321
        <p align='center'>
 
322
        <?php
 
323
 
 
324
        //print 'headid is' . $_SESSION['dvr']['group']['headid'];
 
325
 
 
326
        shn_show_thumb_url($_SESSION['dvr']['group']['headid'], 'database', 'dvr', 'addvictim_img', false);
 
327
?>
 
328
        
 
329
        </p>
 
330
        <?php*/
 
331
 
 
332
        if (    $_SESSION['dvr']['editgroup']['edit_clicked']==true) {
 
333
                shn_form_label(_t("Current Photograph"), $_SESSION['dvr']['group']['picture']);
 
334
?>
 
335
        <p align='center'>
 
336
        <?php
 
337
 
 
338
                shn_show_thumb_url($_SESSION['dvr']['group']['headid'], '', 'dvr', 'addvictim_img', true);
 
339
?>
 
340
        
 
341
        </p>
 
342
        <?php
 
343
 
 
344
        }
 
345
        
 
346
        else
 
347
        {
 
348
                
 
349
shn_form_label(_t("Current Photograph"), $_SESSION['dvr']['group']['picture']);
 
350
?>
 
351
        <p align='center'>
 
352
        <?php
 
353
//print 'here'.$_SESSION['dvr']['group']['headid'];
 
354
                shn_show_thumb_url($_SESSION['dvr']['group']['headid'], 'database', 'dvr', 'addvictim_img', false);
 
355
?>
 
356
        
 
357
        </p>
 
358
        <?php
 
359
 
 
360
        }
 
361
 
 
362
        $extra_opts['value'] = $_SESSION['dvr']['group']['picture'];
 
363
        $extra_opts['help'] = _t("Upload the photograph if available");
 
364
        $extra_opts['req'] = false;
 
365
        shn_form_upload(_t('Upload Photograph'), "picture");
 
366
 
 
367
        $extra_opts['value'] = $_SESSION['dvr']['group']['mobile'];
 
368
        $extra_opts['help'] = _t("Enter the Mobile number if available. (Optional)");
 
369
        shn_form_text(_t("Mobile"), 'mobile', null, $extra_opts);
 
370
 
 
371
        $extra_opts['value'] = $_SESSION['dvr']['group']['telephone'];
 
372
        $extra_opts['help'] = _t("Enter a Land Phone number if available. (Optional)");
 
373
        shn_form_text(_t("Telephone"), 'telephone', null, $extra_opts);
 
374
 
 
375
        $extra_opts['value'] = $_SESSION['dvr']['group']['email'];
 
376
        $extra_opts['help'] = _t("Enter a Email Address if available. (Optional)");
 
377
        shn_form_text(_t("Email"), 'email', null, $extra_opts);
 
378
 
 
379
        $extra_opts['value'] = $_SESSION['dvr']['group']['address'];
 
380
        $extra_opts['help'] = _t("Enter a Address if available. (Optional)");
 
381
    shn_form_textarea(_t("Address"), 'address', null, $extra_opts);
 
382
 
 
383
        shn_form_fsclose();
 
384
        print '<br />';
 
385
 
 
386
        //head count
 
387
        shn_form_fsopen(_t("No Of Members In Group"));
 
388
 
 
389
        print '<br />';
 
390
        $extra_opts['value'] = $_SESSION['dvr']['group']['adlt_mls'];
 
391
        $extra_opts['help'] = _t("Enter the number of adult males in the group if known (Optional)");
 
392
        shn_form_text(_t("Adult Males"), 'adlt_mls', null, $extra_opts);
 
393
 
 
394
        $extra_opts['value'] = $_SESSION['dvr']['group']['adlt_fmls'];
 
395
        $extra_opts['help'] = _t("Enter the number of adult females in the group if known. (Optional)");
 
396
        shn_form_text(_t("Adult Females"), 'adlt_fmls', null, $extra_opts);
 
397
 
 
398
        $extra_opts['value'] = $_SESSION['dvr']['group']['chldrn'];
 
399
        $extra_opts['help'] = _t("Enter the number of children if known (Optional)");
 
400
        shn_form_text(_t("Children"), 'chldrn', null, $extra_opts);
 
401
        shn_form_fsclose();
 
402
        print '<br />';
 
403
        //member status
 
404
        shn_form_fsopen(_t("Status Of Members In Group"));
 
405
        print '<br />';
 
406
 
 
407
        $extra_opts['value'] = $_SESSION['dvr']['group']['dsplcd'];
 
408
        $extra_opts['help'] = _t("Enter the number of displaced people(Optional)");
 
409
        shn_form_text(_t("Displaced"), 'dsplcd', null, $extra_opts);
 
410
 
 
411
        $extra_opts['value'] = $_SESSION['dvr']['group']['mising'];
 
412
        $extra_opts['help'] = _t("Enter the number of missing people (Optional)");
 
413
        shn_form_text(_t("Missing"), 'misng', null, $extra_opts);
 
414
 
 
415
        $extra_opts['value'] = $_SESSION['dvr']['group']['dead'];
 
416
        $extra_opts['help'] = _t("Enter the number of deceased people (Optional)");
 
417
        shn_form_text(_t("Dead"), 'dead', null, $extra_opts);
 
418
 
 
419
        $extra_opts['value'] = $_SESSION['dvr']['group']['rehbd'];
 
420
        $extra_opts['help'] = _t("Enter the number of rehabilitated people in the group (Optional)");
 
421
        shn_form_text(_t("Rehabilitated"), 'rehbd', null, $extra_opts);
 
422
 
 
423
        shn_form_fsclose();
 
424
        
 
425
        shn_form_fsopen(_t("Displaced Location"));
 
426
    $parent = _shn_dvr_get_start_loc();
 
427
        $range = shn_dvr_get_loc_range();
 
428
//$extra_opts["camp_id"]="iswoc-1";
 
429
//      $locid = get_group_location_details($_SESSION['dvr']['group']['id'].'-disp');
 
430
//      if ($_SESSION['dvr']['editgroup']['edit_clicked'] == false)
 
431
//              shn_location($range, $locid, null, $extra_opts);
 
432
//      else{
 
433
//shn_location($range, $_SESSION['dvr']['group']['displaced_loc'], null, $extra_opts);
 
434
    shn_location($range,$_SESSION['dvr']['group']['displaced_loc'], null, $extra_opts);
 
435
 
 
436
        //}
 
437
 
 
438
        shn_form_fsclose();
 
439
        
 
440
        shn_form_submit(_t("Edit Location Check Details"), "name=location_button");
 
441
//      shn_form_submit(_t("Finish"));
 
442
        shn_form_fclose();
 
443
        print '<br />';
 
444
}
 
445
 
 
446
function shn_dvr_loc_dtls($errors = false) {
 
447
 
 
448
        global $global;
 
449
        global $conf;
 
450
        _shn_dvr_print_header(_t("Edit Group"));
 
451
 
 
452
        if ($errors)
 
453
                display_errors();
 
454
 
 
455
        shn_form_fopen("edit_group", null, array (
 
456
                'req_message' => false
 
457
        ));
 
458
        shn_form_hidden(array (
 
459
                'seq' => 'chk'
 
460
        ));
 
461
 
 
462
        /*shn_form_fsopen(_t("Displaced Location"));
 
463
 
 
464
        $range = shn_dvr_get_loc_range();
 
465
 
 
466
        shn_location($range, null, null, $extra_opts);
 
467
 
 
468
        shn_form_fsclose();
 
469
        */
 
470
        
 
471
        shn_form_fsopen(_t("Current Location"));
 
472
 
 
473
        $parent = _shn_dvr_get_start_loc();
 
474
        $range_c = shn_dvr_get_loc_range();
 
475
        
 
476
        $extra_opts['camps'] = true;
 
477
        $extra_opts['org'] = true;
 
478
        
 
479
        shn_location($range_c, $_SESSION['dvr']['group']['current_loc'], null, $extra_opts);
 
480
                
 
481
//echo $_SESSION['dvr']['group']['current_loc'];
 
482
        shn_form_fsclose();
 
483
//    if ($_SESSION['dvr']['editgroup']['edit_clicked'] == false)
 
484
//    $extra_opts["camp_id"]=_shn_dvr_get_shelter($_SESSION['dvr']['group']['id']);
 
485
//      else
 
486
//    $extra_opts["camp_id"]=$_SESSION['dvr']['group']['camps'];
 
487
        
 
488
        
 
489
//$extra_opts['camp_id']='5cn2c-2';
 
490
 
 
491
        //shn_location($range, $_POST[$range["end"]], $parent, $extra_opts);
 
492
    //shn_location($range, null, null, $extra_opts);
 
493
//      $locid = get_group_location_details($_SESSION['dvr']['group']['id'].'-curr');
 
494
//      if ($_SESSION['dvr']['editgroup']['edit_clicked'] == false){
 
495
//              $extra_opts["value"] = $locid;
 
496
//              shn_location($range, $locid, null, $extra_opts);
 
497
//              }else{
 
498
                //$extra_opts["value"] = $_SESSION['dvr']['group']['current_loc'];
 
499
                
 
500
 
 
501
        /*shn_form_fsopen(_t("Location Information"));
 
502
        echo _t("Plot the Camp/Shelter Location or Coordinates below");
 
503
        shn_form_hidden(array (
 
504
                'seq' => 'chk'
 
505
        ));
 
506
 
 
507
        shn_form_fsclose();
 
508
 
 
509
        //call gis api from gis module
 
510
        include $global['approot'] . "/inc/lib_gis/gis_fns.inc";
 
511
 
 
512
        shn_gis_add_marker_map_form("GIS Map",null,"name=checklist_button");*/
 
513
        shn_form_submit(_t("Next"), "name=checklist_button");
 
514
        //shn_form_submit(_t("Finish"));
 
515
        shn_form_fclose();
 
516
 
 
517
        print '<br />';
 
518
 
 
519
}
 
520
 
 
521
function _shn_dvr_group_location_validate_error() {
 
522
    $error = false;
 
523
        $loc = shn_location_get_form_submit_loc();
 
524
        if ($loc == -1) {
 
525
                $error = true;
 
526
                add_error(_t("Please select the current location."));
 
527
 
 
528
        }
 
529
        return $error;
 
530
}
 
531
 
 
532
function shn_dvr_set_location_details() {
 
533
 
 
534
        $loc_c = shn_location_get_form_submit_loc();
 
535
        $_SESSION['dvr']['group']['current_loc'] = $loc_c;
 
536
        
 
537
$_SESSION['dvr']['group']['camps']=$_POST['camps'];
 
538
        if ((null == $_POST['gps_x']) && null == $_POST['gps_y']) {
 
539
                $_SESSION['dvr']['group']['gis_loc_x'] = $_POST['loc_x'];
 
540
                $_SESSION['dvr']['group']['gis_loc_y'] = $_POST['loc_y'];
 
541
        } else {
 
542
                $_POST['loc_x'] = $_POST['gps_x'];
 
543
                $_POST['loc_y'] = $_POST['gps_y'];
 
544
                $_SESSION['dvr']['group']['gis_loc_x'] = $_POST['loc_x'];
 
545
                $_SESSION['dvr']['group']['gis_loc_y'] = $_POST['loc_y'];
 
546
        }
 
547
 
 
548
        //$_SESSION['dvr']['group']['displaced_loc'] = '';
 
549
        
 
550
 
 
551
        //$location = _shn_org_location_string($_SESSION['dvr']['group']['dis_loc']);
 
552
 
 
553
        //      shn_dvr_set_location_details();
 
554
}
 
555
 
 
556
function shn_dvr_cklst_and_desc() {
 
557
        _shn_dvr_print_header(_t("Edit Group"));
 
558
        shn_form_fopen("edit_group", null, array (
 
559
                'req_message' => false
 
560
        ));
 
561
 
 
562
        shn_form_fsopen(_t("Checklist"));
 
563
 
 
564
        print '<br />';
 
565
 
 
566
        //$extra_opts['value'] = $dry_rtns;
 
567
        $extra_opts['help'] = _t("Please select items tick the Check Box (Optional)");
 
568
 
 
569
        if ($_SESSION['dvr']['editgroup']['edit_clicked'] == false) {
 
570
//      $list=split( $_SESSION['dvr']['group']['opt_dvr_service'],',');
 
571
                
 
572
        $sel= explode(',', $_SESSION['dvr']['group']['opt_dvr_service']);               
 
573
                //$_SESSION['dvr']['group']['opt_dvr_service'] = explode(',', $_SESSION['dvr']['group']['opt_dvr_service']);
 
574
//print 'hell'.$x[1];
 
575
        $extra_opts['selected']=$sel;
 
576
        }
 
577
        else
 
578
        
 
579
        $extra_opts['selected'] = $_SESSION['dvr']['group']['opt_dvr_service'];
 
580
$_SESSION['dvr']['editgroup']['edit_clicked'] =false;
 
581
 
 
582
        shn_form_opt_checkbox(_t("opt_dvr_service"), $extra_opts);
 
583
 
 
584
        shn_form_fsclose();
 
585
 
 
586
        print '<br />';
 
587
 
 
588
        shn_form_fsopen(_t("Group Description"));
 
589
 
 
590
        print '<br />';
 
591
 
 
592
        $extra_opts['value'] = $_SESSION['dvr']['group']['other'];
 
593
        $extra_opts['help'] = _t("Enter the group description. (Optional)");
 
594
        shn_form_textarea(_t("Description"), 'desc', null, $extra_opts);
 
595
        
 
596
        
 
597
        shn_form_submit(_t("Finish"), 'name="end_button"');
 
598
 
 
599
        shn_form_fsclose();
 
600
 
 
601
        shn_form_fclose();
 
602
        print '<br />';
 
603
 
 
604
}
 
605
 
 
606
function _shn_dvr_set_checklist() {
 
607
        $dvr_service = $_POST['opt_dvr_service'];
 
608
 
 
609
        $_SESSION['dvr']['group']['opt_dvr_service'] = $dvr_service;
 
610
        $_SESSION['dvr']['group']['other'] = $_POST['desc'];
 
611
 
 
612
}
 
613
 
 
614
function _shn_dvr_regconfirm_group() {
 
615
        global $global;
 
616
        global $conf;
 
617
        $db = $global['db'];
 
618
?>
 
619
<h2><?php echo  _t('Confirm Group Details  Headed by ').$_SESSION['dvr']['group']['full_name'] ?></h2>
 
620
 
 
621
<div id="formcontainer">
 
622
 
 
623
<?php
 
624
 
 
625
 
 
626
        shn_form_fopen("edit_group", null,false);
 
627
 
 
628
        shn_form_fsopen(_t('Group type and head details'));
 
629
 
 
630
        shn_form_label(_t("Group type: "), _shn_dvr_getoptiondescription($_SESSION['dvr']['group']['typ_of_grp']));
 
631
        shn_form_label(_t("Full name"), $_SESSION['dvr']['group']['full_name']);
 
632
        shn_form_label(_t("Family name"), $_SESSION['dvr']['group']['family_name']);
 
633
        shn_form_label(_t("Local name"), $_SESSION['dvr']['group']['local_name']);
 
634
        shn_form_label(_t("NIC"), $_SESSION['dvr']['group']['nic']);
 
635
        shn_form_label(_t("Photograph"), $_SESSION['dvr']['group']['picture']);
 
636
?>
 
637
        <p align='center'>
 
638
        <?php
 
639
 
 
640
//      if ($_SESSION['dvr']['group']['picture'] != null)
 
641
                shn_show_thumb_url($_SESSION['dvr']['group']['headid'], '', 'dvr', 'addvictim_img', true);
 
642
        //else
 
643
                //shn_show_thumb_url($_SESSION['dvr']['group']['headid'], 'database', 'dvr', 'addvictim_img', false);
 
644
?>
 
645
        
 
646
        </p>
 
647
        <?php
 
648
 
 
649
 
 
650
        shn_form_label(_t("Mobile"), $_SESSION['dvr']['group']['mobile']);
 
651
        shn_form_label(_t("Telephone"), $_SESSION['dvr']['group']['telephone']);
 
652
        shn_form_label(_t("Email"), $_SESSION['dvr']['group']['email']);
 
653
        shn_form_label(_t("Address"), $_SESSION['dvr']['group']['address']);
 
654
        shn_form_fsclose();
 
655
        shn_form_fsopen(_t("Member Count"));
 
656
        shn_form_label(_t("Adult Males"), $_SESSION['dvr']['group']['adlt_mls']);
 
657
        shn_form_label(_t("Adult Females"), $_SESSION['dvr']['group']['adlt_fmls']);
 
658
        shn_form_label(_t("Children"), $_SESSION['dvr']['group']['chldrn']);
 
659
        shn_form_fsclose();
 
660
 
 
661
        shn_form_fsopen(_t("Status of Members in Group"));
 
662
        shn_form_label(_t("Displaced"), $_SESSION['dvr']['group']['dsplcd']);
 
663
        shn_form_label(_t("Missing"), $_SESSION['dvr']['group']['mising']);
 
664
        shn_form_label(_t("Dead"), $_SESSION['dvr']['group']['dead']);
 
665
        shn_form_label(_t("Rehabilitated"), $_SESSION['dvr']['group']['rehbd']);
 
666
        shn_form_fsclose();
 
667
 
 
668
        shn_form_fsopen("Location");
 
669
        $location = _shn_org_location_string($_SESSION['dvr']['group']['displaced_loc']);
 
670
 
 
671
        shn_form_label(_t("Displaced Location"), $location);
 
672
        $location = _shn_org_location_string($_SESSION['dvr']['group']['current_loc']);
 
673
 
 
674
        $map_location = "Latitude= " . $_SESSION['dvr']['group']['gis_loc_x'] . " Longitude= " . $_SESSION['dvr']['group']['gis_loc_y'];
 
675
 
 
676
        shn_form_label(_t("Current Location"), $location);
 
677
        //shn_form_label(_t("Current Map Location"), $map_location);
 
678
        shn_form_fsclose();
 
679
 
 
680
        // Contact infomation
 
681
        shn_form_fsopen(_t("Checklist Information"));
 
682
 
 
683
        $checklist = _shn_dvr_getchecklist();
 
684
        $count = $_SESSION['elementcount'];
 
685
        $selected = array ();
 
686
 
 
687
        $selected = $_SESSION['dvr']['group']['opt_dvr_service'];
 
688
 
 
689
        for ($l = 0; $l < count($selected); $l++) {
 
690
 
 
691
                $opt = _shn_dvr_getoptiondescription($selected[$l]);
 
692
 
 
693
                shn_form_label(_t($opt), 'Required');
 
694
        }
 
695
    
 
696
        shn_form_label(_t('Description'), $_SESSION['dvr']['group']['other']);
 
697
        
 
698
        shn_form_fsclose();
 
699
?>
 
700
<br />
 
701
<center>
 
702
<?php
 
703
 
 
704
 
 
705
        //create the submit button
 
706
        $extra_opts['br'] = false;
 
707
 
 
708
        shn_form_submit(_t("Save"), 'name="save"');
 
709
 
 
710
        shn_form_submit(_t("Edit Details"), "name=edit_details");
 
711
        shn_form_hidden(array (
 
712
                'action' => '0'
 
713
        ));
 
714
        // _shn_dvr_action_change_javascript("confirm_reg","action");
 
715
?>
 
716
</center>
 
717
<br />
 
718
<?php
 
719
 
 
720
 
 
721
        //close the form
 
722
        shn_form_fclose();
 
723
?>                                   
 
724
</div>
 
725
<?php
 
726
 
 
727
 
 
728
        // end of form
 
729
}
 
730
//shn_dvr_mbr_confirm();
 
731
 
 
732
function shn_dvr_mbr_confirm() {
 
733
 
 
734
        $msg = $_SESSION['dvr']['group']['name'] ._t(" group was succesfully updated ");
 
735
        add_confirmation($msg);
 
736
}
 
737
function _shn_dvr_commit() {
 
738
 
 
739
        global $global;
 
740
 
 
741
        include_once ($global['approot'] . '/mod/dvr/data_access.inc');
 
742
        _shn_dvr_update_group();
 
743
}
 
744
?>