'0', 'text' => SPECIALS_CONDITION_DROPDOWN_0), array('id' => '1', 'text' => SPECIALS_CONDITION_DROPDOWN_1), array('id' => '2', 'text' => SPECIALS_CONDITION_DROPDOWN_2)); $deduction_type_array = array(array('id' => '0', 'text' => DEDUCTION_TYPE_DROPDOWN_0), array('id' => '1', 'text' => DEDUCTION_TYPE_DROPDOWN_1), array('id' => '2', 'text' => DEDUCTION_TYPE_DROPDOWN_2)); $action = (isset($_GET['action']) ? $_GET['action'] : ''); if (zen_not_null($action)) { switch ($action) { case 'setflag': $salemaker_data_array = array('sale_status' => zen_db_prepare_input($_GET['flag']), 'sale_date_last_modified' => 'now()', 'sale_date_status_change' => 'now()'); zen_db_perform(TABLE_SALEMAKER_SALES, $salemaker_data_array, 'update', "sale_id = '" . zen_db_prepare_input($_GET['sID']) . "'"); // update prices for products in sale zen_update_salemaker_product_prices($_GET['sID']); zen_redirect(zen_href_link(FILENAME_SALEMAKER, '', 'NONSSL')); break; case 'insert': case 'update': // insert a new sale or update an existing sale // Create a string of all affected (sub-)categories if (zen_not_null($_POST['categories'])) { $categories_selected = array(); $categories_all = array(); foreach(zen_db_prepare_input($_POST['categories']) as $category_path) { $tmp = explode('_', substr($category_path,0,strlen($category_path)-1)); $category = array_pop($tmp); $categories_selected[] = $category; $categories_all[] = $category; foreach(zen_get_category_tree($category) as $subcategory) { if ($subcategory['id'] != '0') { $categories_all[] = $subcategory['id']; } } } asort($categories_selected); $categories_selected_string = implode(',', array_unique($categories_selected)); asort($categories_all); $categories_all_string = ',' . implode(',', array_unique($categories_all)) . ','; } else { $categories_selected_string = 'null'; $categories_all_string = 'null'; } $salemaker_sales_data_array = array('sale_name' => zen_db_prepare_input($_POST['name']), 'sale_deduction_value' => zen_db_prepare_input((float)$_POST['deduction']), 'sale_deduction_type' => zen_db_prepare_input($_POST['type']), 'sale_pricerange_from' => zen_db_prepare_input((float)$_POST['from']), 'sale_pricerange_to' => zen_db_prepare_input((float)$_POST['to']), 'sale_specials_condition' => zen_db_prepare_input($_POST['condition']), 'sale_categories_selected' => $categories_selected_string, 'sale_categories_all' => $categories_all_string, 'sale_date_start' => ((zen_db_prepare_input($_POST['start']) == '') ? '0001-01-01' : zen_date_raw($_POST['start'])), 'sale_date_end' => ((zen_db_prepare_input($_POST['end']) == '') ? '0001-01-01' : zen_date_raw($_POST['end']))); if ($action == 'insert') { $salemaker_sales['sale_status'] = 0; $salemaker_sales_data_array['sale_date_added'] = 'now()'; $salemaker_sales_data_array['sale_date_last_modified'] = '0001-01-01'; $salemaker_sales_data_array['sale_date_status_change'] = '0001-01-01'; zen_db_perform(TABLE_SALEMAKER_SALES, $salemaker_sales_data_array, 'insert'); $_POST['sID'] = $db->Insert_ID(); } else { $salemaker_sales_data_array['sale_date_last_modified'] = 'now()'; zen_db_perform(TABLE_SALEMAKER_SALES, $salemaker_sales_data_array, 'update', "sale_id = '" . zen_db_input($_POST['sID']) . "'"); } // update prices for products in sale zen_update_salemaker_product_prices($_POST['sID']); zen_redirect(zen_href_link(FILENAME_SALEMAKER, 'page=' . $_GET['page'] . '&sID=' . $_POST['sID'])); break; case 'copyconfirm': $newname = zen_db_prepare_input($_POST['newname']); if (zen_not_null($newname)) { $salemaker_sales = $db->Execute("select * from " . TABLE_SALEMAKER_SALES . " where sale_id = '" . zen_db_input($_GET['sID']) . "'"); if ($salemaker_sales->RecordCount() > 0) { $sql_data_array = array('sale_id' => 'null', 'sale_status' => 0, 'sale_name' => $newname, 'sale_date_added' => 'now()', 'sale_date_last_modified' => '0001-01-01', 'sale_date_status_change' => '0001-01-01', 'sale_deduction_value' => (float)$salemaker_sales->fields['sale_deduction_value'], 'sale_deduction_type' => (float)$salemaker_sales->fields['sale_deduction_type'], 'sale_pricerange_from' => (float)$salemaker_sales->fields['sale_pricerange_from'], 'sale_pricerange_to' => (float)$salemaker_sales->fields['sale_pricerange_to'], 'sale_specials_condition' => (int)$salemaker_sales->fields['sale_specials_condition'], 'sale_categories_selected' => $salemaker_sales->fields['sale_categories_selected'], 'sale_categories_all' => $salemaker_sales->fields['sale_categories_all'], 'sale_date_start' => $salemaker_sales->fields['sale_date_start'], 'sale_date_end' => $salemaker_sales->fields['sale_date_end'] ); zen_db_perform(TABLE_SALEMAKER_SALES, $sql_data_array, 'insert'); $sale_id = $db->Insert_ID(); // update prices for products in sale zen_update_salemaker_product_prices($sale_id); } } zen_redirect(zen_href_link(FILENAME_SALEMAKER, 'page=' . $_GET['page'] . '&sID=' . $db->Insert_ID())); break; case 'deleteconfirm': $sale_id = zen_db_prepare_input($_GET['sID']); // set sale off to update prices before removing $db->Execute("update " . TABLE_SALEMAKER_SALES . " set sale_status=0 where sale_id='" . $sale_id . "'"); // update prices for products in sale zen_update_salemaker_product_prices($sale_id); $db->Execute("delete from " . TABLE_SALEMAKER_SALES . " where sale_id = '" . (int)$sale_id . "'"); zen_redirect(zen_href_link(FILENAME_SALEMAKER, 'page=' . $_GET['page'])); break; } } ?> > <?php echo TITLE; ?>
\n"; echo '
Execute("select sale_id, sale_status, sale_name, sale_deduction_value, sale_deduction_type, sale_pricerange_from, sale_pricerange_to, sale_specials_condition, sale_categories_selected, sale_categories_all, sale_date_start, sale_date_end, sale_date_added, sale_date_last_modified, sale_date_status_change from " . TABLE_SALEMAKER_SALES . " where sale_id = '" . (int)$_GET['sID'] . "'"); $sInfo = new objectInfo($salemaker_sales->fields); } else { $sInfo = new objectInfo(array()); } ?> method="post">

0 ? '&sID=' . $_GET['sID'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?>
  sale_name, 'size="37"'); ?>
  sale_deduction_value, 'size="8"') . TEXT_SALEMAKER_DEDUCTION_TYPE . zen_draw_pull_down_menu('type', $deduction_type_array, $sInfo->sale_deduction_type); ?>
  sale_pricerange_from, 'size="8"') . TEXT_SALEMAKER_PRICERANGE_TO . zen_draw_input_field('to', $sInfo->sale_pricerange_to, 'size="8"'); ?>
  sale_specials_condition); ?>
 
 
