Plugin Directory

Changeset 1736203


Ignore:
Timestamp:
09/26/2017 11:41:41 AM (9 years ago)
Author:
agurghis
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cardojo-lite/trunk/includes/cardojo-core-functions.php

    r1736171 r1736203  
    19681968                'key' => '_sold_date_month',
    19691969                'value' => $current_month
     1970            ),
     1971            array(
     1972                'key' => '_sold',
     1973                'value' => 1
    19701974            )
    19711975        )
     
    20002004                'key' => '_sold_date_month',
    20012005                'value' => $current_month
     2006            ),
     2007            array(
     2008                'key' => '_sold',
     2009                'value' => 1
    20022010            )
    20032011        )
     
    20142022        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    20152023
    2016             $deal_profit = esc_attr(get_post_meta(get_the_ID(), 'deal_profit',true));
     2024            $vehicle_cost = esc_attr(get_post_meta(get_the_ID(), 'vehicle_cost',true));
     2025            $price = esc_attr(get_post_meta(get_the_ID(), 'vehicle_price',true));
     2026            $deal_profit = $price - $vehicle_cost;
    20172027            $profit = $profit + $deal_profit;
    20182028
     
    20342044   
    20352045    $search_args = array(
    2036         'post_type'           => 'deal',
     2046        'post_type'           => 'vehicle',
    20372047        'post_status'         => array( 'publish' ),
    20382048        'posts_per_page'      => 1,
     
    20402050        'orderby' => 'date',
    20412051        'order'   => 'ASC',
     2052        'meta_query' => array(
     2053            array(
     2054                'key' => '_sold',
     2055                'value' => 1
     2056            )
     2057        )
    20422058
    20432059    );
     
    20492065        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    20502066
    2051             $first_date = get_the_date( $format, get_the_ID() );
     2067            $vehicle_sold_date = esc_attr(get_post_meta(get_the_ID(), '_sold_date',true));
     2068            $vehicle_sold_date = date($format, $vehicle_sold_date);
     2069            $first_date = $vehicle_sold_date;
    20522070
    20532071        endwhile;
     
    20642082    $total_sales = 0;
    20652083
    2066    
    20672084    $search_args = array(
    2068         'post_type'           => 'deal',
     2085        'post_type'           => 'vehicle',
    20692086        'post_status'         => array( 'publish' ),
    20702087        'posts_per_page'      => -1,
    20712088        'author'              => get_current_user_id(),
    2072         'year'                => $year
     2089        'meta_query' => array(
     2090            'relation' => 'AND',
     2091            array(
     2092                'key' => '_sold_date_year',
     2093                'value' => $year
     2094            ),
     2095            array(
     2096                'key' => '_sold',
     2097                'value' => 1
     2098            )
     2099        )
    20732100
    20742101    );
     
    20842111        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    20852112
    2086             $deal_profit = esc_attr(get_post_meta(get_the_ID(), 'deal_profit',true));
     2113            $vehicle_cost = esc_attr(get_post_meta(get_the_ID(), 'vehicle_cost',true));
     2114            $price = esc_attr(get_post_meta(get_the_ID(), 'vehicle_price',true));
     2115            $deal_profit = $price - $vehicle_cost;
    20872116            $profit = $profit + $deal_profit;
    20882117
     
    21022131   
    21032132    $search_args = array(
    2104         'post_type'           => 'deal',
     2133        'post_type'           => 'vehicle',
    21052134        'post_status'         => array( 'publish' ),
    21062135        'posts_per_page'      => -1,
    2107         'author'              => get_current_user_id()
     2136        'author'              => get_current_user_id(),
     2137        'meta_query' => array(
     2138            array(
     2139                'key' => '_sold',
     2140                'value' => 1
     2141            )
     2142        )
    21082143    );
    21092144
     
    21172152        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    21182153
    2119             $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_make',true));
     2154            $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'vehicle_make_desc_init',true));
    21202155            $car_makers[] = $deal_vehicle_make;
    21212156
     
    21332168        $i++;
    21342169
    2135        
    21362170        $search_args = array(
    2137             'post_type'           => 'deal',
     2171            'post_type'           => 'vehicle',
    21382172            'posts_per_page'      => -1,
    21392173            'post_status'         => array( 'publish' ),
    21402174            'author'              => get_current_user_id(),
    21412175            'meta_query' => array(
     2176                'relation' => 'AND',
    21422177                array(
    2143                     'key' => 'deal_vehicle_make',
     2178                    'key' => 'vehicle_make_desc_init',
    21442179                    'value' => $car_maker
     2180                ),
     2181                array(
     2182                    'key' => '_sold',
     2183                    'value' => 1
    21452184                )
    21462185            )
     
    21572196            while ( $deals_query->have_posts() ) : $deals_query->the_post();
    21582197
    2159                 $age = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_age',true));
     2198                $format = get_option('date_format');
     2199                $pfx_date = get_the_date( $format, get_the_ID() );
     2200                $sold = esc_attr(get_post_meta(get_the_ID(), '_sold_date',true));
     2201
     2202                if(!empty($sold)) {
     2203                    $now = $sold;
     2204                } else {
     2205                    $now = strtotime(date("Y-m-d H:i:s"));
     2206                }
     2207
     2208                $age = ($now - strtotime($pfx_date)) / (60 * 60 * 24);
    21602209                $cars_age = $cars_age + $age;
    21612210
    2162                 $profit = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_profit',true));
    2163                 $total_profit =  $total_profit + $profit;
     2211                $vehicle_cost = esc_attr(get_post_meta(get_the_ID(), 'vehicle_cost',true));
     2212                $price = esc_attr(get_post_meta(get_the_ID(), 'vehicle_price',true));
     2213                $total_profit = $price - $vehicle_cost;
    21642214
    21652215            endwhile;
     
    21692219        $total_cars[$i]['make'] = $car_maker;
    21702220        $total_cars[$i]['amount'] = $total;
    2171         $total_cars[$i]['age'] = $cars_age/$total;
     2221        $total_cars[$i]['age'] = round($cars_age/$total);
    21722222        $total_cars[$i]['avg_profit'] = $total_profit/$total;
    21732223        $total_cars[$i]['total_profit'] = $total_profit;
     
    21812231// Total Sales by Model
    21822232function cardojo_get_total_sales_by_model() {
    2183 
    21842233   
    21852234    $search_args = array(
    2186         'post_type'           => 'deal',
     2235        'post_type'           => 'vehicle',
    21872236        'post_status'         => array( 'publish' ),
    21882237        'posts_per_page'      => -1,
    2189         'author'              => get_current_user_id()
     2238        'author'              => get_current_user_id(),
     2239        'meta_query' => array(
     2240            array(
     2241                'key' => '_sold',
     2242                'value' => 1
     2243            )
     2244        )
    21902245    );
    21912246
     
    21992254        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    22002255
    2201             $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_model',true));
     2256            $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'vehicle_model',true));
    22022257            $car_makers[] = $deal_vehicle_make;
    22032258
     
    22142269
    22152270        $i++;
    2216 
    22172271       
    22182272        $search_args = array(
    2219             'post_type'           => 'deal',
     2273            'post_type'           => 'vehicle',
    22202274            'posts_per_page'      => -1,
    22212275            'post_status'         => array( 'publish' ),
    22222276            'author'              => get_current_user_id(),
    22232277            'meta_query' => array(
     2278                'relation' => 'AND',
    22242279                array(
    2225                     'key' => 'deal_vehicle_model',
     2280                    'key' => 'vehicle_model',
    22262281                    'value' => $car_maker
     2282                ),
     2283                array(
     2284                    'key' => '_sold',
     2285                    'value' => 1
    22272286                )
    22282287            )
     
    22392298            while ( $deals_query->have_posts() ) : $deals_query->the_post();
    22402299
    2241                 $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_make',true));
    2242 
    2243                 $age = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_age',true));
     2300                $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'vehicle_make_desc_init',true));
     2301
     2302                $format = get_option('date_format');
     2303                $pfx_date = get_the_date( $format, get_the_ID() );
     2304                $sold = esc_attr(get_post_meta(get_the_ID(), '_sold_date',true));
     2305
     2306                if(!empty($sold)) {
     2307                    $now = $sold;
     2308                } else {
     2309                    $now = strtotime(date("Y-m-d H:i:s"));
     2310                }
     2311
     2312                $age = ($now - strtotime($pfx_date)) / (60 * 60 * 24);
    22442313                $cars_age = $cars_age + $age;
    22452314
    2246                 $profit = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_profit',true));
    2247                 $total_profit =  $total_profit + $profit;
     2315                $vehicle_cost = esc_attr(get_post_meta(get_the_ID(), 'vehicle_cost',true));
     2316                $price = esc_attr(get_post_meta(get_the_ID(), 'vehicle_price',true));
     2317                $total_profit = $price - $vehicle_cost;
    22482318
    22492319            endwhile;
     
    22532323        $total_cars[$i]['make'] = $deal_vehicle_make . " " . $car_maker;
    22542324        $total_cars[$i]['amount'] = $total;
    2255         $total_cars[$i]['age'] = $cars_age/$total;
     2325        $total_cars[$i]['age'] = round($cars_age/$total);
    22562326        $total_cars[$i]['avg_profit'] = $total_profit/$total;
    22572327        $total_cars[$i]['total_profit'] = $total_profit;
     
    22682338   
    22692339    $search_args = array(
    2270         'post_type'           => 'deal',
     2340        'post_type'           => 'vehicle',
    22712341        'post_status'         => array( 'publish' ),
    22722342        'posts_per_page'      => -1,
    2273         'author'              => get_current_user_id()
     2343        'author'              => get_current_user_id(),
     2344        'meta_query' => array(
     2345            array(
     2346                'key' => '_sold',
     2347                'value' => 1
     2348            )
     2349        )
    22742350    );
    22752351
     
    22832359        while ( $cars_query->have_posts() ) : $cars_query->the_post();
    22842360
    2285             $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_trim',true));
     2361            $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'vehicle_trim_id',true));
    22862362            $car_makers[] = $deal_vehicle_make;
    22872363
     
    22982374
    22992375        $i++;
    2300 
    23012376       
    23022377        $search_args = array(
    2303             'post_type'           => 'deal',
     2378            'post_type'           => 'vehicle',
    23042379            'posts_per_page'      => -1,
    23052380            'post_status'         => array( 'publish' ),
    23062381            'author'              => get_current_user_id(),
    23072382            'meta_query' => array(
     2383                'relation' => 'AND',
    23082384                array(
    2309                     'key' => 'deal_vehicle_trim',
     2385                    'key' => 'vehicle_trim_id',
    23102386                    'value' => $car_maker
     2387                ),
     2388                array(
     2389                    'key' => '_sold',
     2390                    'value' => 1
    23112391                )
    23122392            )
     
    23232403            while ( $deals_query->have_posts() ) : $deals_query->the_post();
    23242404
    2325                 $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_make',true));
    2326                 $deal_vehicle_model = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_model',true));
    2327 
    2328                 $age = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_age',true));
     2405                $deal_vehicle_make = esc_attr(get_post_meta(get_the_ID(), 'vehicle_make_desc_init',true));
     2406                $deal_vehicle_model = esc_attr(get_post_meta(get_the_ID(), 'vehicle_model',true));
     2407                $vehicle_trim_desc_init = esc_attr(get_post_meta(get_the_ID(), 'vehicle_trim_desc_init',true));
     2408
     2409                $format = get_option('date_format');
     2410                $pfx_date = get_the_date( $format, get_the_ID() );
     2411                $sold = esc_attr(get_post_meta(get_the_ID(), '_sold_date',true));
     2412
     2413                if(!empty($sold)) {
     2414                    $now = $sold;
     2415                } else {
     2416                    $now = strtotime(date("Y-m-d H:i:s"));
     2417                }
     2418
     2419                $age = ($now - strtotime($pfx_date)) / (60 * 60 * 24);
    23292420                $cars_age = $cars_age + $age;
    23302421
    2331                 $profit = esc_attr(get_post_meta(get_the_ID(), 'deal_vehicle_profit',true));
    2332                 $total_profit =  $total_profit + $profit;
     2422                $vehicle_cost = esc_attr(get_post_meta(get_the_ID(), 'vehicle_cost',true));
     2423                $price = esc_attr(get_post_meta(get_the_ID(), 'vehicle_price',true));
     2424                $total_profit = $price - $vehicle_cost;
    23332425
    23342426            endwhile;
     
    23362428        endif; wp_reset_postdata();
    23372429
    2338         $total_cars[$i]['make'] = $deal_vehicle_make . " " . $deal_vehicle_model . " " . $car_maker;
     2430        $total_cars[$i]['make'] = $deal_vehicle_make . " " . $deal_vehicle_model . " " . $vehicle_trim_desc_init;
    23392431        $total_cars[$i]['amount'] = $total;
    2340         $total_cars[$i]['age'] = $cars_age/$total;
     2432        $total_cars[$i]['age'] = round($cars_age/$total);
    23412433        $total_cars[$i]['avg_profit'] = $total_profit/$total;
    23422434        $total_cars[$i]['total_profit'] = $total_profit;
Note: See TracChangeset for help on using the changeset viewer.