<?php
/*
  $Id: store_update.php,v 1.00 2004/10/22 23:59:59 helpONline

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

  Copyright (c) 2004 osCommerce PL Team | M. Ptak

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
?>  
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<style type="text/css"><!--
a { color:#080381; text-decoration:none; }
a:hover { color:#aabbdd; text-decoration:underline; }
a.text:link, a.text:visited { color: #000000; text-decoration: none; }
a:text:hover { color: #000000; text-decoration: underline; }
a.main:link, a.main:visited { color: #ffffff; text-decoration: none; }
A.main:hover { color: #ffffff; text-decoration: underline; }
a.sub:link, a.sub:visited { color: #dddddd; text-decoration: none; }
A.sub:hover { color: #dddddd; text-decoration: underline; }
.heading { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; line-height: 1.5; color: #D3DBFF; }
.main { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 17px; font-weight: bold; line-height: 1.5; color: #ffffff; }
.main_false { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 17px; font-weight: bold; line-height: 1.5; color: #dddddd; }
.sub { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; line-height: 1.5; color: #ffffff; }
.sub_false { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; line-height: 1.5; color: #C1C1C1; }
.text { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; line-height: 1.5; color: #000000; }
.menuBoxHeading { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #ffffff; font-weight: bold; background-color: #7187bb; border-color: #7187bb; border-style: solid; border-width: 1px; }
.infoBox { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #080381; background-color: #f2f4ff; border-color: #7187bb; border-style: solid; border-width: 1px; }
.smallText { font-family: Verdana, Arial, sans-serif; font-size: 10px; }
//--></style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php
?>
<table border="0" width="750" height="100%" cellspacing="0" cellpadding="0" align="center" valign="middle">
<tr>
  
<td>
<table border="0" width="610" cellspacing="1" cellpadding="1">
 <tr>
	<td class="menuBoxHeading" colspan="2"><center>Prepared by <a href="http://www.oscommerce.pl" alt="Profesjonalne sklepy intrnetowe">osCommerce PL Team</a></center></td>
 </tr>
  <tr>
    <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
	<td class="heading"><?php echo HEADING_TITLE; ?></td>
</tr>
</table>
<table border="0" width="610" cellspacing="1" cellpadding="1">
				  <tr>
					<td class="smalltext">
<?php

if ($process=='tmp') {
  $update_query = tep_db_query("select p.products_id as id,  pd.products_name, p.products_quantity as qnty, p.products_status as stat, p.products_date_added as da, p.products_last_modified as dm from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_quantity < '1' and p.products_id = pd.products_id order by products_status DESC, pd.products_name ASC");
	for ($i=0, $n = tep_db_num_rows($update_query); $i<$n; $i++) {
		$update[$i] = tep_db_fetch_array($update_query);
		$sql_data_array = array('products_id' => $update[$i]['id'],
							'products_last_modified' => 'now()',
                            'products_status' => '0');
		$parameters = "products_id = " . (int)$update[$i]['id'] . " and products_status = " . $update[$i]['stat'];
		tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', $parameters);
	}
}

  $update_query = tep_db_query("select p.products_id as id,  pd.products_name, p.products_quantity as qnty, p.products_status as stat, p.products_date_added as da, p.products_last_modified as dm from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_quantity < '1' and p.products_id = pd.products_id order by products_status DESC, pd.products_name ASC");

	echo	'<p class="menuBoxHeading"><b>' . ENTRY_BOX_HEADING . '</b></p>' ."\n" .
			'<table border="1" cellspacing="0" cellpadding="0" width=100%><tr><td class="infoBox" align="center">ID</td><td class="infoBox" align="center">' . ENTRY_BOX_NAME . '</td><td class="infoBox" align="center">' . ENTRY_BOX_QNTY . '</td><td class="infoBox" align="center">Status</td><td class="infoBox" align="center">' . ENTRY_BOX_ADDED . '</td><td class="infoBox" align="center">' . ENTRY_BOX_CHANGE . '</td></b></tr>';
  for ($i=0, $n = tep_db_num_rows($update_query); $i<$n; $i++) {
	  $update[$i] = tep_db_fetch_array($update_query);
	  echo	'<tr>' .
			'<td class="smalltext">' . $update[$i]['id'] . '</td>' .
			'<td class="smalltext"><a href="' . tep_catalog_href_link() . 'product_info.php?products_id=' . $update[$i]['id'] . '">' . $update[$i]['products_name'] . '</a></td>' .
			'<td class="smalltext" align="center">' . $update[$i]['qnty'] . '</td>';
	  echo	'<td class="smalltext" align="center">';
			if ($update[$i]['stat'] == '1') {
				echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10);
			} else {
				echo tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
			}
	  echo	'</td>';
	  echo 	'<td class="smalltext" align="center">' . $update[$i]['da'] . '</td>' .
		 	'<td class="smalltext" align="center">' . $update[$i]['dm'] . '</td>' .
			'</td></tr>';
  }
	  echo '</table>';
?>
<table>
      <tr>
	  <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
	  </tr>
	  <tr>
        <td><table border="0" width="480" cellspacing="1" cellpadding="2" class="infoBox">
          <tr class="infoBoxContents">
			  <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_back.gif', 'Powrot do sklepu bez zmiany bazy danych') . '</a>'; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>  
			<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_BACKUP) . '">' . tep_image_button('button_backup.gif', 'Wykonaj kopie bezpieczeństwa przed rozpoczęciem zmian') . '</a>'; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>
			<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                <td align="right"><?php echo '<a href="' . tep_href_link('store_update.php') . '?process=tmp">' . tep_image_button('button_continue.gif', 'Wylacz produkty w sklepie, ktorych nie ma w magazynie') . '</a>'; ?></td>
                <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
              </tr>
            </table></td>

          </tr>
        </table></td>
      </tr>
</table>
</td>

<td>
   <table border="0" width="200" height="100%" cellspacing="0" cellpadding="0" align="center" valign="top">
	<tr>
    <td>

<?php
  $heading = array();
  $contents = array();

  $heading[] = array('params' => 'class="menuBoxHeading"',
                     'text'  => 'osCommerce Professional');

  $contents[] = array('params' => 'class="infoBox"',
                      'text'  => '<a href="http://www.oscommerce.pl" target="_blank">Strona wsparcia</a><br>' .
                                 '<a href="http://www.forum.oscommerce.pl" target="_blank">Forum wsparcia</a><br>' .
								 '<a href="' . tep_catalog_href_link() . '">' . HEADER_TITLE_ONLINE_CATALOG . '</a><br>');


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

  echo '<br>';

  $orders_contents = '';
  $orders_status_query = tep_db_query("select orders_status_name, orders_status_id from " . TABLE_ORDERS_STATUS . " where language_id = '" . $languages_id . "'");
  while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $orders_pending_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS . " where orders_status = '" . $orders_status['orders_status_id'] . "'");
    $orders_pending = tep_db_fetch_array($orders_pending_query);
    if (tep_admin_check_boxes(FILENAME_ORDERS, 'sub_boxes') == true) { 
      $orders_contents .= '<a href="' . tep_href_link(FILENAME_ORDERS, 'selected_box=customers&status=' . $orders_status['orders_status_id']) . '">' . $orders_status['orders_status_name'] . '</a>: ' . $orders_pending['count'] . '<br>';
    } else {
      $orders_contents .= '' . $orders_status['orders_status_name'] . ': ' . $orders_pending['count'] . '<br>';
    }
  }
  $orders_contents = substr($orders_contents, 0, -4);

  $heading = array();
  $contents = array();

  $heading[] = array('params' => 'class="menuBoxHeading"',
                     'text'  => BOX_TITLE_ORDERS);

  $contents[] = array('params' => 'class="infoBox"',
                      'text'  => $orders_contents);

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

  echo '<br>';
  $heading = array();
  $contents = array();
  $heading[] = array('params' => 'class="menuBoxHeading"',
                     'text'  => 'Bezpieczeństwo'); 

  $contents[] = array('params' => 'class="infoBox"',
					  'text'  => tep_admin_files_boxes(FILENAME_BACKUP, BOX_TOOLS_BACKUP));

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

  echo '<br>';

  $customers_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS);
  $customers = tep_db_fetch_array($customers_query);
  $products_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS);
  $products = tep_db_fetch_array($products_query);
  $products_in_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " where products_status = '1'");
  $products_in = tep_db_fetch_array($products_in_query);
  $products_out_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " where products_status = '0'");
  $products_out = tep_db_fetch_array($products_out_query);
  $products_tmp_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS . " where products_status = '1' and products_quantity < '1'");
  $products_tmp = tep_db_fetch_array($products_tmp_query);

  $heading = array();
  $contents = array();

  $heading[] = array('params' => 'class="menuBoxHeading"',
                     'text'  => BOX_TITLE_STATISTICS);

  $contents[] = array('params' => 'class="infoBox"',
                      'text'  => BOX_ENTRY_CUSTOMERS . ' ' . $customers['count'] . '<br>' .
                                 BOX_ENTRY_PRODUCTS . ' ' . $products['count'] . '<br>' .
                                 BOX_ENTRY_PRODUCTS_IN . ' ' . $products_in['count'] . '<br>' .
                                 BOX_ENTRY_PRODUCTS_OUT. ' ' . $products_out['count'] . '<br>' .
                                 BOX_ENTRY_PRODUCTS_TMP . ' ' . $products_tmp['count']);
  $box = new box;
  echo $box->menuBox($heading, $contents);

  echo '<br>';

  $contents = array();

  if (getenv('HTTPS') == 'on') {
    $size = ((getenv('SSL_CIPHER_ALGKEYSIZE')) ? getenv('SSL_CIPHER_ALGKEYSIZE') . '-bit' : '<i>' . BOX_CONNECTION_UNKNOWN . '</i>');
    $contents[] = array('params' => 'class="infoBox"',
                        'text' => tep_image(DIR_WS_ICONS . 'locked.gif', ICON_LOCKED, '', '', 'align="right"') . sprintf(BOX_CONNECTION_PROTECTED, $size));
  } else {
    $contents[] = array('params' => 'class="infoBox"',
                        'text' => tep_image(DIR_WS_ICONS . 'unlocked.gif', ICON_UNLOCKED, '', '', 'align="right"') . BOX_CONNECTION_UNPROTECTED);
  }

  $box = new box;
  echo $box->tableBlock($contents);
?>
			</td>
		</tr>
	</table>
  </td>
 </tr>
 <tr>
	<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
 </tr>
 <tr>
	<td class="menuBoxHeading" colspan="2"><center>Powered by <a href="http://www.oscommerce.pl" alt="Profesjonalne sklepy intrnetowe">osCommerceProfessional</a></center></td>
 </tr>
</table>

</body>

</html>