|
ZenCart_Documentation
1.5.0
http://www.collinsharper.com
|
00001 <?php 00009 if (!defined('IS_ADMIN_FLAG')) { 00010 die('Illegal Access'); 00011 } 00012 $parameters = array('products_name' => '', 00013 'products_description' => '', 00014 'products_url' => '', 00015 'products_id' => '', 00016 'products_quantity' => '', 00017 'products_model' => '', 00018 'products_image' => '', 00019 'products_price' => '', 00020 'products_virtual' => DEFAULT_DOCUMENT_GENERAL_PRODUCTS_VIRTUAL, 00021 'products_weight' => '', 00022 'products_date_added' => '', 00023 'products_last_modified' => '', 00024 'products_date_available' => '', 00025 'products_status' => '', 00026 'products_tax_class_id' => DEFAULT_DOCUMENT_GENERAL_TAX_CLASS_ID, 00027 'manufacturers_id' => '', 00028 'products_quantity_order_min' => '', 00029 'products_quantity_order_units' => '', 00030 'products_priced_by_attribute' => '', 00031 'product_is_free' => '', 00032 'product_is_call' => '', 00033 'products_quantity_mixed' => '', 00034 'product_is_always_free_shipping' => DEFAULT_DOCUMENT_GENERAL_PRODUCTS_IS_ALWAYS_FREE_SHIPPING, 00035 'products_qty_box_status' => PRODUCTS_QTY_BOX_STATUS, 00036 'products_quantity_order_max' => '0', 00037 'products_sort_order' => '0', 00038 'products_discount_type' => '0', 00039 'products_discount_type_from' => '0', 00040 'products_price_sorter' => '0', 00041 'master_categories_id' => '' 00042 ); 00043 00044 $pInfo = new objectInfo($parameters); 00045 00046 if (isset($_GET['pID']) && empty($_POST)) { 00047 $product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url, 00048 p.products_id, p.products_quantity, p.products_model, 00049 p.products_image, p.products_price, p.products_virtual, p.products_weight, 00050 p.products_date_added, p.products_last_modified, 00051 date_format(p.products_date_available, '%Y-%m-%d') as 00052 products_date_available, p.products_status, p.products_tax_class_id, 00053 p.manufacturers_id, 00054 p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, 00055 p.product_is_free, p.product_is_call, p.products_quantity_mixed, 00056 p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max, 00057 p.products_sort_order, 00058 p.products_discount_type, p.products_discount_type_from, 00059 p.products_price_sorter, p.master_categories_id 00060 from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 00061 where p.products_id = '" . (int)$_GET['pID'] . "' 00062 and p.products_id = pd.products_id 00063 and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'"); 00064 00065 $pInfo->objectInfo($product->fields); 00066 } elseif (zen_not_null($_POST)) { 00067 $pInfo->objectInfo($_POST); 00068 $products_name = $_POST['products_name']; 00069 $products_description = $_POST['products_description']; 00070 $products_url = $_POST['products_url']; 00071 } 00072 00073 $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE)); 00074 $manufacturers = $db->Execute("select manufacturers_id, manufacturers_name 00075 from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); 00076 while (!$manufacturers->EOF) { 00077 $manufacturers_array[] = array('id' => $manufacturers->fields['manufacturers_id'], 00078 'text' => $manufacturers->fields['manufacturers_name']); 00079 $manufacturers->MoveNext(); 00080 } 00081 00082 $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); 00083 $tax_class = $db->Execute("select tax_class_id, tax_class_title 00084 from " . TABLE_TAX_CLASS . " order by tax_class_title"); 00085 while (!$tax_class->EOF) { 00086 $tax_class_array[] = array('id' => $tax_class->fields['tax_class_id'], 00087 'text' => $tax_class->fields['tax_class_title']); 00088 $tax_class->MoveNext(); 00089 } 00090 00091 $languages = zen_get_languages(); 00092 00093 if (!isset($pInfo->products_status)) $pInfo->products_status = '1'; 00094 switch ($pInfo->products_status) { 00095 case '0': $in_status = false; $out_status = true; break; 00096 case '1': 00097 default: $in_status = true; $out_status = false; 00098 break; 00099 } 00100 // set to out of stock if categories_status is off and new product or existing products_status is off 00101 if (zen_get_categories_status($current_category_id) == '0' and $pInfo->products_status != '1') { 00102 $pInfo->products_status = 0; 00103 $in_status = false; 00104 $out_status = true; 00105 } 00106 00107 // Virtual Products 00108 if (!isset($pInfo->products_virtual)) $pInfo->products_virtual = DEFAULT_DOCUMENT_GENERAL_PRODUCTS_VIRTUAL; 00109 switch ($pInfo->products_virtual) { 00110 case '0': $is_virtual = false; $not_virtual = true; break; 00111 case '1': $is_virtual = true; $not_virtual = false; break; 00112 default: $is_virtual = false; $not_virtual = true; 00113 } 00114 // Always Free Shipping 00115 if (!isset($pInfo->product_is_always_free_shipping)) $pInfo->product_is_always_free_shipping = DEFAULT_DOCUMENT_GENERAL_PRODUCTS_IS_ALWAYS_FREE_SHIPPING; 00116 switch ($pInfo->product_is_always_free_shipping) { 00117 case '0': $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = true; $special_product_is_always_free_shipping = false; break; 00118 case '1': $is_product_is_always_free_shipping = true; $not_product_is_always_free_shipping = false; $special_product_is_always_free_shipping = false; break; 00119 case '2': $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = false; $special_product_is_always_free_shipping = true; break; 00120 default: $is_product_is_always_free_shipping = false; $not_product_is_always_free_shipping = true; $special_product_is_always_free_shipping = false; break; 00121 } 00122 // products_qty_box_status shows 00123 if (!isset($pInfo->products_qty_box_status)) $pInfo->products_qty_box_status = PRODUCTS_QTY_BOX_STATUS; 00124 switch ($pInfo->products_qty_box_status) { 00125 case '0': $is_products_qty_box_status = false; $not_products_qty_box_status = true; break; 00126 case '1': $is_products_qty_box_status = true; $not_products_qty_box_status = false; break; 00127 default: $is_products_qty_box_status = true; $not_products_qty_box_status = false; 00128 } 00129 // Product is Priced by Attributes 00130 if (!isset($pInfo->products_priced_by_attribute)) $pInfo->products_priced_by_attribute = '0'; 00131 switch ($pInfo->products_priced_by_attribute) { 00132 case '0': $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; break; 00133 case '1': $is_products_priced_by_attribute = true; $not_products_priced_by_attribute = false; break; 00134 default: $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; 00135 } 00136 // Product is Free 00137 if (!isset($pInfo->product_is_free)) $pInfo->product_is_free = '0'; 00138 switch ($pInfo->product_is_free) { 00139 case '0': $in_product_is_free = false; $out_product_is_free = true; break; 00140 case '1': $in_product_is_free = true; $out_product_is_free = false; break; 00141 default: $in_product_is_free = false; $out_product_is_free = true; 00142 } 00143 // Product is Call for price 00144 if (!isset($pInfo->product_is_call)) $pInfo->product_is_call = '0'; 00145 switch ($pInfo->product_is_call) { 00146 case '0': $in_product_is_call = false; $out_product_is_call = true; break; 00147 case '1': $in_product_is_call = true; $out_product_is_call = false; break; 00148 default: $in_product_is_call = false; $out_product_is_call = true; 00149 } 00150 // Products can be purchased with mixed attributes retail 00151 if (!isset($pInfo->products_quantity_mixed)) $pInfo->products_quantity_mixed = '0'; 00152 switch ($pInfo->products_quantity_mixed) { 00153 case '0': $in_products_quantity_mixed = false; $out_products_quantity_mixed = true; break; 00154 case '1': $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; break; 00155 default: $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; 00156 } 00157 00158 // set image overwrite 00159 $on_overwrite = true; 00160 $off_overwrite = false; 00161 // set image delete 00162 $on_image_delete = false; 00163 $off_image_delete = true; 00164 ?> 00165 <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css"> 00166 <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script> 00167 <script language="javascript"><!-- 00168 var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE); 00169 //--></script> 00170 <script language="javascript"><!-- 00171 var tax_rates = new Array(); 00172 <?php 00173 for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) { 00174 if ($tax_class_array[$i]['id'] > 0) { 00175 echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . zen_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n"; 00176 } 00177 } 00178 ?> 00179 00180 00181 //--></script> 00182 <?php 00183 // echo $type_admin_handler; 00184 echo zen_draw_form('new_product', $type_admin_handler , 'cPath=' . $cPath . (isset($_GET['product_type']) ? '&product_type=' . $_GET['product_type'] : '') . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . '&action=new_product_preview' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : ''), 'post', 'enctype="multipart/form-data"'); 00185 ?> 00186 <table border="0" width="100%" cellspacing="0" cellpadding="2"> 00187 <tr> 00188 <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> 00189 <tr> 00190 <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, zen_output_generated_category_path($current_category_id)); ?></td> 00191 <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> 00192 </tr> 00193 </table></td> 00194 </tr> 00195 <tr> 00196 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00197 </tr> 00198 <tr> 00199 <td class="main" align="right"><?php echo zen_draw_hidden_field('products_date_added', (zen_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 00200 </tr> 00201 <tr> 00202 <td><table border="0" cellspacing="0" cellpadding="2"> 00203 <?php 00204 // show when product is linked 00205 if (zen_get_product_is_linked($_GET['pID']) == 'true' and $_GET['pID'] > 0) { 00206 ?> 00207 <tr> 00208 <td class="main"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td> 00209 <td class="main"> 00210 <?php 00211 // echo zen_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id); 00212 echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . ' '; 00213 echo zen_draw_pull_down_menu('master_category', zen_get_master_categories_pulldown($_GET['pID']), $pInfo->master_categories_id); ?> 00214 </td> 00215 </tr> 00216 <?php } else { ?> 00217 <tr> 00218 <td class="main"><?php echo TEXT_MASTER_CATEGORIES_ID; ?></td> 00219 <td class="main"><?php echo TEXT_INFO_ID . ($_GET['pID'] > 0 ? $pInfo->master_categories_id . ' ' . zen_get_category_name($pInfo->master_categories_id, $_SESSION['languages_id']) : $current_category_id . ' ' . zen_get_category_name($current_category_id, $_SESSION['languages_id'])); ?></td> 00220 </tr> 00221 <?php } ?> 00222 <tr> 00223 <td colspan="2" class="main"><?php echo TEXT_INFO_MASTER_CATEGORIES_ID; ?></td> 00224 </tr> 00225 <tr> 00226 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '100%', '2'); ?></td> 00227 </tr> 00228 <?php 00229 // hidden fields not changeable on products page 00230 echo zen_draw_hidden_field('master_categories_id', $pInfo->master_categories_id); 00231 echo zen_draw_hidden_field('products_discount_type', $pInfo->products_discount_type); 00232 echo zen_draw_hidden_field('products_discount_type_from', $pInfo->products_discount_type_from); 00233 echo zen_draw_hidden_field('products_price_sorter', $pInfo->products_price_sorter); 00234 echo zen_draw_hidden_field('products_quantity_order_min', 1); 00235 echo zen_draw_hidden_field('products_quantity_order_units', 1); 00236 ?> 00237 <tr> 00238 <td colspan="2" class="main" align="center"><?php echo (zen_get_categories_status($current_category_id) == '0' ? TEXT_CATEGORIES_STATUS_INFO_OFF : '') . ($out_status == true ? ' ' . TEXT_PRODUCTS_STATUS_INFO_OFF : ''); ?></td> 00239 </tr> 00240 <tr> 00241 <td class="main"><?php echo TEXT_DOCUMENT_STATUS; ?></td> 00242 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_DOCUMENT_AVAILABLE . ' ' . zen_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_DOCUMENT_NOT_AVAILABLE; ?></td> 00243 </tr> 00244 <tr> 00245 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00246 </tr> 00247 <tr> 00248 <td class="main"><?php echo TEXT_DOCUMENT_DATE_AVAILABLE; ?><br /><small>(YYYY-MM-DD)</small></td> 00249 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td> 00250 </tr> 00251 <tr> 00252 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00253 </tr> 00254 <?php 00255 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 00256 ?> 00257 <tr> 00258 <td class="main"><?php if ($i == 0) echo TEXT_DOCUMENT_NAME; ?></td> 00259 <td class="main"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('products_name[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_name[$languages[$i]['id']]) ? stripslashes($products_name[$languages[$i]['id']]) : zen_get_products_name($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_name')); ?></td> 00260 </tr> 00261 <?php 00262 } 00263 ?> 00264 00265 <tr> 00266 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00267 </tr> 00268 00269 00270 <?php 00271 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 00272 ?> 00273 <tr> 00274 <td class="main" valign="top"><?php if ($i == 0) echo TEXT_DOCUMENT_DETAILS; ?></td> 00275 <td colspan="2"><table border="0" cellspacing="0" cellpadding="0"> 00276 <tr> 00277 <td class="main" width="25" valign="top"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td> 00278 <td class="main" width="100%"><?php echo zen_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '30', htmlspecialchars((isset($products_description[$languages[$i]['id']])) ? stripslashes($products_description[$languages[$i]['id']]) : zen_get_products_description($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE)); //,'id="'.'products_description' . $languages[$i]['id'] . '"'); ?></td> 00279 </tr> 00280 </table></td> 00281 </tr> 00282 <?php 00283 } 00284 ?> 00285 <tr> 00286 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00287 </tr> 00288 <?php 00289 $dir = @dir(DIR_FS_CATALOG_IMAGES); 00290 $dir_info[] = array('id' => '', 'text' => "Main Directory"); 00291 while ($file = $dir->read()) { 00292 if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") { 00293 $dir_info[] = array('id' => $file . '/', 'text' => $file); 00294 } 00295 } 00296 $dir->close(); 00297 sort($dir_info); 00298 00299 $default_directory = substr( $pInfo->products_image, 0,strpos( $pInfo->products_image, '/')+1); 00300 ?> 00301 <tr> 00302 <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td> 00303 </tr> 00304 00305 <tr> 00306 <td class="main" colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0"> 00307 <tr> 00308 <td class="main"><?php echo TEXT_DOCUMENT_IMAGE; ?></td> 00309 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_file_field('products_image') . ' ' . ($pInfo->products_image !='' ? TEXT_IMAGE_CURRENT . $pInfo->products_image : TEXT_IMAGE_CURRENT . ' ' . NONE) . zen_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td> 00310 <td valign = "center" class="main"><?php echo TEXT_DOCUMENT_IMAGE_DIR; ?> <?php echo zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory); ?></td> 00311 </tr> 00312 <tr> 00313 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15'); ?></td> 00314 <td class="main" valign="top"><?php echo TEXT_IMAGES_DELETE . ' ' . zen_draw_radio_field('image_delete', '0', $off_image_delete) . ' ' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('image_delete', '1', $on_image_delete) . ' ' . TABLE_HEADING_YES; ?></td> 00315 </tr> 00316 00317 <tr> 00318 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15'); ?></td> 00319 <td colspan="3" class="main" valign="top"><?php echo TEXT_IMAGES_OVERWRITE . ' ' . zen_draw_radio_field('overwrite', '0', $off_overwrite) . ' ' . TABLE_HEADING_NO . ' ' . zen_draw_radio_field('overwrite', '1', $on_overwrite) . ' ' . TABLE_HEADING_YES; ?> 00320 <?php echo '<br />' . TEXT_PRODUCTS_IMAGE_MANUAL . ' ' . zen_draw_input_field('products_image_manual'); ?></td> 00321 </tr> 00322 </table></td> 00323 </tr> 00324 00325 <tr> 00326 <td colspan="2"><?php echo zen_draw_separator('pixel_black.gif', '100%', '3'); ?></td> 00327 </tr> 00328 00329 <?php 00330 for ($i=0, $n=sizeof($languages); $i<$n; $i++) { 00331 ?> 00332 <tr> 00333 <td class="main"><?php if ($i == 0) echo TEXT_DOCUMENT_URL . '<br /><small>' . TEXT_DOCUMENT_URL_WITHOUT_HTTP . '</small>'; ?></td> 00334 <td class="main"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('products_url[' . $languages[$i]['id'] . ']', htmlspecialchars(isset($products_url[$languages[$i]['id']]) ? $products_url[$languages[$i]['id']] : zen_get_products_url($pInfo->products_id, $languages[$i]['id']), ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_PRODUCTS_DESCRIPTION, 'products_url')); ?></td> 00335 </tr> 00336 <?php 00337 } 00338 ?> 00339 <tr> 00340 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00341 </tr> 00342 <tr> 00343 <td class="main"><?php echo TEXT_PRODUCTS_SORT_ORDER; ?></td> 00344 <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_sort_order', $pInfo->products_sort_order); ?></td> 00345 </tr> 00346 </table></td> 00347 </tr> 00348 <tr> 00349 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td> 00350 </tr> 00351 <tr> 00352 <td class="main" align="right"><?php echo zen_draw_hidden_field('products_date_added', (zen_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . ( (isset($_GET['search']) && !empty($_GET['search'])) ? zen_draw_hidden_field('search', $_GET['search']) : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? zen_draw_hidden_field('search', $_POST['search']) : '') . zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . ' <a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['pID']) ? '&pID=' . $_GET['pID'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . ( (isset($_GET['search']) && !empty($_GET['search'])) ? '&search=' . $_GET['search'] : '') . ( (isset($_POST['search']) && !empty($_POST['search']) && empty($_GET['search'])) ? '&search=' . $_POST['search'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td> 00353 </tr> 00354 </table></form>