Execute("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $categories_array[$i]['id'] . "' "); $categories_array[$i]['parent_id'] = $parents->fields['parent_id']; $categories_array[$i]['categories_id'] = $categories_array[$i]['id']; $categories_array[$i]['path'] = $categories_array[$i]['categories_id']; $categories_array[$i]['indent'] = 0; $parent = $categories_array[$i]['parent_id']; while($parent != 0) { $categories_array[$i]['indent']++; for($j = 0; $j < $n; $j++) { if($categories_array[$j]['categories_id'] == $parent) { $categories_array[$i]['path'] = $parent . '_' . $categories_array[$i]['path']; $parent = $categories_array[$j]['parent_id']; break; } } } $categories_array[$i]['path'] = $categories_array[$i]['path'] . '_'; } $categories_selected = explode(',', $sInfo->sale_categories_selected); if (zen_not_null($sInfo->sale_categories_selected)) { $selected = in_array(0, $categories_selected); } else { $selected = false; } $prev_sales = $db->Execute("select sale_categories_all from " . TABLE_SALEMAKER_SALES); while (!$prev_sales->EOF) { $prev_categories = explode(',', $prev_sales->fields['sale_categories_all']); while(list($key,$value) = each($prev_categories)) { if ($value) $prev_categories_array[$value]++; } $prev_sales->MoveNext(); } echo " \n"; echo ' \n"; echo ' \n"; echo " \n"; echo ' ' . "\n"; echo ' \n"; echo ' \n"; echo " \n"; echo " \n"; echo ' \n"; echo ' \n"; echo " \n"; echo "
' . zen_draw_separator('pixel_trans.gif', '4', '1') . zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif') . "
' . TEXT_SALEMAKER_ENTIRE_CATALOG . "
' . zen_draw_checkbox_field('categories[]', '0', $selected) . "' . TEXT_SALEMAKER_TOP . "
' . zen_draw_separator('pixel_trans.gif', '4', '1') . zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif') . "
' . TEXT_SALEMAKER_CATEGORIES . "
' . "\n"; foreach($categories_array as $category) { if (zen_not_null($sInfo->sale_categories_selected)) { $selected = in_array($category['categories_id'], $categories_selected); } else { $selected = false; } echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; } echo '
' . "\n"; echo ' ' . "\n"; echo ' \n"; echo ' \n"; echo '\n"; echo ' ' . "\n"; echo '
' . zen_draw_checkbox_field('categories[]', $category['path'], $selected) . "' . $category['text']. "'; if ($prev_categories_array[$category['categories_id']]) { echo sprintf(TEXT_WARNING_SALEMAKER_PREVIOUS_CATEGORIES, $prev_categories_array[$category['categories_id']]); } echo "
' . "\n"; echo ' ' . "\n"; if ($prev_categories_array[$category['categories_id']]) { echo ' ' . "\n"; echo '
' . "\n"; ?> \n"; echo '
' . "\n"; ?> '' . TEXT_INFO_HEADING_COPY_SALE . ''); $contents = array('form' => zen_draw_form('sales', FILENAME_SALEMAKER, 'page=' . $_GET['page'] . '&sID=' . $sInfo->sale_id . '&action=copyconfirm')); $contents[] = array('text' => sprintf(TEXT_INFO_COPY_INTRO, $sInfo->sale_name)); $contents[] = array('text' => '
 ' . zen_draw_input_field('newname', $sInfo->sale_name . '_', 'size="31"')); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_copy.gif', IMAGE_COPY) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; case 'delete': $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_SALE . ''); $contents = array('form' => zen_draw_form('sales', FILENAME_SALEMAKER, 'page=' . $_GET['page'] . '&sID=' . $sInfo->sale_id . '&action=deleteconfirm')); $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); $contents[] = array('text' => '
' . $sInfo->sale_name . ''); $contents[] = array('align' => 'center', 'text' => '
' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); break; default: if (is_object($sInfo)) { $heading[] = array('text' => '' . $sInfo->sale_name . ''); $contents[] = array('align' => 'center', 'text' => '' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '' . zen_image_button('button_copy_to.gif', IMAGE_COPY_TO) . '' . zen_image_button('button_delete.gif', IMAGE_DELETE) . ''); $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . zen_date_short($sInfo->sale_date_added)); $contents[] = array('text' => '' . TEXT_INFO_DATE_MODIFIED . ' ' . (($sInfo->sale_date_last_modified == '0001-01-01') ? TEXT_SALEMAKER_NEVER : zen_date_short($sInfo->sale_date_last_modified))); $contents[] = array('text' => '' . TEXT_INFO_DATE_STATUS_CHANGE . ' ' . (($sInfo->sale_date_status_change == '0001-01-01') ? TEXT_SALEMAKER_NEVER : zen_date_short($sInfo->sale_date_status_change))); $contents[] = array('text' => '
' . TEXT_INFO_DEDUCTION . ' ' . $sInfo->sale_deduction_value . ' ' . $deduction_type_array[$sInfo->sale_deduction_type]['text']); $contents[] = array('text' => '' . TEXT_INFO_PRICERANGE_FROM . ' ' . $currencies->format($sInfo->sale_pricerange_from) . TEXT_INFO_PRICERANGE_TO . $currencies->format($sInfo->sale_pricerange_to)); $contents[] = array('text' => '
Execute($salemaker_sales_query_raw); while (!$salemaker_sales->EOF) { if ((!isset($_GET['sID']) || (isset($_GET['sID']) && ($_GET['sID'] == $salemaker_sales->fields['sale_id']))) && !isset($sInfo)) { $sInfo_array = $salemaker_sales->fields; $sInfo = new objectInfo($sInfo_array); } if (isset($sInfo) && is_object($sInfo) && ($salemaker_sales->fields['sale_id'] == $sInfo->sale_id)) { echo ' ' . "\n"; } else { echo ' ' . "\n"; } ?> MoveNext(); } ?>
 
fields['sale_name']; ?> fields['sale_deduction_value']; ?> fields['sale_deduction_type']]['text']; ?> fields['sale_date_start'] == '0001-01-01') ? TEXT_SALEMAKER_IMMEDIATELY : zen_date_short($salemaker_sales->fields['sale_date_start'])); ?> fields['sale_date_end'] == '0001-01-01') ? TEXT_SALEMAKER_NEVER : zen_date_short($salemaker_sales->fields['sale_date_end'])); ?> fields['sale_status'] == '1') { echo '' . zen_image(DIR_WS_IMAGES . 'icon_green_on.gif', IMAGE_ICON_STATUS_ON) . ''; } else { echo '' . zen_image(DIR_WS_IMAGES . 'icon_red_on.gif', IMAGE_ICON_STATUS_OFF) . ''; } ?> fields['sale_id'] == $sInfo->sale_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($salemaker_sales_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_SALES); ?> display_links($salemaker_sales_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?>
' . zen_image_button('button_new_sale.gif', IMAGE_NEW_SALE) . ''; ?>
' . TEXT_INFO_SPECIALS_CONDITION . ' ' . $specials_condition_array[$sInfo->sale_specials_condition]['text'] . '
'); $contents[] = array('text' => '
' . TEXT_INFO_DATE_START . ' ' . (($sInfo->sale_date_start == '0001-01-01') ? TEXT_SALEMAKER_IMMEDIATELY : zen_date_short($sInfo->sale_date_start))); $contents[] = array('text' => '' . TEXT_INFO_DATE_END . ' ' . (($sInfo->sale_date_end == '0001-01-01') ? TEXT_SALEMAKER_NEVER : zen_date_short($sInfo->sale_date_end))); } break; } if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) { echo ' ' . "\n"; $box = new box; echo $box->infoBox($heading, $contents); echo ' ' . "\n"; } } ?>