$manufacturers_name); if ($action == 'insert') { $insert_sql_data = array('date_added' => 'now()'); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); zen_db_perform(TABLE_MANUFACTURERS, $sql_data_array); $manufacturers_id = zen_db_insert_id(); } elseif ($action == 'save') { $update_sql_data = array('last_modified' => 'now()'); $sql_data_array = array_merge($sql_data_array, $update_sql_data); zen_db_perform(TABLE_MANUFACTURERS, $sql_data_array, 'update', "manufacturers_id = '" . (int)$manufacturers_id . "'"); } if ($_POST['manufacturers_image_manual'] != '') { // add image manually $manufacturers_image_name = $_POST['img_dir'] . $_POST['manufacturers_image_manual']; $db->Execute("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image_name . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } else { $manufacturers_image = new upload('manufacturers_image'); $manufacturers_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']); if ( $manufacturers_image->parse() && $manufacturers_image->save()) { // remove image from database if none if ($manufacturers_image->filename != 'none') { $db->Execute("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $_POST['img_dir'] . $manufacturers_image->filename . "' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } else { $db->Execute("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } } } $languages = zen_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $manufacturers_url_array = $_POST['manufacturers_url']; $language_id = $languages[$i]['id']; $sql_data_array = array('manufacturers_url' => zen_db_prepare_input($manufacturers_url_array[$language_id])); if ($action == 'insert') { $insert_sql_data = array('manufacturers_id' => $manufacturers_id, 'languages_id' => $language_id); $sql_data_array = array_merge($sql_data_array, $insert_sql_data); zen_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array); } elseif ($action == 'save') { zen_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array, 'update', "manufacturers_id = '" . (int)$manufacturers_id . "' and languages_id = '" . (int)$language_id . "'"); } } zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'mID=' . $manufacturers_id)); break; case 'deleteconfirm': // demo active test if (zen_admin_demo()) { $_GET['action']= ''; $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution'); zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page'])); } $manufacturers_id = zen_db_prepare_input($_GET['mID']); if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) { $manufacturer = $db->Execute("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$manufacturers_id . "'"); $image_location = DIR_FS_CATALOG_IMAGES . $manufacturer->fields['manufacturers_image']; if (file_exists($image_location)) @unlink($image_location); } $db->Execute("delete from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$manufacturers_id . "'"); $db->Execute("delete from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturers_id . "'"); if (isset($_POST['delete_products']) && ($_POST['delete_products'] == 'on')) { $products = $db->Execute("select products_id from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers_id . "'"); while (!$products->EOF) { zen_remove_product($products->fields['products_id']); $products->MoveNext(); } } else { $db->Execute("update " . TABLE_PRODUCTS . " set manufacturers_id = '' where manufacturers_id = '" . (int)$manufacturers_id . "'"); } zen_redirect(zen_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page'])); break; } } ?> > <?php echo TITLE; ?>
'' . TEXT_HEADING_NEW_MANUFACTURER . ''); $contents = array('form' => zen_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'action=insert', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_NEW_INTRO); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_NAME . '
' . zen_draw_input_field('manufacturers_name', '', zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name'))); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_IMAGE . '
' . zen_draw_file_field('manufacturers_image')); $dir = @dir(DIR_FS_CATALOG_IMAGES); $dir_info[] = array('id' => '', 'text' => "Main Directory"); while ($file = $dir->read()) { if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { $dir_info[] = array('id' => $file . '/', 'text' => $file); } } $dir->close(); sort($dir_info); $default_directory = 'manufacturers/'; $contents[] = array('text' => '
' . TEXT_PRODUCTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory)); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_IMAGE_MANUAL . ' ' . zen_draw_input_field('manufacturers_image_manual')); $manufacturer_inputs_string = ''; $languages = zen_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']', '', zen_set_field_length(TABLE_MANUFACTURERS_INFO, 'manufacturers_url') ); } $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'edit': $heading[] = array('text' => '' . TEXT_HEADING_EDIT_MANUFACTURER . ''); $contents = array('form' => zen_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'page=' . $_GET['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=save', 'post', 'enctype="multipart/form-data"')); $contents[] = array('text' => TEXT_EDIT_INTRO); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_NAME . '
' . zen_draw_input_field('manufacturers_name', $mInfo->manufacturers_name, zen_set_field_length(TABLE_MANUFACTURERS, 'manufacturers_name'))); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_IMAGE . '
' . zen_draw_file_field('manufacturers_image') . '
' . $mInfo->manufacturers_image); $dir = @dir(DIR_FS_CATALOG_IMAGES); $dir_info[] = array('id' => '', 'text' => "Main Directory"); while ($file = $dir->read()) { if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { $dir_info[] = array('id' => $file . '/', 'text' => $file); } } $dir->close(); sort($dir_info); $default_directory = substr( $mInfo->manufacturers_image, 0,strpos( $mInfo->manufacturers_image, '/')+1); $contents[] = array('text' => '
' . TEXT_PRODUCTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory)); $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_IMAGE_MANUAL . ' ' . zen_draw_input_field('manufacturers_image_manual')); $contents[] = array('text' => '
' . zen_info_image($mInfo->manufacturers_image, $mInfo->manufacturers_name)); $manufacturer_inputs_string = ''; $languages = zen_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']', zen_get_manufacturer_url($mInfo->manufacturers_id, $languages[$i]['id']), zen_set_field_length(TABLE_MANUFACTURERS_INFO, 'manufacturers_url')); } $contents[] = array('text' => '
' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'delete': $heading[] = array('text' => '' . TEXT_HEADING_DELETE_MANUFACTURER . ''); $contents = array('form' => zen_draw_form('manufacturers', FILENAME_MANUFACTURERS, 'page=' . $_GET['page'] . '&mID=' . $mInfo->manufacturers_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_DELETE_INTRO); $contents[] = array('text' => '
' . $mInfo->manufacturers_name . ''); $contents[] = array('text' => '
' . zen_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE); if ($mInfo->products_count > 0) { $contents[] = array('text' => '
' . zen_draw_checkbox_field('delete_products') . ' ' . TEXT_DELETE_PRODUCTS); $contents[] = array('text' => '
' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $mInfo->products_count)); } $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (isset($mInfo) && is_object($mInfo)) { $heading[] = array('text' => '' . $mInfo->manufacturers_name . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_DATE_ADDED . ' ' . zen_date_short($mInfo->date_added)); if (zen_not_null($mInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . zen_date_short($mInfo->last_modified)); $contents[] = array('text' => '
' . zen_info_image($mInfo->manufacturers_image, $mInfo->manufacturers_name)); $contents[] = array('text' => '
' . TEXT_PRODUCTS . ' ' . $mInfo->products_count); } break; } if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { echo ' ' . "\n"; } ?>
Execute($manufacturers_query_raw); while (!$manufacturers->EOF) { if ((!isset($_GET['mID']) || (isset($_GET['mID']) && ($_GET['mID'] == $manufacturers->fields['manufacturers_id']))) && !isset($mInfo) && (substr($action, 0, 3) != 'new')) { $manufacturer_products = $db->Execute("select count(*) as products_count from " . TABLE_PRODUCTS . " where manufacturers_id = '" . (int)$manufacturers->fields['manufacturers_id'] . "'"); $mInfo_array = array_merge($manufacturers->fields, $manufacturer_products->fields); $mInfo = new objectInfo($mInfo_array); } if (isset($mInfo) && is_object($mInfo) && ($manufacturers->fields['manufacturers_id'] == $mInfo->manufacturers_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
fields['manufacturers_name']; ?> fields['manufacturers_id'] . '&action=edit') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . ''; ?> fields['manufacturers_id'] . '&action=delete') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . ''; ?> fields['manufacturers_id'] == $mInfo->manufacturers_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?>
display_count($manufacturers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_MANUFACTURERS); ?> display_links($manufacturers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?>
manufacturers_id . '&action=new') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo '