[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_shop/inc/ -> listing.products.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  $_entry['query']            = '';
  31  
  32  // create pagination
  33  if(isset($_GET['c'])) {
  34      $_SESSION['list_count'] = $_GET['c'] == 'all' ? '99999' : intval($_GET['c']);
  35  }
  36  if(isset($_GET['page'])) {
  37      $_SESSION['detail_page'] = intval($_GET['page']);
  38  }
  39  
  40  // set default values for paginating
  41  if(empty($_SESSION['list_count'])) {
  42      $_SESSION['list_count'] = 25;
  43  }
  44  
  45  // paginate and search form processing
  46  if(isset($_POST['do_pagination'])) {
  47  
  48      $_SESSION['list_active']    = empty($_POST['showactive']) ? 0 : 1;
  49      $_SESSION['list_inactive']    = empty($_POST['showinactive']) ? 0 : 1;
  50  
  51      $_SESSION['filter']            = clean_slweg($_POST['filter']);
  52      if(empty($_SESSION['filter'])) {
  53          unset($_SESSION['filter']);
  54      } else {
  55          $_SESSION['filter']    = convertStringToArray($_SESSION['filter'], ' ');
  56          $_POST['filter']    = $_SESSION['filter'];
  57      }
  58      
  59      $_SESSION['detail_page'] = intval($_POST['page']);
  60  
  61  }
  62  
  63  if(empty($_SESSION['detail_page'])) {
  64      $_SESSION['detail_page'] = 1;
  65  }
  66  
  67  $_entry['list_active']        = isset($_SESSION['list_active'])    ? $_SESSION['list_active']        : 1;
  68  $_entry['list_inactive']    = isset($_SESSION['list_inactive'])    ? $_SESSION['list_inactive']    : 1;
  69  
  70  
  71  // set correct status query
  72  if($_entry['list_active'] != $_entry['list_inactive']) {
  73      
  74      if(!$_entry['list_active']) {
  75          $_entry['query'] .= 'shopprod_status=0';
  76      }
  77      if(!$_entry['list_inactive']) {
  78          $_entry['query'] .= 'shopprod_status=1';
  79      }
  80      
  81  } else {
  82      $_entry['query'] .= 'shopprod_status!=9';
  83  }
  84  
  85  if(isset($_SESSION['filter']) && is_array($_SESSION['filter']) && count($_SESSION['filter'])) {
  86      
  87      $_entry['filter_array'] = array();
  88  
  89      foreach($_SESSION['filter'] as $_entry['filter']) {
  90          //usr_name, usr_login, usr_email
  91          $_entry['filter_array'][] = "CONCAT(    shopprod_ordernumber,     shopprod_model,            shopprod_name1,        
  92                                                  shopprod_name2,            shopprod_tag,            (shopprod_price+' '),
  93                                                  shopprod_description1,    shopprod_description2,    shopprod_description3
  94                                              ) LIKE '%".aporeplace($_entry['filter'])."%'";        
  95      }
  96      if(count($_entry['filter_array'])) {
  97          
  98          $_SESSION['filter'] = ' AND ('.implode(' OR ', $_entry['filter_array']).')';
  99          $_entry['query'] .= $_SESSION['filter'];
 100      
 101      }
 102  
 103  } elseif(isset($_SESSION['filter']) && is_string($_SESSION['filter'])) {
 104  
 105      $_entry['query'] .= $_SESSION['filter'];
 106  
 107  }
 108  
 109  
 110  // paginating values
 111  $_entry['count_total'] = _dbCount('SELECT COUNT(shopprod_id) FROM '.DB_PREPEND.'phpwcms_shop_products WHERE '.$_entry['query']);
 112  $_entry['pages_total'] = ceil($_entry['count_total'] / $_SESSION['list_count']);
 113  if($_SESSION['detail_page'] > $_entry['pages_total']) {
 114      $_SESSION['detail_page'] = empty($_entry['pages_total']) ? 1 : $_entry['pages_total'];
 115  }
 116  
 117  
 118  
 119  ?>
 120  <h1 class="title" style="margin-bottom:10px"><?php echo $BLM['listing_title'] ?></h1>
 121  
 122  <div class="navBarLeft imgButton chatlist">
 123      &nbsp;&nbsp;
 124      <a href="<?php echo shop_url(array('controller=prod', 'edit=0')) ?>" title="<?php echo $BLM['create_new_prod'] ?>"><img src="img/famfamfam/package_add.gif" alt="Add" border="0" /><span><?php echo $BLM['create_new_prod'] ?></span></a>
 125  </div>
 126  
 127  
 128  <form action="<?php echo shop_url('controller=prod') ?>" method="post" name="paginate" id="paginate"><input type="hidden" name="do_pagination" value="1" />
 129  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="paginate" summary="">
 130      <tr>
 131          <td><table border="0" cellpadding="0" cellspacing="0" summary="">
 132              <tr>
 133                  
 134                  <td><input type="checkbox" name="showactive" id="showactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_active'], 1) ?> /></td>
 135                  <td><label for="showactive"><img src="img/button/aktiv_12x13_1.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 136                  <td><input type="checkbox" name="showinactive" id="showinactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_inactive'], 1) ?> /></td>
 137                  <td><label for="showinactive"><img src="img/button/aktiv_12x13_0.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 138  
 139  <?php 
 140  if($_entry['pages_total'] > 1) {
 141  
 142      echo '<td class="chatlist">|&nbsp;</td>';
 143      echo '<td>';
 144      if($_SESSION['detail_page'] > 1) {
 145          echo '<a href="'. shop_url( array('controller=prod', 'page='.($_SESSION['detail_page']-1)) ) . '">';
 146          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" /></a>';
 147      } else {
 148          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" class="inactive" />';
 149      }
 150      echo '</td>';
 151      echo '<td><input type="text" name="page" id="page" maxlength="4" size="4" value="'.$_SESSION['detail_page'];
 152      echo '"  class="textinput" style="margin:0 3px 0 5px;width:30px;font-weight:bold;" /></td>';
 153      echo '<td class="chatlist">/'.$_entry['pages_total'].'&nbsp;</td>';
 154      echo '<td>';
 155      if($_SESSION['detail_page'] < $_entry['pages_total']) {
 156          echo '<a href="'.shop_url( array('controller=prod', 'page='.($_SESSION['detail_page']+1)) ) .'">';
 157          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" /></a>';
 158      } else {
 159          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" class="inactive" />';
 160      }
 161      echo '</td><td class="chatlist">&nbsp;|&nbsp;</td>';
 162  
 163  } else {
 164  
 165      echo '<td class="chatlist">|&nbsp;<input type="hidden" name="page" id="page" value="1" /></td>';
 166  
 167  }
 168  ?>
 169                  <td><input type="text" name="filter" id="filter" size="10" value="<?php 
 170                  
 171                  if(isset($_POST['filter']) && is_array($_POST['filter']) ) {
 172                      echo html_specialchars(implode(' ', $_POST['filter']));
 173                  }
 174                  
 175                  ?>" class="textinput" style="margin:0 2px 0 0;width:110px;text-align:left;" title="filter results by username, name or email" /></td>
 176                  <td><input type="image" name="gofilter" src="img/famfamfam/action_go.gif" style="margin-right:3px;" /></td>
 177              
 178              </tr>
 179          </table></td>
 180  
 181      <td class="chatlist" align="right">
 182          <a href="<?php echo shop_url(array('controller=prod', 'c=10')) ?>">10</a>
 183          <a href="<?php echo shop_url(array('controller=prod', 'c=25')) ?>">25</a>
 184          <a href="<?php echo shop_url(array('controller=prod', 'c=50')) ?>">50</a>
 185          <a href="<?php echo shop_url(array('controller=prod', 'c=100')) ?>">100</a>
 186          <a href="<?php echo shop_url(array('controller=prod', 'c=250')) ?>">250</a>
 187          <a href="<?php echo shop_url(array('controller=prod', 'c=all')) ?>"><?php echo $BL['be_ftptakeover_all'] ?></a>
 188      </td>
 189  
 190      </tr>
 191  </table>
 192  </form>
 193  
 194  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="" class="shop">
 195          
 196      <tr>
 197          <th>&nbsp;</th>
 198          <th>&nbsp;<?php echo $BLM['th_ordnr'] ?></th>
 199          <th>&nbsp;<?php echo $BLM['th_modnr'] ?></th>
 200          <th>&nbsp;<?php echo $BLM['th_product'] ?></th>
 201          <th>&nbsp;<?php echo $BLM['th_price'] ?>&nbsp;</th>
 202          <th>&nbsp;</th>
 203      </tr>
 204      
 205      
 206  <?php
 207  // loop listing available newsletters
 208  $row_count = 0;                
 209  
 210  $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_shop_products WHERE '.$_entry['query'].' ';
 211  //$sql .= 'ORDER BY shopprod_name ASC ';
 212  $sql .= 'LIMIT '.(($_SESSION['detail_page']-1) * $_SESSION['list_count']).','.$_SESSION['list_count'];
 213  
 214  $data = _dbQuery($sql);
 215  
 216  $_controller_link =  shop_url('controller=prod');
 217  
 218  foreach($data as $row) {
 219  
 220      echo '<tr'.( ($row_count % 2) ? ' class="adsAltRow"' : '' ).'>'.LF;
 221      
 222      echo '<td width="25" style="padding:2px 3px 2px 4px;">';
 223      echo '<img src="img/famfamfam/package.gif" alt="'.$BLM['shop_product'].'" /></td>'.LF;
 224      
 225      echo '<td class="dir" width="10%">&nbsp;'.html_specialchars($row['shopprod_ordernumber'])."</td>\n";
 226      echo '<td class="dir" width="10%">&nbsp;'.html_specialchars($row['shopprod_model'])."</td>\n";
 227      echo '<td class="dir" width="60%">&nbsp;'.html_specialchars($row['shopprod_name1'])."</td>\n";
 228      echo '<td class="dir listNumber" width="10%">&nbsp;'.html_specialchars( number_format( round($row['shopprod_price'], 2) , 2, $BLM['dec_point'], $BLM['thousands_sep'] ) )."&nbsp;</td>\n";
 229  
 230      echo '<td width="7%" align="right" nowrap="nowrap" class="button_td">';
 231      
 232          echo '<a href="'.$_controller_link.'&amp;edit='.$row["shopprod_id"].'">';        
 233          echo '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>';
 234      
 235          echo '<a href="'.$_controller_link.'&amp;status=' . $row["shopprod_id"] . '-' . $row["shopprod_status"] .'">';
 236          echo '<img src="img/button/aktiv_12x13_'.$row["shopprod_status"].'.gif" border="0" alt="" /></a>';
 237      
 238          echo '<a href="'.$_controller_link.'&amp;delete='.$row["shopprod_id"];
 239          echo '" title="delete: '.html_specialchars($row['shopprod_ordernumber'].' / '.$row['shopprod_name1']).'"';
 240          echo ' onclick="return confirm(\''.$BLM['delete_product'].js_singlequote($row['shopprod_ordernumber'].' / '.$row['shopprod_name1']).'\');">';
 241          echo '<img src="img/button/trash_13x13_1.gif" border="0" alt="" /></a>';
 242      
 243      echo '</td>'.LF;
 244      
 245      echo '</tr>'.LF;
 246  
 247      $row_count++;
 248  }
 249  
 250  if($row_count) {
 251      echo '<tr><td colspan="6" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>';
 252  }
 253  
 254  ?>    
 255  
 256  </table>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7