// Clear all previous errors $_SESSION['errors'] = array(); $_SESSION['form_data'] = array(); // Get form data from POST fields foreach ($_POST as $key => $value) { $_SESSION['form_data'][$key] = $value; } $_SESSION['form_data']['id_org'] = intval(_session('id_org', 0)); $ref_upd_org = 'edit_org.php?org=' . _session('id_org'); if ($_SERVER['HTTP_REFERER']) { $ref_upd_org = $_SERVER['HTTP_REFERER']; } // // Update data // $obj_org = new LcmOrg(_session('id_org')); $errs = $obj_org->save(); if (count($errs)) { $_SESSION['errors'] = array_merge($_SESSION['errors'], $errs); lcm_header("Location: " . $ref_upd_org); exit; } // // Attach to case // if (_session('attach_case')) { lcm_query("INSERT INTO lcm_case_client_org\n\t\t\t\tSET id_case = " . _session('attach_case') . ",\n\t\t\t\t\tid_org = " . $obj_org->getDataInt('id_org')); } // // Go to the 'view details' page of the organisation //
if (_request('add_client')) { include_lcm('inc_obj_client'); $client = new LcmClient(); $errs = $client->save(); if (count($errs)) { $_SESSION['errors'] = array_merge($_SESSION['errors'], $errs); } else { $_SESSION['form_data']['attach_client'] = $client->getDataInt('id_client', '__ASSERT__'); } } // // Create organisation, if requested // if (_request('add_org')) { include_lcm('inc_obj_org'); $org = new LcmOrg(); $errs = $org->save(); if (count($errs)) { $_SESSION['errors'] = array_merge($_SESSION['errors'], $errs); } else { $_SESSION['form_data']['attach_org'] = $org->getDataInt('id_org', '__ASSERT__'); } } // // Create or update case data // $case = new LcmCase($id_case); $errs = $case->save(); if (count($errs)) { $_SESSION['errors'] = array_merge($_SESSION['errors'], $errs); lcm_header("Location: " . $_SERVER['HTTP_REFERER']);