????

Your IP : 18.191.171.72


Current Path : /home2/morganrand/backup.morganrand.com/design_room/design/
Upload File :
Current File : /home2/morganrand/backup.morganrand.com/design_room/design/designs.php

<?php
/*
  $Id: designs.php

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  $user_opt = 1;

  require('includes/application_top.php');

  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();

  $orders_statuses = array();
  $orders_status_array = array();
  $orders_status_query = tep_db_query("select dmi_sort, dmi_name, dmi_value_code from " . TABLE_DESIGN_MENUS_ITEMS . " where dmi_menus_ID = '0' and (dmi_available = '1' or dmi_available = '3') order by dmi_sort");
  while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $orders_statuses[] = array('id' => $orders_status['dmi_value_code'],
                               'text' => $orders_status['dmi_name']);
//                               'text' => substr($orders_status['dmi_value_code'], 0, 2) . ' - ' . $orders_status['dmi_name']);
    $orders_status_array[$orders_status['dmi_sort']] = $orders_status['dmi_name'];
  }

  $tassel_choices = array();
  $tassel_choice_query = tep_db_query("select dmi_sort, dmi_name, dmi_value_code from " . TABLE_DESIGN_MENUS_ITEMS . " where dmi_menus_ID = '0' and dmi_available > '1' order by dmi_sort");
  while ($tassel_choice = tep_db_fetch_array($tassel_choice_query)) {
    $tassel_choices[] = array('id' => $tassel_choice['dmi_value_code'], 'text' => $tassel_choice['dmi_name']);
  }

  $ribbon_choices = array();
  $ribbon_choice_query = tep_db_query("select dmi_sort, dmi_name, dmi_value_code from " . TABLE_DESIGN_MENUS_ITEMS . " where dmi_menus_ID = '0' and dmi_level = '1' order by dmi_sort");
  while ($ribbon_choice = tep_db_fetch_array($ribbon_choice_query)) {
    $ribbon_choices[] = array('id' => $ribbon_choice['dmi_value_code'], 'text' => $ribbon_choice['dmi_name']);
  }

  $candy_choices = array();
  $candy_choice_query = tep_db_query("select dmi_sort, dmi_name, dmi_value_code from " . TABLE_DESIGN_MENUS_ITEMS . " where dmi_menus_ID = '2' and dmi_available = '1' order by dmi_sort");
  while ($candy_choice = tep_db_fetch_array($candy_choice_query)) {
    $candy_choices[] = array('id' => $candy_choice['dmi_value_code'], 'text' => $candy_choice['dmi_name']);
  }

  $base_choices = array();
  $base_choice_query = tep_db_query("select dmi_sort, dmi_name, dmi_value_code from " . TABLE_DESIGN_MENUS_ITEMS . " where dmi_menus_ID = '3' and dmi_available = '1' order by dmi_sort");
  while ($base_choice = tep_db_fetch_array($base_choice_query)) {
    $base_choices[] = array('id' => $base_choice['dmi_value_code'], 'text' => $base_choice['dmi_name']);
  }

  $keep_quiet = false;

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

  if (tep_not_null($action)) {
    switch ($action) {
      case 'update_design':
        $dID = tep_db_prepare_input($HTTP_GET_VARS['dID']);
        $design_updated = false;
        $check_status_query = tep_db_query("select designs_name, designs_description, designs_comment, designs_data, date_expires, designs_event_name, designs_event_date from " . TABLE_DESIGNS . " where designs_id = '" . (int)$dID . "'");
        $check_status = tep_db_fetch_array($check_status_query);

        if (isset($HTTP_GET_VARS['data'])) {
          $d_data = tep_db_prepare_input($HTTP_GET_VARS['data']);
          if (($check_status['designs_data'] != $d_data)) {
            if (isset($HTTP_GET_VARS['name'])) {
              $d_name = tep_db_prepare_input($HTTP_GET_VARS['name']);
              tep_db_query("update " . TABLE_DESIGNS . " set date_modified = now(), designs_name = '" . tep_db_input($d_name) . "', designs_data = '" . tep_db_input($d_data) . "' where designs_id = '" . (int)$dID . "'");
            } else {
              tep_db_query("update " . TABLE_DESIGNS . " set date_modified = now(), designs_data = '" . tep_db_input($d_data) . "' where designs_id = '" . (int)$dID . "'");
              $keep_quiet = true;
            }
            $design_updated = true;
          }
        } else {
          $d_name = tep_db_prepare_input($HTTP_POST_VARS['name']);
          $d_description = tep_db_prepare_input($HTTP_POST_VARS['description']);
          $d_event_name = tep_db_prepare_input($HTTP_POST_VARS['event_name']);
          $d_event_date = tep_db_prepare_input($HTTP_POST_VARS['event_date']);
//          $d_data = tep_db_prepare_input($HTTP_POST_VARS['data']);
          $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);

          if (isset($HTTP_POST_VARS['use_data']) && ($HTTP_POST_VARS['use_data'] == 'on')) {
            $d_data = substr($check_status['designs_data'],0,3);
// pompoms
            $d_wrk = '';
            $pos = 0;
            $d_wrk = tep_db_prepare_input($HTTP_POST_VARS['pom1']) . tep_db_prepare_input($HTTP_POST_VARS['pom2']) . tep_db_prepare_input($HTTP_POST_VARS['pom3']) . tep_db_prepare_input($HTTP_POST_VARS['pom4']) . tep_db_prepare_input($HTTP_POST_VARS['pom5']) . tep_db_prepare_input($HTTP_POST_VARS['pom6']);
            $d_wrk = $d_wrk . 'XXXXXXXXXXXX';
            $pos = strpos($d_wrk, 'XX');
            $d_wrk = substr_replace($d_wrk, 'XXXXXXXXXXXX', $pos);
            $d_wrk = substr($d_wrk,0,12);
            $pos = floor($pos/2);
            if (($pos <= 0) || ($pos > 6)) {
              $d_wrk = '1BKXXXXXXXXXX';
            } else {
              $d_wrk = strval($pos) . $d_wrk;
            }
            $d_data = $d_data . $d_wrk;
// candy
            $candy_valid = true;
            $d_wrk = '';
            $pos = 0;
            $d_wrk = tep_db_prepare_input($HTTP_POST_VARS['can1']);
            if ((strlen($d_wrk) != 3) || (strpos($d_wrk, 'XX') > 0)) {
              $d_wrk = '000XXXXXX';
              $candy_valid = false;
            } else {
              $d_wrk1 = substr($d_wrk,0,1);
              $d_wrk = $d_wrk1 . '00' . substr($d_wrk,1,2) . 'XXXXXX';
              if ($d_wrk1 != '6' && $d_wrk1 != '7') {
                $d_wrk1 = tep_db_prepare_input($HTTP_POST_VARS['can2']);
                if ((strlen($d_wrk1) == 3) && (strpos($d_wrk1, 'XX') < 1)) {
                  $d_wrk = substr($d_wrk,0,1) . substr($d_wrk1,0,1) . '0' . substr($d_wrk,3,2) . substr($d_wrk1,1,2) . 'XXXXXX';
                  $d_wrk1 = '';
                  $d_wrk1 = tep_db_prepare_input($HTTP_POST_VARS['can3']);
                  if ((strlen($d_wrk1) == 3) && (strpos($d_wrk1, 'XX') < 1) && (substr($d_wrk1,0,1) == '1')) {
                    $d_wrk = substr($d_wrk,0,2) . substr($d_wrk1,0,1) . substr($d_wrk,3,4) . substr($d_wrk1,1,2) . 'XXXXXX';
                  }
                }
              }
            }
            $d_wrk = substr($d_wrk,0,9);
            if (!is_numeric(substr($d_wrk,0,3))) {
              $d_wrk = '000XXXXXX';
              $candy_valid = false;
            } else {
              if (strpos('A100,110,111,130,140,200,230,250,300,310,320,330,400,410,500,520,550,600,700',substr($d_wrk,0,3))<1) {
                $d_wrk = '000XXXXXX';
                $candy_valid = false;
              }
            }
            $d_data = $d_data . $d_wrk;
// tassels
            $d_wrk = '';
            $pos = 0;
            $d_wrk = tep_db_prepare_input($HTTP_POST_VARS['tas1']) . tep_db_prepare_input($HTTP_POST_VARS['tas2']) . tep_db_prepare_input($HTTP_POST_VARS['tas3']) . tep_db_prepare_input($HTTP_POST_VARS['tas4']) . tep_db_prepare_input($HTTP_POST_VARS['tas5']) . tep_db_prepare_input($HTTP_POST_VARS['tas6']);
            $d_wrk = $d_wrk . 'XXXXXXXXXXXX';
            $pos = strpos($d_wrk, 'XX');
            $d_wrk = substr_replace($d_wrk, 'XXXXXXXXXXXX', $pos);
            $d_wrk = substr($d_wrk,0,12);
            $pos = floor($pos/2);
            if (($pos <= 0) || ($pos > 6)) $d_wrk = 'XXXXXXXXXXXX';
            $d_data = $d_data . $d_wrk;
// wraparound, base
            $d_wrk = '';
            $d_wrk = tep_db_prepare_input($HTTP_POST_VARS['wrap']) . 'XX';
            $d_wrk = substr($d_wrk ,0,2);
            $d_wrk = $d_wrk . tep_db_prepare_input($HTTP_POST_VARS['base']) . 'XX';
            $d_wrk = substr($d_wrk ,0,4);

            $d_data = $d_data . $d_wrk;
            if (($check_status['designs_data'] != $d_data) || ($check_status['designs_name'] != $d_name) || ($check_status['designs_description'] != $d_description) || ($check_status['designs_comment'] != $comments) || ($check_status['event_name'] != $d_event_name) || ($check_status['event_date'] != $d_event_date)) {
              tep_db_query("update " . TABLE_DESIGNS . " set designs_name = '" . tep_db_input($d_name) . "', designs_data = '" . tep_db_input($d_data) . "', designs_description = '" . tep_db_input($d_description) . "', designs_comment = '" . tep_db_input($comments) . "', designs_event_name = '" . tep_db_input($d_event_name) . "', designs_event_date = '" . tep_db_input($d_event_date) . "' where designs_id = '" . (int)$dID . "'");
              $design_updated = true;
              if ($candy_valid == false) {
                $messageStack->add_session('invalid candy combination, resetting to empty', 'warning');
              }
            }
          } else {
            if ( ($check_status['designs_name'] != $d_name) || ($check_status['designs_description'] != $d_description) || ($check_status['designs_comment'] != $comments) || ($check_status['event_name'] != $d_event_name) || ($check_status['event_date'] != $d_event_date)) {
              tep_db_query("update " . TABLE_DESIGNS . " set designs_name = '" . tep_db_input($d_name) . "', designs_description = '" . tep_db_input($d_description) . "', designs_comment = '" . tep_db_input($comments) . "', designs_event_name = '" . tep_db_input($d_event_name) . "', designs_event_date = '" . tep_db_input($d_event_date) . "' where designs_id = '" . (int)$dID . "'");
              $design_updated = true;
            }
          }
        }

        if ($design_updated == true) {
         $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
        } else {
          $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
        }

        if ($keep_quiet == false) {
          tep_redirect(tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('action', 'data')) . 'action=edit'));
        }
        break;
      case 'new_design':
        $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
//        $d_name = tep_db_prepare_input($HTTP_POST_VARS['name']);
//        $d_description = tep_db_prepare_input($HTTP_POST_VARS['description']);
        $d_data = 'A101IWXXXXXXXXXX400WHXXXXPPXXXXXXXXXXPPBG';
//        $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);

        $design_updated = false;
//        $check_status_query = tep_db_query("select designs_name, designs_description, designs_comment, designs_data, date_expires from " . TABLE_DESIGNS . " where designs_id = '" . (int)$dID . "'");
//        $check_status = tep_db_fetch_array($check_status_query);

        tep_db_query("insert into " . TABLE_DESIGNS . " (customers_id, date_created, designs_event_date, designs_data) values ('" . (int)$cID . "', now(), now(),'" . tep_db_input($d_data) . "')");

        $design_updated = true;

        if (design_updated == true) {
         $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');
        } else {
          $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');
        }

        tep_redirect(tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action'))));
        break;
      case 'deleteconfirm':
        $dID = tep_db_prepare_input($HTTP_GET_VARS['dID']);

        tep_remove_design($dID);

        tep_redirect(tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action'))));
        break;
    }
  }

  if (($action == 'edit') && isset($HTTP_GET_VARS['dID'])) {
    $dID = tep_db_prepare_input($HTTP_GET_VARS['dID']);

    $designs_query = tep_db_query("select designs_id from " . TABLE_DESIGNS . " where designs_id = '" . (int)$dID . "'");
    $design_exists = true;
    if (!tep_db_num_rows($designs_query)) {
      $design_exists = false;
      $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $dID), 'error');
    }
  }

//  include(DIR_WS_CLASSES . 'order.php');

  if ($keep_quiet == true) {
    echo 'design updated' . chr(13) . chr(10);
  } else {
?>

  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html <?php echo HTML_PARAMS; ?>>
  <head><script src="//cdn.optimizely.com/js/1865631164.js"></script>
  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  <title><?php echo TITLE; ?></title>
  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  <script language="javascript" src="includes/general.js"></script>
  </head>
  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
  <!-- header //-->
  <?php
    require(DIR_WS_INCLUDES . 'header.php');
  ?>
  <!-- header_eof //-->

  <!-- body //-->
  <table border="0" width="100%" cellspacing="2" cellpadding="2">
    <tr>
      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  <!-- left_navigation //-->
  <?php 
    if ($user_opt == 0) {
      require(DIR_WS_INCLUDES . 'column_left.php'); 
    } else {
      require(DIR_WS_INCLUDES . 'column_left_r.php');
    } 
  ?>
  <!-- left_navigation_eof //-->
      </table></td>
  <!-- body_text //-->
      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  <?php
    if (($action == 'edit') && ($design_exists == true)) {
//      $order = new order($oID);
      $zone_exists = true;
      $designs_query_raw = "select d.designs_id, c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, a.entry_street_address, a.entry_city, z.zone_code, a.entry_postcode, d.date_created, d.designs_name, d.designs_description, d.designs_comment, d.designs_data, d.designs_event_name, d.designs_event_date from " . TABLE_DESIGNS . " d , " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a, " . TABLE_ZONES . " z where d.designs_id = '" . (int)$dID . "' and (c.customers_id = d.customers_id) and (a.customers_id = d.customers_id) and (z.zone_id = a.entry_zone_id)";
      $designs_query = tep_db_query($designs_query_raw);
      if (!tep_db_num_rows($designs_query)) {
        $designs_query_raw = "select d.designs_id, c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, a.entry_street_address, a.entry_city, a.entry_postcode, d.date_created, d.designs_name, d.designs_description, d.designs_comment, d.designs_data, d.designs_event_name, d.designs_event_date from " . TABLE_DESIGNS . " d , " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a where d.designs_id = '" . (int)$dID . "' and (c.customers_id = d.customers_id) and (a.customers_id = d.customers_id)";
        $designs_query = tep_db_query($designs_query_raw);
        $zone_exists = false;
      }
      $designs = tep_db_fetch_array($designs_query);
      $infoo = tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('action', 'data')) . 'action=update_design');

  ?>
        <tr>
          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
              <td class="pageHeading" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
            <tr>
              <td colspan="3"><?php echo tep_draw_separator(); ?></td>
            </tr>
            <tr>
              <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                  <td class="main" valign="top"><b><?php echo ENTRY_CUSTOMER; ?></b></td>
                  <td class="main">
                    <?php if ($zone_exists == true) {
                      echo $designs['customers_firstname'] . ' '. $designs['customers_lastname'] . '<br>' . $designs['entry_street_address'] . '<br>' . $designs['entry_city'] . ', ' . $designs['zone_code'] . '<br>' . $designs['entry_postcode'] . '<br>' ; 
                    } else {
                      echo $designs['customers_firstname'] . ' '. $designs['customers_lastname'] . '<br>' . $designs['entry_street_address'] . '<br>' . $designs['entry_city'] . ', ' . $designs['entry_postcode'] . '<br>' ; 
                    }
                    ?>
                  </td>
                </tr>
                <tr>
                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
                </tr>
                <tr>
                  <td class="main"><b><?php echo ENTRY_TELEPHONE_NUMBER; ?></b></td>
                  <td class="main"><?php echo $designs['customers_telephone']; ?></td>
                </tr>
                <tr>
                  <td class="main"><b><?php echo ENTRY_EMAIL_ADDRESS; ?></b></td>
                  <td class="main"><?php echo '<a href="mailto:' . $designs['customers_email_address'] . '"><u>' . $designs['customers_email_address'] . '</u></a>'; ?></td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
        </tr>
        <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
        </tr>
<!-- ag_plus //-->
        <tr>
          <center>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="640" height="620" id="test009a" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="FlashVars" value="ex0=22&ext1=<?php echo rtrim($designs['designs_data']) . '">'; ?>
<param name="movie" value="../design/test009a.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="../design/test009a.swf" FlashVars = "ex0=22&ext1=<?php echo rtrim($designs['designs_data']) . '"'; ?> quality="high" bgcolor="#ffffff" width="640" height="620" name="test009a" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>


          </center>
        </tr>
<!-- ag_plus_eof //-->

        <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
        </tr>
        <tr><?php echo tep_draw_form('status', FILENAME_DESIGNS, tep_get_all_get_params(array('action')) . 'action=update_design'); ?>

          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
            <tr>
              <td><table border="0" cellspacing="0" cellpadding="3">
                <tr>
                  <td class="main"><b><?php echo TABLE_HEADING_EVENT_NAME; ?></b></td>
                  <td class="main"><?php echo tep_draw_input_field('event_name', $designs['designs_event_name'], 'maxlength="64", size="40"'); ?></td>        
                  <td class="main"><b><?php echo TABLE_HEADING_NAME; ?></b></td>
                  <td class="main"><?php echo tep_draw_input_field('name', $designs['designs_name'], 'maxlength="64", size="40"'); ?></td>        
                </tr>
                <tr>
                  <td class="main"><b><?php echo TABLE_HEADING_EVENT_DATE; ?></b></td>
                  <td class="main"><?php echo tep_draw_input_field('event_date', $designs['designs_event_date'], 'maxlength="24", size="40"'); ?></td>        
                  <td class="main"><b><?php echo TABLE_HEADING_DESCRIPTION; ?></b></td>
                  <td class="main"><?php echo tep_draw_input_field('description', $designs['designs_description'] , 'maxlength="64", size="40"'); ?></td>        
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
            </tr>
            <tr>
              <?php
                $skip_it = true;
                if ($skip_it == false) {
              ?>
                <td><table border ="1">
                  <tr><td>
                    <table border="0" cellspacing="0" cellpadding="3" bgcolor="#E2E2E2">
                    <tr>
                      <td class="main"></td>
                      <td class="main"><b><?php echo TABLE_HEADING_POMPOMS; ?></b></td>
                      <td class="main"><b><?php echo TABLE_HEADING_TASSELS; ?></b></td>
                      <td class="main"><b><?php echo TABLE_HEADING_CANDIES; ?></b></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>1</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom1', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'], 4, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas1', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],25, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('can1', array_merge(array(array('id' => '0XX', 'text' => TEXT_EMPTY)), $candy_choices), substr($designs['designs_data'],16, 1) . substr($designs['designs_data'],19, 2)); ?></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>2</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom2', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'], 6, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas2', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],27, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('can2', array_merge(array(array('id' => '0XX', 'text' => TEXT_NONE)), $candy_choices), substr($designs['designs_data'],17, 1) . substr($designs['designs_data'],21, 2)); ?></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>3</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom3', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'], 8, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas3', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],29, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('can3', array_merge(array(array('id' => '0XX', 'text' => TEXT_NONE)), $candy_choices), substr($designs['designs_data'],18, 1) . substr($designs['designs_data'],23, 2)); ?></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>4</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom4', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'],10, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas4', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],31, 2)); ?></td>
                      <td class="main"><b><?php echo TABLE_HEADING_WRAPAROUNDS; ?></b></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>5</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom5', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'],12, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas5', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],33, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('wrap', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $ribbon_choices), substr($designs['designs_data'],37, 2)); ?></td>
                      <td class="main"></td>
                    </tr>
                    <tr>
                      <td class="main"><b>6</b></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('pom6', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $orders_statuses), substr($designs['designs_data'],14, 2)); ?></td>
                      <td class="main"><?php echo tep_draw_pull_down_menu('tas6', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $tassel_choices), substr($designs['designs_data'],35, 2)); ?></td>
                      <td class="main"><b><?php echo TABLE_HEADING_BASE; ?></b>&nbsp;&nbsp;<?php echo tep_draw_pull_down_menu('base', array_merge(array(array('id' => 'XX', 'text' => TEXT_NONE)), $base_choices), substr($designs['designs_data'],39, 2)); ?></td>
                      <td class="main"><b><?php echo ENTRY_USE_DESIGN_TOOL; ?></b> <?php echo tep_draw_checkbox_field('use_data'); ?></td>
                    </tr>
                  </table></td></tr>
                </table></td>
              <?php
                }
              ?>
            </tr>
          </td>
          <tr>
            <td class="main"><br><b><?php echo TABLE_HEADING_COMMENTS; ?></b></td>
          </tr>
          <td class="main"><?php echo tep_draw_textarea_field('comments', 'soft', '76', '5', $designs['designs_comment']); ?></td>
        </tr>
        <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
        </tr>
        <tr>
          <td><table border="0" cellspacing="0" cellpadding="2">
            <tr>
              <td valign="top"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE); ?></td>
            </tr>
          </table></td>
        </form></tr>
        <tr>
          <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
        </tr>
  <?php
    } else {
  ?>
        <tr>
          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
              <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                <tr><?php echo tep_draw_form('designs', FILENAME_DESIGNS, '', 'get'); ?>
                  <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('dID', '', 'size="12"') . tep_draw_hidden_field('action', 'edit'); ?></td>
                </form></tr>            
              </table></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                <tr class="dataTableHeadingRow">
                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DATE_PURCHASED; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
                </tr>
  <?php
      if (isset($HTTP_GET_VARS['cID'])) {
        $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
        $designs_query_raw = "select d.designs_id, d.customers_id, c.customers_firstname, c.customers_lastname, d.date_created, d.designs_name, d.designs_description from " . TABLE_DESIGNS . " d , " . TABLE_CUSTOMERS . " c where (d.customers_id = c.customers_id) and d.customers_id = '" . (int)$cID . "' order by d.designs_id DESC";
      } else {
        $designs_query_raw = "select d.designs_id, d.customers_id, c.customers_firstname, c.customers_lastname, d.date_created, d.designs_name, d.designs_description from " . TABLE_DESIGNS . " d , " . TABLE_CUSTOMERS . " c where (d.customers_id = c.customers_id) order by d.designs_id DESC";
      }
      $designs_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $designs_query_raw, $designs_query_numrows);
      $designs_query = tep_db_query($designs_query_raw);
      while ($designs = tep_db_fetch_array($designs_query)) {
      if ((!isset($HTTP_GET_VARS['dID']) || (isset($HTTP_GET_VARS['dID']) && ($HTTP_GET_VARS['dID'] == $designs['designs_id']))) && !isset($dInfo)) {
          $dInfo = new objectInfo($designs);
        }

        if (isset($dInfo) && is_object($dInfo) && ($designs['designs_id'] == $dInfo->designs_id)) {
          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $dInfo->designs_id . '&action=edit') . '\'">' . "\n";
        } else {
          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID')) . 'dID=' . $designs['designs_id']) . '\'">' . "\n";
        }
  ?>
                  <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $designs['designs_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;' . $designs['customers_firstname']; ?></td>
                  <td class="dataTableContent" align="right"><?php echo strip_tags($designs['customers_lastname']); ?></td>
                  <td class="dataTableContent" align="center"><?php echo tep_datetime_short($designs['date_created']); ?></td>
                  <td class="dataTableContent" align="right"><?php echo $designs['designs_name']; ?></td>
                  <td class="dataTableContent" align="right"><?php if (isset($dInfo) && is_object($dInfo) && ($designs['designs_id'] == $dInfo->designs_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID')) . 'dID=' . $designs['designs_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
                </tr>
  <?php
      }
  ?>
                <tr>
                  <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                    <tr>
                      <td class="smallText" valign="top"><?php echo $designs_split->display_count($designs_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_DESIGNS); ?></td>
                      <td class="smallText" align="right"><?php echo $designs_split->display_links($designs_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'dID', 'action'))); ?></td>
                    </tr>
                  </table></td>
                </tr>
              </table></td>
  <?php
    $heading = array();
    $contents = array();

    switch ($action) {
      case 'delete':
        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_ORDER . '</b>');

        $contents = array('form' => tep_draw_form('designs', FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $dInfo->designs_id . '&action=deleteconfirm'));
        $contents[] = array('text' => TEXT_INFO_DELETE_INTRO . '<br><br><b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');

        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $dInfo->designs_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
        break;
      default:
        if (isset($dInfo) && is_object($dInfo)) {
          $heading[] = array('text' => '<b>[' . $dInfo->designs_id . ']&nbsp;&nbsp;' . tep_datetime_short($dInfo->date_created) . '</b>');

          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $dInfo->designs_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('dID', 'action')) . 'dID=' . $dInfo->designs_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <br> <a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $dInfo->customers_id . '&action=new_design') . '">' . tep_image_button('button_new.gif', IMAGE_NEW_DESIGN) . '</a>');

          $contents[] = array('text' => '<br>' . TEXT_DATE_ORDER_CREATED . ' ' . tep_date_short($dInfo->date_created));

          $contents[] = array('text' => '<br>' . TEXT_INFO_PAYMENT_METHOD . ' '  . $dInfo->designs_name);
        } else {
          if (isset($HTTP_GET_VARS['cID'])) {
            $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
            $check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$cID . "'");
            $check_customer = tep_db_fetch_array($check_customer_query);
            if ($check_customer['customers_id'] == $cID) {
              $heading[] = array('text' => '<b>' . $check_customer['customers_firstname'] .' '. $check_customer['customers_lastname'] . '</b>');
              $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_DESIGNS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cID . '&action=new_design') . '">' . tep_image_button('button_new.gif', IMAGE_NEW_DESIGN) . '</a>');
            }
          }
        }
        break;
    }

    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
      echo '            <td width="25%" valign="top">' . "\n";

      $box = new box;
      echo $box->infoBox($heading, $contents);

      echo '            </td>' . "\n";
    }
  ?>
            </tr>
          </table></td>
        </tr>
  <?php
    }
  ?>
      </table></td>
  <!-- body_text_eof //-->
    </tr>
  </table>
  <!-- body_eof //-->

  <!-- footer //-->
  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  <!-- footer_eof //-->
  <br>
  <!-- Hotjar Tracking Code for wanderfuls.com -->
<script>
    (function(h,o,t,j,a,r){
        h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
        h._hjSettings={hjid:78806,hjsv:5};
        a=o.getElementsByTagName('head')[0];
        r=o.createElement('script');r.async=1;
        r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
        a.appendChild(r);
    })(window,document,'//static.hotjar.com/c/hotjar-','.js?sv=');
</script></body>
</html>
  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
<?php 
  }
?>