senses-designertravelv3 /application/modules/qualification/controllers/qualifications.php

Language PHP Lines 133
MD5 Hash dd98015645aa60e2f6f453e77db90bc0 Estimated Cost $2,131 (why?)
Repository https://bitbucket.org/matyhaty/senses-designertravelv3 View Raw File View Project SPDX
  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
<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Qualifications extends Base_Controller
{

    /**
     * Constructor for profile page
     *
     */
    function __construct()
    {
        $this->load->library('form_validation');
        $this->load->helper(array(
            'form',
            'url'
        ));
        parent::__construct('Qualification');

    }

    public function edit($userID)
    {
        // Load the email helper
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->helper('upload');
        $this->load->library('form_validation');
        $this->load->library('session');

        //log_message('error', 'hello edit quallys');

        $qualification = $this->model;
        $formdata = $this->xml_forms->loadXML(APPPATH . 'modules/qualification/forms', 'qualifications');
        //$formdropdowns['qualification']  	= qualificationtype::getOptions($currentFlag = NULL);

            //var_dump($_POST);

        if ($this->input->post() && $userID)
        {
            if ($this->form_validation->run() == TRUE)
            {
                $data = $this->input->post();
                $userid = $this->session->userdata('userid');
                $saved = DMZ_Array::from_array($qualification, $data, NULL, TRUE);

                // Save the job
                if ($saved)
                {
                    
                    // relate to qualifcation type
                    $qt = new Qualificationtype($data['qualification']);
                    $qualification->save($qt);
                    $u = new User($userID);
                    $qualification->save($u);
                    
                    // delete this users cache for qualifcations 
                    $this->model->removeCachedObject('qualification', null, $u, false, null, '', '');
                    

                    // Save Files
                    $this->teamleaf->checkpath($userID . '/qualifications');
                    $config['upload_path'] = UPLOAD_PATH . $userID . '/qualifications/';
                    $config['allowed_types'] = '*'; // ONLY WORKS ON THE WILDCARD - UNKNOWN REASON!
                    $config['max_size'] = '100000';
                    $this->load->library('upload', $config);


                    multifile_array();              // HELPER SORTS OUT THE FILE ARRAY SO DO_UPLOAD CAN RUN
                    foreach ($_FILES as $file => $file_data)
                    {
                        $this->upload->initialize($config);
                        if(!$this->upload->do_upload($file))
                        {
                            echo $this->upload->display_errors('<p>', '</p>');
							echo 'Upload Path is: '.$config['upload_path'];
                        }
                        else
                        {
                            // save file into DB
                            $uploaded = new File();
                            $filedata = $this->upload->data();
                            //print_r($filedata);
                            $saved = DMZ_Array::from_array($uploaded, $filedata, NULL, TRUE);
                            // and relate to qually
                            $uploaded->save($qualification);
                        }

                    }
                    $errors = '';
                    //-------   Upload the potential 4 files
                    
                    
                    $clearCache = true;
                    echo $qualification->getQualifications($userID, $clearCache);

                }
                else
                {
                    echo 'Save Error<hr>';
                    echo validation_errors();
                }
            }
            else
            {
                echo 'Failed validation: '.validation_errors();
            }

        }
        else
        {
            // Load the view
            $form = $this->xml_forms->createform($formdata['xml'], $this->user, $formdropdowns, array(
                'nosheet' => 1,
                'grid' => ''
            ));
            echo $form;
        }

    }

    public function delete($id, $userID)
    {
           $qualification = new Qualification();
           $qualification->deleteQualification($id, $userID);
           redirect('admin/user/profile/display/'.$userID);
    }

}

//end class
Back to Top