Esempio n. 1
0
    }
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Execute actions
 *
 *********************************************************************************/
if (!$fatal_error) {
    switch ($action) {
        case 'add':
            try {
                $new_category = Category::add($database, $current_user, $log, $new_name, $new_parent_id, $new_disable_footprints, $new_disable_manufacturers, $new_disable_autodatasheets);
                $html->set_variable('refresh_navigation_frame', true, 'boolean');
                if (!$add_more) {
                    $selected_category = $new_category;
                    $selected_id = $selected_category->get_id();
                }
            } catch (Exception $e) {
                $messages[] = array('text' => 'Die neue Kategorie konnte nicht angelegt werden!', 'strong' => true, 'color' => 'red');
                $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
            }
            break;
        case 'delete':
            try {
                if (!is_object($selected_category)) {
                    throw new Exception('Es ist keine Kategorie markiert oder es trat ein Fehler auf!');
                }
                $parts = $selected_category->get_parts();
Esempio n. 2
0
    $system = new System($database, $log);
    $current_user = new User($database, $current_user, $log, 1);
    // admin
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Database Update (if required and automatic updates are enabled)
 *
 *********************************************************************************/
if (!$fatal_error && $database->is_update_required()) {
    if ($database->get_current_version() < 13 && $database->get_latest_version() >= 13) {
        $config['db']['auto_update'] = false;
        $html->set_variable('auto_disabled_autoupdate', true, 'boolean');
    }
    $html->set_variable('database_update', true, 'boolean');
    $html->set_variable('disabled_autoupdate', !$config['db']['auto_update'], 'boolean');
    $html->set_variable('db_version_current', $database->get_current_version(), 'integer');
    $html->set_variable('db_version_latest', $database->get_latest_version(), 'integer');
    if ($config['db']['auto_update'] == true) {
        $update_log = $database->update();
        $html->set_variable('database_update_log', nl2br($update_log));
    }
}
/********************************************************************************
 *
 *   Show a warning if there are empty tables
 *       (categories, storelocations, footprints, suppliers)
 *
Esempio n. 3
0
    $root_category = new Category($database, $current_user, $log, 0);
    $root_device = new Device($database, $current_user, $log, 0);
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Build Navigation Trees
 *
 *********************************************************************************/
$html->use_javascript(array('dtree', 'toggle'));
if (!$fatal_error) {
    try {
        $javascript = $root_category->build_javascript_tree('cat_navtree', 'show_category_parts.php', 'cid', 'content_frame');
        $html->set_variable('categories_navtree', $javascript);
        $javascript = $root_device->build_javascript_tree('cat_devtree', 'show_device_parts.php', 'device_id', 'content_frame', true, true, 'Übersicht', false, true);
        $html->set_variable('devices_navtree', $javascript);
    } catch (Exception $e) {
        $messages[] = array('text' => 'Die Navigationsmenüs konnten nicht erfolgreich erstellt werden!', 'strong' => true, 'color' => 'red');
        $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_variable('disable_footprints', $config['footprints']['disable'], 'boolean');
$html->set_variable('disable_manufacturers', $config['manufacturers']['disable'], 'boolean');
$html->set_variable('disable_devices', $config['devices']['disable'], 'boolean');
Esempio n. 4
0
                    throw new Exception('Es ist kein Lieferant markiert oder es trat ein Fehler auf!');
                }
                $selected_supplier->set_attributes(array('name' => $new_name, 'parent_id' => $new_parent_id, 'address' => $new_address, 'phone_number' => $new_phone_number, 'fax_number' => $new_fax_number, 'email_address' => $new_email_address, 'website' => $new_website, 'auto_product_url' => $new_auto_product_url));
            } catch (Exception $e) {
                $messages[] = array('text' => 'Die neuen Werte konnten nicht gespeichert werden!', 'strong' => true, 'color' => 'red');
                $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
            }
            break;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_variable('add_more', $add_more, 'boolean');
if (!$fatal_error) {
    try {
        if (is_object($selected_supplier)) {
            $parent_id = $selected_supplier->get_parent_id();
            $html->set_variable('id', $selected_supplier->get_id(), 'integer');
            $html->set_variable('name', $selected_supplier->get_name(), 'string');
            $html->set_variable('address', $selected_supplier->get_address(), 'string');
            $html->set_variable('phone_number', $selected_supplier->get_phone_number(), 'string');
            $html->set_variable('fax_number', $selected_supplier->get_fax_number(), 'string');
            $html->set_variable('email_address', $selected_supplier->get_email_address(), 'string');
            $html->set_variable('website', $selected_supplier->get_website(), 'string');
            $html->set_variable('auto_product_url', $selected_supplier->get_auto_product_url(NULL), 'string');
        } elseif ($action == 'add') {
            $parent_id = $new_parent_id;
        } else {
Esempio n. 5
0
        $table_loop = Part::build_template_table_array($parts, 'noprice_parts');
        $html->set_loop('table', $table_loop);
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
        $fatal_error = true;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->use_javascript(array('popup'));
if (!$fatal_error) {
    // global stuff
    $html->set_variable('disable_footprints', $config['footprints']['disable'], 'boolean');
    $html->set_variable('disable_manufacturers', $config['manufacturers']['disable'], 'boolean');
    $html->set_variable('disable_auto_datasheets', $config['auto_datasheets']['disable'], 'boolean');
    $html->set_variable('use_modal_popup', $config['popup']['modal'], 'boolean');
    $html->set_variable('popup_width', $config['popup']['width'], 'integer');
    $html->set_variable('popup_height', $config['popup']['height'], 'integer');
}
/********************************************************************************
 *
 *   Generate HTML Output
 *
 *********************************************************************************/
$html->print_header($messages);
if (!$fatal_error) {
    $html->print_template('show_noprice_parts');
}
Esempio n. 6
0
             throw new Exception('Datei konnte nicht hochgeladen werden!');
         }
         $file_content = file_get_contents($_FILES['uploaded_file']['tmp_name']);
         $import_data = import_text_to_array($file_content, $file_format, $separator);
         $table_loop = build_parts_import_template_loop($database, $current_user, $log, $import_data);
     } catch (Exception $e) {
         $messages[] = array('text' => 'Es gab ein Fehler!', 'strong' => true, 'color' => 'red');
         $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
     }
     break;
 case 'check_data':
     try {
         $import_data = extract_import_data_from_request($table_rowcount);
         $table_loop = build_parts_import_template_loop($database, $current_user, $log, $import_data);
         import_parts($database, $current_user, $log, $import_data, true);
         $html->set_variable('data_is_valid', true, 'boolean');
         // now the "import" button will be visible
         $messages[] = array('text' => 'Die Daten sind gültig!', 'strong' => true, 'color' => 'darkgreen');
     } catch (Exception $e) {
         $messages[] = array('text' => 'Die Daten sind nicht gültig!', 'strong' => true, 'color' => 'red');
         $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
     }
     break;
 case 'import_data':
     try {
         $import_data = extract_import_data_from_request($table_rowcount);
         $table_loop = build_parts_import_template_loop($database, $current_user, $log, $import_data);
         $new_parts = import_parts($database, $current_user, $log, $import_data, false);
         $html->set_variable('refresh_navigation_frame', true, 'boolean');
         $messages[] = array('text' => 'Die Daten wurden erfolgreich importiert!', 'strong' => true, 'color' => 'darkgreen');
         unset($import_data);
Esempio n. 7
0
    }
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Execute actions
 *
 *********************************************************************************/
if (!$fatal_error) {
    switch ($action) {
        case 'add':
            try {
                $new_device = Device::add($database, $current_user, $log, $new_name, $new_parent_id);
                $html->set_variable('refresh_navigation_frame', true, 'boolean');
                if (!$add_more) {
                    $selected_device = $new_device;
                    $selected_id = $selected_device->get_id();
                }
            } catch (Exception $e) {
                $messages[] = array('text' => 'Die neue Baugruppe konnte nicht angelegt werden!', 'strong' => true, 'color' => 'red');
                $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
            }
            break;
        case 'delete':
            try {
                if (!is_object($selected_device)) {
                    throw new Exception('Es ist keine Baugruppe markiert oder es trat ein Fehler auf!');
                }
                $parts = $selected_device->get_parts();
Esempio n. 8
0
         // enable write permissions
         $filehandle = fopen(DOKUWIKI_PERMS_FILENAME, 'w');
         if (!$filehandle) {
             $messages[] = array('text' => 'Die Datei "' . DOKUWIKI_PERMS_FILENAME . '" kann nicht gelöscht werden! ' . 'Überprüfen Sie, ob Sie die nötigen Schreibrechte besitzen.', 'strong' => true, 'color' => 'red');
         } else {
             fclose($filehandle);
         }
     } elseif (!$enable_dokuwiki_write_perms && file_exists(DOKUWIKI_PERMS_FILENAME)) {
         // disable write permissions
         if (!unlink(DOKUWIKI_PERMS_FILENAME)) {
             $messages[] = array('text' => 'Die Datei "' . DOKUWIKI_PERMS_FILENAME . '" kann nicht gelöscht werden! ' . 'Überprüfen Sie, ob Sie die nötigen Schreibrechte besitzen.', 'strong' => true, 'color' => 'red');
         }
     }
     try {
         save_config();
         $html->set_variable('refresh_navigation_frame', true, 'boolean');
         //header('Location: system_config.php'); // Reload the page that we can see if the new settings are stored successfully --> does not work correctly?!
     } catch (Exception $e) {
         $config = $config_old;
         // reload the old config
         $messages[] = array('text' => 'Die neuen Werte konnten nicht gespeichert werden!', 'strong' => true, 'color' => 'red');
         $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
     }
     break;
 case 'change_admin_password':
     try {
         if ($config['is_online_demo']) {
             throw new Exception('Diese Funktion steht in der Online-Demo nicht zur Verfügung!');
         }
         // set_admin_password() throws an exception if the old or the new passwords are not valid
         set_admin_password($current_admin_password, $new_admin_password_1, $new_admin_password_2, false);
Esempio n. 9
0
    // admin
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Set all HTML variables
 *
 *********************************************************************************/
if (!$fatal_error) {
    try {
        $noprice_parts = Part::get_noprice_parts($database, $current_user, $log);
        $count_of_parts_with_price = Part::get_count($database) - count($noprice_parts);
        // :-)
        $html->set_variable('parts_count_with_prices', $count_of_parts_with_price, 'integer');
        $html->set_variable('parts_count_sum_value', Part::get_sum_price_instock($database, $current_user, $log, true), 'string');
        $html->set_variable('parts_count', Part::get_count($database), 'integer');
        $html->set_variable('parts_count_sum_instock', Part::get_sum_count_instock($database), 'integer');
        $html->set_variable('categories_count', Category::get_count($database), 'integer');
        $html->set_variable('footprint_count', Footprint::get_count($database), 'integer');
        $html->set_variable('location_count', Storelocation::get_count($database), 'integer');
        $html->set_variable('suppliers_count', Supplier::get_count($database), 'integer');
        $html->set_variable('manufacturers_count', Manufacturer::get_count($database), 'integer');
        $html->set_variable('devices_count', Device::get_count($database), 'integer');
        $html->set_variable('attachements_count', Attachement::get_count($database), 'integer');
        $html->set_variable('footprint_picture_count', count(find_all_files(BASE . '/img/footprints/', true)), 'integer');
        $html->set_variable('iclogos_picture_count', count(find_all_files(BASE . '/img/iclogos/', true)), 'integer');
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
        $fatal_error = true;
Esempio n. 10
0
}
if (isset($reload_site) && $reload_site && !$config['debug']['request_debugging_enable']) {
    // reload the site to avoid multiple actions by manual refreshing
    header('Location: show_order_parts.php?selected_supplier_id=' . $selected_supplier_id);
}
/********************************************************************************
 *
 *   Generate Supplier Dropdown-List
 *
 *********************************************************************************/
if (!$fatal_error) {
    try {
        $suppliers = Supplier::get_order_suppliers($database, $current_user, $log);
        $supplier_loop = get_suppliers_template_loop($suppliers, $selected_supplier_id);
        $html->set_loop('suppliers', $supplier_loop);
        $html->set_variable('selected_supplier_id', $selected_supplier_id, 'integer');
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
        $fatal_error = true;
    }
}
/********************************************************************************
 *
 *   Generate "Parts to order"-Table
 *
 *********************************************************************************/
if (!$fatal_error) {
    try {
        if ($selected_supplier_id > 0) {
            $parts = Part::get_order_parts($database, $current_user, $log, array($selected_supplier_id));
        } else {
Esempio n. 11
0
// try to save the config array in config.php --> fatal error if this does not work!
try {
    save_config();
} catch (Exception $e) {
    $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Decide which installation step should be displayed next
 *   and set the rest of the HTML variables
 *
 *********************************************************************************/
if (!$fatal_error) {
    // global variables
    $html->set_variable('system_version', $system_version->as_string(false, true, true, false), 'string');
    $html->set_variable('system_version_full', $system_version->as_string(false, false, false, true), 'string');
    if (!$config['installation_complete']['locales']) {
        // step "set_locales"
        $tmpl_site_to_show = 'set_locales';
        $html->set_loop('timezone_loop', array_to_template_loop($config['timezones'], $config['timezone']));
        $html->set_loop('language_loop', array_to_template_loop($config['languages'], $config['language']));
    } elseif (!$config['installation_complete']['admin_password']) {
        $tmpl_site_to_show = 'set_admin_password';
    } elseif (!$config['installation_complete']['database']) {
        // step "set_db_settings"
        $tmpl_site_to_show = 'set_db_settings';
        $html->set_loop('db_type_loop', array_to_template_loop($config['db_types'], $config['db']['type']));
        $html->set_loop('db_charset_loop', array_to_template_loop($config['db_charsets'], $config['db']['charset']));
        $html->set_variable('db_host', $config['db']['host'], 'string');
        $html->set_variable('db_name', $config['db']['name'], 'string');
Esempio n. 12
0
            $remove_spaces_successful = tab2spaces($trim_exec_output, $tab2spaces_output_loop);
            break;
        case 'build_release_package':
            $release_packing_successful = build_release_package($trim_exec_output, $release_packing_output_loop);
            break;
        case 'delete_release_package':
            unlink($release_package_filename);
            break;
    }
}
/********************************************************************************
 *
 *   Set all HTML variables
 *
 *********************************************************************************/
$html->set_variable('current_system_version', $config['system']['version'], 'string');
if (file_exists($release_package_filename)) {
    $html->set_variable('release_archive_link', str_replace(BASE, BASE_RELATIVE, $release_package_filename), 'string');
    $html->set_variable('release_archive_basename', basename($release_package_filename), 'string');
}
$html->set_variable('packing_checklist_link', BASE_RELATIVE . '/development/package_output/readme.txt', 'string');
if (isset($doxygen_output_loop)) {
    //$html->set_variable('exec_successful', $doxygen_successful, 'boolean');
    $html->set_loop('exec_output', $doxygen_output_loop);
}
if (isset($tab2spaces_output_loop)) {
    //$html->set_variable('exec_successful', $tab2spaces_successful, 'boolean');
    $html->set_loop('exec_output', $tab2spaces_output_loop);
}
if (isset($release_packing_output_loop)) {
    //$html->set_variable('exec_successful', $release_packing_successful, 'boolean');
                    throw new Exception('Es ist kein Dateityp markiert oder es trat ein Fehler auf!');
                }
                $selected_attachement_type->set_attributes(array('name' => $new_name, 'parent_id' => $new_parent_id));
            } catch (Exception $e) {
                $messages[] = array('text' => 'Die neuen Werte konnten nicht gespeichert werden!', 'strong' => true, 'color' => 'red');
                $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
            }
            break;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_variable('add_more', $add_more, 'boolean');
if (!$fatal_error) {
    try {
        if (is_object($selected_attachement_type)) {
            $parent_id = $selected_attachement_type->get_parent_id();
            $html->set_variable('id', $selected_attachement_type->get_id(), 'integer');
            $name = $selected_attachement_type->get_name();
        } elseif ($action == 'add') {
            $parent_id = $new_parent_id;
            $name = $new_name;
        } else {
            $parent_id = 0;
            $name = '';
        }
        $html->set_variable('name', $name, 'string');
        $attachement_types_list = $root_attachement_type->build_html_tree($selected_id, true, false);
Esempio n. 14
0
            foreach ($update_log as $message) {
                $messages[] = array('text' => nl2br($message['text']), 'color' => $message['error'] == true ? 'red' : 'black');
            }
        } catch (Exception $e) {
            $messages[] = array('text' => 'Es trat ein Fehler auf!', 'strong' => true, 'color' => 'red');
            $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
        }
        $messages[count($messages) - 1]['text'] .= nl2br("\n");
        break;
}
/********************************************************************************
 *
 *   Set all HTML variables
 *
 *********************************************************************************/
$html->set_variable('is_online_demo', $config['is_online_demo'], 'boolean');
$html->set_loop('db_type_loop', array_to_template_loop($config['db_types'], $config['db']['type']));
$html->set_loop('db_charset_loop', array_to_template_loop($config['db_charsets'], $config['db']['charset']));
$html->set_variable('db_host', $config['db']['host'], 'string');
$html->set_variable('db_name', $config['db']['name'], 'string');
$html->set_variable('db_user', $config['db']['user'], 'string');
$html->set_variable('automatic_updates_enabled', $config['db']['auto_update'], 'boolean');
$html->set_variable('refresh_navigation_frame', isset($database_update_executed) && $database_update_executed, 'boolean');
if (!$fatal_error) {
    try {
        $current = $database->get_current_version();
        $latest = $database->get_latest_version();
        $html->set_variable('current_version', $current, 'integer');
        $html->set_variable('latest_version', $latest, 'integer');
        $html->set_variable('update_required', $latest > $current, 'boolean');
        $html->set_variable('last_update_failed', $config['db']['update_error']['version'] == $current, 'boolean');
Esempio n. 15
0
 *
 *   Check if all installation steps are done. If not, go to the installer.
 *
 *********************************************************************************/
if (!is_array($config['installation_complete']) || in_array(false, $config['installation_complete'], true)) {
    header('Location: install.php');
    // ...then go to the installation page
    exit;
}
/********************************************************************************
 *
 *   Initialize Objects
 *
 *********************************************************************************/
$html = new HTML($config['html']['theme'], $config['html']['custom_css'], $config['page_title']);
$html->set_variable('title', $config['page_title'], 'string');
/********************************************************************************
 *
 *   Check if client is a mobile device
 *
 *********************************************************************************/
/*$mobile = false;
    if (isset($_SERVER["HTTP_USER_AGENT"]))
    {
        $agents = array(
            'Windows CE', 'Pocket', 'Mobile',
            'Portable', 'Smartphone', 'SDA',
            'PDA', 'Handheld', 'Symbian',
            'WAP', 'Palm', 'Avantgo',
            'cHTML', 'BlackBerry', 'Opera Mini',
            'Nokia', 'PSP', 'J2ME'
Esempio n. 16
0
                $proposed_filenames_loop = array();
                $proposed_filenames = get_proposed_filenames($footprint->get_filename(), $available_proposed_files);
                if (count($proposed_filenames) > 0 && pathinfo($proposed_filenames[0], PATHINFO_FILENAME) == pathinfo($footprint->get_filename(), PATHINFO_FILENAME)) {
                    $exact_match = true;
                } else {
                    $exact_match = false;
                }
                foreach ($proposed_filenames as $index => $filename) {
                    $filename = str_replace(BASE . '/', '', $filename);
                    $proposed_filenames_loop[] = array('selected' => $index == 0 && $exact_match, 'proposed_filename' => $filename);
                }
                $broken_filename_loop[] = array('index' => $i, 'checked' => $exact_match, 'broken_id' => $footprint->get_id(), 'broken_full_path' => $footprint->get_full_path(), 'broken_filename' => str_replace(BASE . '/', '', $footprint->get_filename()), 'proposed_filenames_count' => count($proposed_filenames_loop), 'proposed_filenames' => $proposed_filenames_loop);
            }
            $html->set_loop('broken_filename_footprints', $broken_filename_loop);
        }
        $html->set_variable('broken_footprints_count', count($broken_filename_loop), 'integer');
        $html->set_variable('broken_footprints_count_total', count($broken_filename_footprints), 'integer');
    } catch (Exception $e) {
        $messages[] = array('text' => 'Es konnten nicht alle Footprints mit defektem Dateinamen aufgelistet werden!', 'strong' => true, 'color' => 'red');
        $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_variable('add_more', $add_more, 'boolean');
if (!$fatal_error) {
    try {
        if (is_object($selected_footprint)) {
Esempio n. 17
0
                } catch (Exception $e) {
                    $messages[] = array('text' => 'Die neuen Werte konnten nicht gespeichert werden!', 'strong' => true, 'color' => 'red');
                    $messages[] = array('text' => 'Fehlermeldung: ' . nl2br($e->getMessage()), 'color' => 'red');
                }
            } else {
                $messages[] = array('text' => 'Es ist kein Lagerort markiert oder es trat ein Fehler auf!', 'strong' => true, 'color' => 'red');
            }
            break;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_variable('add_more', $add_more, 'boolean');
if (!$fatal_error) {
    try {
        if (is_object($selected_storelocation)) {
            $parent_id = $selected_storelocation->get_parent_id();
            $html->set_variable('id', $selected_storelocation->get_id(), 'integer');
            $name = $selected_storelocation->get_name();
            $is_full = $selected_storelocation->get_is_full();
        } elseif ($action == 'add') {
            $parent_id = $new_parent_id;
            $name = $new_name;
            $is_full = $new_is_full;
        } else {
            $parent_id = 0;
            $name = '';
            $is_full = false;
Esempio n. 18
0
        $parts_table_loops = array();
        foreach ($category_parts as $category_full_path => $parts) {
            $parts_table_loops[$category_full_path] = Part::build_template_table_array($parts, 'search_parts');
        }
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
        $fatal_error = true;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->use_javascript(array('popup'));
$html->set_variable('keyword', $keyword, 'string');
$html->set_variable('hits_count', isset($hits_count) ? $hits_count : 0, 'integer');
$html->set_variable('search_name', $search_name, 'boolean');
$html->set_variable('search_category', $search_category, 'boolean');
$html->set_variable('search_description', $search_description, 'boolean');
$html->set_variable('search_comment', $search_comment, 'boolean');
$html->set_variable('search_supplier', $search_supplier, 'boolean');
$html->set_variable('search_supplierpartnr', $search_supplierpartnr, 'boolean');
$html->set_variable('search_storelocation', $search_storelocation, 'boolean');
$html->set_variable('search_footprint', $search_footprint, 'boolean');
$html->set_variable('search_manufacturer', $search_manufacturer, 'boolean');
if (!$fatal_error) {
    // export formats
    $html->set_loop('export_formats', build_export_formats_loop('searchparts'));
    // global stuff
    $html->set_variable('disable_footprints', $config['footprints']['disable'], 'boolean');
Esempio n. 19
0
            } catch (Exception $e) {
                $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
            }
            break;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->use_javascript(array('validatenumber', 'popup', 'util-functions', 'clear-default-text'));
if (!$fatal_error) {
    try {
        // global settings
        $html->set_variable('use_modal_popup', $config['popup']['modal'], 'boolean');
        $html->set_variable('popup_width', $config['popup']['width'], 'integer');
        $html->set_variable('popup_height', $config['popup']['height'], 'integer');
        // special
        $html->set_variable('is_new_part', $is_new_part || $add_one_more_part, 'boolean');
        // part attributes
        if (isset($part) && is_object($part)) {
            $html->set_variable('pid', $part->get_id(), 'integer');
            $html->set_variable('name', $part->get_name(), 'string');
            $html->set_variable('description', $part->get_description(), 'string');
            $html->set_variable('instock', $part->get_instock(), 'integer');
            $html->set_variable('mininstock', $part->get_mininstock(), 'integer');
            $html->set_variable('visible', $part->get_visible(), 'boolean');
            $html->set_variable('comment', $part->get_comment(), 'string');
            // dropdown lists -> get IDs
            $category_id = is_object($part->get_category()) ? $part->get_category()->get_id() : 0;
Esempio n. 20
0
    $fatal_error = true;
}
/********************************************************************************
 *
 *   Execute actions
 *
 *********************************************************************************/
if (!$fatal_error) {
    switch ($action) {
        case 'show_searched_parts':
            // show the search results for adding parts to this device
            try {
                // search parts by name and description
                $searched_parts = Part::search_parts($database, $current_user, $log, $new_part_name, '', true, true, false, false, false, false, false, false);
                $searched_parts_loop = Part::build_template_table_array($searched_parts, 'searched_device_parts');
                $html->set_variable('searched_parts_rowcount', count($searched_parts), 'integer');
                $html->set_variable('no_searched_parts_found', count($searched_parts) == 0, 'integer');
            } catch (Exception $e) {
                $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
            }
            break;
        case 'assign_by_selected':
            // add some parts (which were listed by part search) to this device
            for ($i = 0; $i < $searched_parts_rowcount; $i++) {
                $part_id = isset($_REQUEST['id_' . $i]) ? (int) $_REQUEST['id_' . $i] : 0;
                $quantity = isset($_REQUEST['quantity_' . $i]) ? abs((int) $_REQUEST['quantity_' . $i]) : 0;
                $mountname = isset($_REQUEST['mountnames_' . $i]) ? trim((string) $_REQUEST['mountnames_' . $i]) : '';
                if ($quantity > 0) {
                    try {
                        // if there is already such Part in this Device, the quantity will be increased
                        $device_part = DevicePart::add($database, $current_user, $log, $device_id, $part_id, $quantity, $mountname, true);
Esempio n. 21
0
            try {
                $part->set_manual_order(false);
            } catch (Exception $e) {
                $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
            }
            break;
    }
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->use_javascript(array('validatenumber', 'popup'));
// global settings
$html->set_variable('use_modal_popup', $config['popup']['modal'], 'boolean');
$html->set_variable('popup_width', $config['popup']['width'], 'integer');
$html->set_variable('popup_height', $config['popup']['height'], 'integer');
if (!$fatal_error) {
    try {
        // part attributes
        $html->set_variable('pid', $part->get_id(), 'integer');
        $html->set_variable('name', $part->get_name(), 'string');
        $html->set_variable('manufacturer_product_url', $part->get_manufacturer_product_url(), 'string');
        $html->set_variable('description', $part->get_description(), 'string');
        $html->set_variable('category_full_path', $part->get_category()->get_full_path(), 'string');
        $html->set_variable('instock', $part->get_instock(), 'integer');
        $html->set_variable('mininstock', $part->get_mininstock(), 'integer');
        $html->set_variable('visible', $part->get_visible(), 'boolean');
        $html->set_variable('comment', nl2br($part->get_comment()), 'string');
        $html->set_variable('footprint_full_path', is_object($footprint) ? $footprint->get_full_path() : '-', 'string');