Example #1
0
function super_unique($array)
{
    $result = array_map("unserialize", array_unique(array_map("serialize", $array)));
    foreach ($result as $key => $value) {
        if (is_array($value)) {
            $result[$key] = super_unique($value);
        }
    }
    return $result;
}
Example #2
0
 /**
  * method
  *
  * @return \Cake\Network\Response|null
  */
 public function getProductByCat($catId)
 {
     //pre($this->imagePath);die;
     header('Content-Type: application/json');
     header('Access-Control-Allow-Origin: *');
     $connection = ConnectionManager::get('default');
     $sql = "\n\t\t\tSELECT \n\t\t\t\tProduct.id as PRODUCT_ID,\n\t\t\t\tProduct.item_code as PRODUCT_ITEMCODE,\n\t\t\t\tProduct.title as PRODUCT_TITLE,\n\t\t\t\tProduct.product_desc as PRODUCT_DESC,\n\t\t\t\tProduct.created as PRODUCT_CREATED,\n\t\t\t\tProductsAttr.brand_id as PRODUCT_BRANDID,\n\t\t\t\tProductsAttr.model as PRODUCT_MODEL,\n\t\t\t\tProductsAttr.video_link as PRODUCT_VIDEOLINK,\n\t\t\t\tProductsAttr.size as PRODUCT_SIZE,\n\t\t\t\tProductsAttr.weight as PRODUCT_WEIGHT,\n\t\t\t\tProductsAttr.packaging as PRODUCT_PACKAGING,\n\t\t\t\tProductsAttr.uom as PRODUCT_UOM,\n\t\t\t\tProductsAttr.quantity as PRODUCT_QUANTITY,\n\t\t\t\tProductsAttr.main_promo_1 as PRODUCT_PROMO1,\n\t\t\t\tProductsAttr.main_promo_2 as PRODUCT_PROMO2,\n\t\t\t\tProductsAttr.main_promo_3 as PRODUCT_PROMO3,\n\t\t\t\tProductsImages.*,\n\t\t\t\tProductsMarketingImages.*,\n\t\t\t\tProductsPrices.*,\n\t\t\t\tProductsPromos.*,\n\t\t\t\tProductsRelated.*,\n\t\t\t\tProductsCategory.*\n\t\t\tFROM\n\t\t\t\tproducts as Product\n\t\t\t\tLEFT JOIN products_attrs as ProductsAttr ON (ProductsAttr.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_images as ProductsImages ON (ProductsImages.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_marketing_images as ProductsMarketingImages ON (ProductsMarketingImages.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_prices as ProductsPrices ON (ProductsPrices.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_promos as ProductsPromos ON (ProductsPromos.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_relateds as ProductsRelated ON (ProductsRelated.product_id=Product.id)\n\t\t\t\tLEFT JOIN products_categories as ProductsCategory ON (ProductsCategory.product_id=Product.id)\n\t\t\t\tWHERE ProductsCategory.category_id=" . $catId . " GROUP By Product.id\n\t\t";
     $products['products'] = $connection->execute($sql)->fetchAll('assoc');
     $allBrands = array();
     if (empty($products)) {
         $response['msg'] = 'Not any product available for this category.';
         $response['response_code'] = '0';
         $this->set(array('response' => $response, '_serialize' => array('response')));
     } else {
         $i = 0;
         foreach ($products['products'] as $key => $prods) {
             //$products[$i]['IMG_PATH']=$this->imagePath;
             $sqlBrands = 'SELECT * FROM `brands` WHERE id=' . $prods['PRODUCT_BRANDID'];
             //$products[$i]['IMG_PATH']=$this->imagePath;
             $allBrands[] = @$connection->execute($sqlBrands)->fetchAll('assoc')[0];
             //$allBrands[] = $allBrands[$key][0];
             $i = $i + 1;
         }
         $sqlCatImg = 'SELECT image FROM `category_details` WHERE category_id=' . $catId;
         $cat_img = @$connection->execute($sqlCatImg)->fetchAll('assoc')[0]['image'];
         $products['BRANDS_LIST_FOR_THIS_CAT'] = super_unique($allBrands);
         $products['IMAGE_PATH'] = $this->imagePath;
         $products['CATEGORY_IMG_PATH'] = CAT_IMG_PATH_PRODUCTS . $cat_img;
         //	pre($products);
         echo json_encode($products);
         die;
     }
 }
