示例#1
0
 /**
  * Function displays the list of products available 
  * 
  * 
  * @return array
  */
 function showAllProducts()
 {
     include 'classes/Core/CRoleChecking.php';
     include_once 'classes/Core/Settings/CManageProducts.php';
     include_once 'classes/Display/DManageProducts.php';
     include 'classes/Core/CAdminHome.php';
     $chkuser = Core_CRoleChecking::checkRoles();
     if ($chkuser) {
         $default = new Core_Settings_CManageProducts();
         $output['username'] = Core_CAdminHome::userName();
         $output['currentDate'] = date('l, M d, Y H:i:s');
         $output['allproducts'] = $default->showAllProducts();
         Bin_Template::createTemplate('manageproducts.html', $output);
     } else {
         $output['usererr'] = 'You are Not having Privilege to view this page contact your Admin for detail';
         Bin_Template::createTemplate('Errors.html', $output);
     }
 }
示例#2
0
 /**
  * Function gets the search results from the database 
  * 
  * 
  * @return string
  */
 function searchProductDetails()
 {
     $producttitle = $_POST['title'];
     $brand = $_POST['brand'];
     $sku = $_POST['sku'];
     $qty = $_POST['qty'];
     $frommsrp = $_POST['frommsrp'];
     $tomsrp = $_POST['tomsrp'];
     $fromprice = $_POST['fromprice'];
     $toprice = $_POST['toprice'];
     $scost = $_POST['shippingcost'];
     $status = $_POST['status'];
     $cse = $_POST['cse'];
     $tag = $_POST['tag'];
     $fdte = $_POST['fromdate'];
     $tdte = $_POST['todate'];
     $ptype = $_POST['producttype'];
     if ($ptype != 1) {
         $sql = 'SELECT distinct pt.title,pt.sku,pt.cse_enabled,pt.status,pt.shipping_cost,pt.tag,pt.intro_date,pt.product_id,pt.brand, pt.price,pt.msrp, pt.status , invt.soh FROM products_table as pt , product_inventory_table as invt  ';
         $condition = array();
         if ($producttitle != '') {
             $condition[] = "  pt.title like '%" . $producttitle . "%'";
         }
         if ($brand != '') {
             $condition[] = " pt.brand like  '%" . $brand . "%'";
         }
         if ($sku != '') {
             $condition[] = "  pt.sku like  '%" . $sku . "%'";
         }
         if ($qty != '') {
             $condition[] = "  invt.soh like  '%" . $qty . "%'";
         }
         if ($frommsrp != '' && $tomsrp != '') {
             $condition[] = "  pt.msrp between '" . $frommsrp . "' and  '" . $tomsrp . "'";
         }
         if ($frommsrp != '' && $tomsrp == '') {
             $condition[] = "  pt.msrp > '" . $frommsrp . "'";
         }
         if ($frommsrp == '' && $tomsrp != '') {
             $condition[] = "  pt.msrp < '" . $tomsrp . "'";
         }
         if ($fromprice != '' && $toprice != '') {
             $condition[] = "  pt.price between   '" . $fromprice . "' and  '" . $toprice . "'";
         }
         if ($fromprice != '' && $toprice == '') {
             $condition[] = "  pt.price >   '" . $fromprice . "'";
         }
         if ($fromprice == '' && $toprice != '') {
             $condition[] = "  pt.price <   '" . $fromprice . "'";
         }
         if ($scost != '') {
             $condition[] = "  pt.shipping_cost like  '%" . $scost . "%'";
         }
         if ($status != '' && $status > -1) {
             $condition[] = "  pt.status = '" . $status . "'";
         }
         if ($cse != '' && $cse > -1) {
             $condition[] = "  pt.cse_enabled like  '%" . $cse . "%'";
         }
         if ($tag != '') {
             $condition[] = "  pt.tag like  '%" . $tag . "%'";
         }
         if ($fdte != '' && $tdte != '') {
             $condition[] = "pt.intro_date between '" . $fdte . "' and '" . $tdte . "'";
         }
         if ($ptype != '' && $ptype != '-1') {
             if ($ptype == '0') {
                 $condition[] = "pt.digital='0' AND pt.gift='0'";
             }
             if ($ptype == '1') {
                 $condition[] = "pt.digital='1' AND pt.gift='0'";
             }
             if ($ptype == '2') {
                 $condition[] = "pt.digital='0' AND pt.gift='1'";
             }
         }
         if (count($condition) > 1) {
             $sql .= ' where ' . implode(' and ', $condition) . 'and pt.product_id=invt.product_id AND product_status!="3"';
         } elseif (count($condition) > 0) {
             $sql .= ' where  ' . implode('', $condition) . ' and pt.product_id=invt.product_id AND product_status!="3"';
         } elseif (count($condition) == 0) {
             $sql .= ' where pt.product_id=invt.product_id AND product_status!="3"';
         }
     } else {
         $sql = 'SELECT * FROM products_table   ';
         $condition = array();
         if ($producttitle != '') {
             $condition[] = " title like '%" . $producttitle . "%'";
         }
         if ($sku != '') {
             $condition[] = " sku like  '%" . $brand . "%'";
         }
         if ($frommsrp != '' && $tomsrp != '') {
             $condition[] = "  msrp between '" . $frommsrp . "' and  '" . $tomsrp . "'";
         }
         if ($frommsrp != '' && $tomsrp == '') {
             $condition[] = "  msrp > '" . $frommsrp . "'";
         }
         if ($frommsrp == '' && $tomsrp != '') {
             $condition[] = "  msrp < '" . $tomsrp . "'";
         }
         if ($fromprice != '' && $toprice != '') {
             $condition[] = "  price between   '" . $fromprice . "' and  '" . $toprice . "'";
         }
         if ($fromprice != '' && $toprice == '') {
             $condition[] = "  price >   '" . $fromprice . "'";
         }
         if ($fromprice == '' && $toprice != '') {
             $condition[] = "  price <   '" . $fromprice . "'";
         }
         if ($scost != '') {
             $condition[] = " shipping_cost like  '%" . $scost . "%'";
         }
         if ($status != '' && $status > -1) {
             $condition[] = " status = '" . $status . "'";
         }
         if ($tag != '') {
             $condition[] = " tag like  '%" . $tag . "%'";
         }
         if ($fdte != '' && $tdte != '') {
             $condition[] = " intro_date between '" . $fdte . "' and '" . $tdte . "'";
         }
         if ($ptype != '' && $ptype != '-1') {
             if ($ptype == '0') {
                 $condition[] = "pt.digital='0' AND pt.gift='0'";
             }
             if ($ptype == '1') {
                 $condition[] = "pt.digital='1' AND pt.gift='0'";
             }
             if ($ptype == '2') {
                 $condition[] = "pt.digital='0' AND pt.gift='1'";
             }
         }
         if (count($condition) > 1) {
             $sql .= ' where ' . implode(' and ', $condition) . ' and digital="1" AND product_status!="3"';
         } elseif (count($condition) > 0) {
             $sql .= ' where  ' . implode('', $condition) . ' and digital="1" AND product_status!="3"';
         } elseif (count($condition) == 0) {
             $sql .= ' where digital="1" AND product_status!="3"';
         }
     }
     if ($_POST['search'] == 'Search') {
         $obj = new Bin_Query();
         if ($obj->executeQuery($sql)) {
             $output = Display_DManageProducts::showAllProducts($obj->records, '1', $this->data['paging'], $this->data['prev'], $this->data['next'], 0);
         } else {
             $output = Display_DManageProducts::showAllProducts($obj->records, '0', $this->data['paging'], $this->data['prev'], $this->data['next'], 0);
         }
         return $output;
     } else {
         return Core_Settings_CManageProducts::showAllProducts($sql, $this->data['paging'], $this->data['prev'], $this->data['next'], 0);
     }
 }