Esempio n. 1
0
 function save($id = FALSE)
 {
     if ($_POST) {
         $meeting = new Meeting($id);
         $_POST['start_date'] = Date2DB($_POST['start_date']);
         $_POST['end_date'] = Date2DB($_POST['end_date']);
         $_POST['close_date'] = Date2DB($_POST['close_date']);
         $meeting->from_array($_POST);
         $meeting->save();
         fix_file($_FILES['file']);
         foreach ($_POST['doc'] as $key => $doc) {
             if (@$_FILES['file'][$key]['name'] || @$_POST['doc_id'][$key]) {
                 $document = new Meeting_document(@$_POST['doc_id'][$key]);
                 if ($_FILES['file'][$key]['name']) {
                     if (@$_POST['doc_id'][$key]) {
                         $document->delete_file('uploads/meeting', 'file');
                     }
                     $document->file = $document->upload($_FILES['file'][$key], 'uploads/meeting');
                 }
                 $document->name = $doc;
                 $document->meeting_id = $meeting->id;
                 $document->save();
             }
         }
         set_notify('success', lang('save_data_complete'));
     }
     redirect('meetings');
 }