Example #3
0
 function merge_arrays($arr1, $arr2)
 {
     $arr1 = (array) $arr1;
     $arr2 = (array) $arr2;
     $output = array_merge($arr1, $arr2);
     sort($output);
     return super_unique($output);
 }
Example #4
0
function woo_multidimensional_array_unique($array)
{
    // Make sure the $array parameter is in fact an array.
    if (!is_array($array)) {
        return;
    }
    // End IF Statement
    $result = array_map("unserialize", array_unique(array_map("serialize", $array)));
    foreach ($result as $key => $value) {
        if (is_array($value)) {
            $result[$key] = super_unique($value);
        }
    }
    return $result;
}
Example #5
0
function get_evaluations()
{
    //***********
    //GET Evaluations
    global $wpdb;
    $eval_table_name = "wp_seufolios_evaluations";
    $depts = get_all_depts();
    $query_dept = $_POST['dept'];
    foreach ($depts as $dept) {
        if ($query_dept == $dept->abbr) {
            $query_dept_id = $dept->id;
        }
    }
    //setup dates for sql format
    $startdate = $_POST['startdate'];
    $enddate = $_POST['enddate'];
    //***sql query for evals
    $evals_o = $wpdb->get_results("SELECT * FROM {$eval_table_name} WHERE submittime > '{$startdate}' AND submittime < '{$enddate}' AND answers != '' ORDER BY id");
    //filter for dept, add to array
    foreach ($evals_o as $eval_o) {
        $eval_o->taxonomies = unserialize($eval_o->taxonomies);
        $major = get_major($eval_o->studentid);
        foreach ($depts as $dept) {
            if ($major == $dept->id) {
                $major_abbr = $dept->abbr;
            }
        }
        if ($major_abbr == $query_dept) {
            $evals[] = get_object_vars($eval_o);
        }
    }
    //filter for 1 eval per prof per student
    $evals = super_unique($evals, 'profid', 'studentid');
    //convert user_ids to names
    for ($i = 0; $i < count($evals); $i++) {
        //change profid
        $user = get_userdata($evals[$i]['profid']);
        if ($user->user_lastname && $user->user_firstname) {
            $evals[$i]['profid'] = $user->user_firstname . ' ' . $user->user_lastname;
        } else {
            $evals[$i]['profid'] = $user->user_email;
        }
        //change studentid
        $user = get_userdata($evals[$i]['studentid']);
        if ($user->user_lastname && $user->user_firstname) {
            $evals[$i]['studentid'] = $user->user_firstname . ' ' . $user->user_lastname;
        } else {
            $evals[$i]['studentid'] = $user->user_email;
        }
    }
    //***sql query for eval questions
    //sql query for eval sections from dept
    $sections_table_name = "wp_seufolios_eval_sections";
    $sql = "SELECT * FROM {$sections_table_name} WHERE dept_id = {$query_dept_id} ORDER BY order_loc ASC";
    $sections = $wpdb->get_results($sql);
    //sql query for eval questions from sections
    $questions_table_name = "wp_seufolios_eval_questions";
    foreach ($sections as $section) {
        $sql = "SELECT * FROM {$questions_table_name} WHERE section_id = {$section->id} ORDER BY order_loc ASC";
        $questions[$section->id] = $wpdb->get_results($sql);
    }
    //***return results
    $result = serialize(array('sections' => $sections, 'questions' => $questions, 'taxes' => $all_taxonomies, 'evals' => $evals));
    return $result;
    //$printable = unserialize($result);
    //print_r($printable);
}