X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fcreate_coy.php;h=ef6c93f8711658f4eeb4943bbfa4f0dfa3bd1ed1;hb=02dd4aefa3e3babb64d61140bb7f7de14e37f755;hp=6667ea451e85da955df725451a9f3ab917642748;hpb=49d2702ed98abe7a564a4abb4c8c5fa225f362e8;p=fa-stable.git diff --git a/admin/create_coy.php b/admin/create_coy.php index 6667ea45..ef6c93f8 100644 --- a/admin/create_coy.php +++ b/admin/create_coy.php @@ -80,10 +80,10 @@ function remove_connection($id) { function handle_submit() { global $db_connections, $def_coy, $tb_pref_counter, $db, - $comp_path, $comp_subdirs; + $comp_path, $comp_subdirs, $path_to_root; $new = false; - + $error = false; if (!check_data()) return false; @@ -115,25 +115,30 @@ function handle_submit() if (($db = db_create_db($conn)) == 0) { display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually")); - remove_connection($id); - set_global_connection(); - return false; - } + $error = true; + } else { - $filename = $_FILES['uploadfile']['tmp_name']; - if (is_uploaded_file ($filename)) - { - db_import($filename, $conn, $id); - if (isset($_POST['admpassword']) && $_POST['admpassword'] != "") - update_admin_password($conn, md5($_POST['admpassword'])); + $filename = $_FILES['uploadfile']['tmp_name']; + if (is_uploaded_file ($filename)) + { + if (!db_import($filename, $conn, $id)) { + display_error(_('Cannot create new company due to bugs in sql file.')); + $error = true; + } else + if (isset($_POST['admpassword']) && $_POST['admpassword'] != "") + update_admin_password($conn, md5($_POST['admpassword'])); + } + else + { + display_error(_("Error uploading Database Script, please upload it manually")); + $error = true; + } } - else - { - display_error(_("Error uploading Database Script, please upload it manually")); - set_global_connection(); + set_global_connection(); + if ($error) { + remove_connection($id); return false; } - set_global_connection(); } $error = write_config_db($new); if ($error == -1) @@ -153,6 +158,7 @@ function handle_submit() } $exts = get_company_extensions(); write_extensions($exts, $id); + display_notification($new ? _('New company has been created.') : _('Company has been updated.')); return true; } @@ -218,8 +224,7 @@ function handle_delete() display_error(_("Cannot remove temporary renamed company data directory ") . $tmpname); return; } - - meta_forward($_SERVER['PHP_SELF']); + display_notification(_("Selected company as been deleted")); } //--------------------------------------------------------------------------------------------- @@ -359,19 +364,14 @@ function display_company_edit($selected_id) //--------------------------------------------------------------------------------------------- -if (isset($_GET['c']) && $_GET['c'] == 'df') -{ - +if (isset($_GET['c']) && $_GET['c'] == 'df') { handle_delete(); + $selected_id = -1; } if (isset($_GET['c']) && $_GET['c'] == 'u') -{ if (handle_submit()) - { - meta_forward($_SERVER['PHP_SELF']); - } -} + $selected_id = -1; //---------------------------------------------------------------------------------------------