Changeset 1736203
- Timestamp:
- 09/26/2017 11:41:41 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cardojo-lite/trunk/includes/cardojo-core-functions.php
r1736171 r1736203 1968 1968 'key' => '_sold_date_month', 1969 1969 'value' => $current_month 1970 ), 1971 array( 1972 'key' => '_sold', 1973 'value' => 1 1970 1974 ) 1971 1975 ) … … 2000 2004 'key' => '_sold_date_month', 2001 2005 'value' => $current_month 2006 ), 2007 array( 2008 'key' => '_sold', 2009 'value' => 1 2002 2010 ) 2003 2011 ) … … 2014 2022 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2015 2023 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; 2017 2027 $profit = $profit + $deal_profit; 2018 2028 … … 2034 2044 2035 2045 $search_args = array( 2036 'post_type' => ' deal',2046 'post_type' => 'vehicle', 2037 2047 'post_status' => array( 'publish' ), 2038 2048 'posts_per_page' => 1, … … 2040 2050 'orderby' => 'date', 2041 2051 'order' => 'ASC', 2052 'meta_query' => array( 2053 array( 2054 'key' => '_sold', 2055 'value' => 1 2056 ) 2057 ) 2042 2058 2043 2059 ); … … 2049 2065 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2050 2066 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; 2052 2070 2053 2071 endwhile; … … 2064 2082 $total_sales = 0; 2065 2083 2066 2067 2084 $search_args = array( 2068 'post_type' => ' deal',2085 'post_type' => 'vehicle', 2069 2086 'post_status' => array( 'publish' ), 2070 2087 'posts_per_page' => -1, 2071 2088 '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 ) 2073 2100 2074 2101 ); … … 2084 2111 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2085 2112 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; 2087 2116 $profit = $profit + $deal_profit; 2088 2117 … … 2102 2131 2103 2132 $search_args = array( 2104 'post_type' => ' deal',2133 'post_type' => 'vehicle', 2105 2134 'post_status' => array( 'publish' ), 2106 2135 '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 ) 2108 2143 ); 2109 2144 … … 2117 2152 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2118 2153 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)); 2120 2155 $car_makers[] = $deal_vehicle_make; 2121 2156 … … 2133 2168 $i++; 2134 2169 2135 2136 2170 $search_args = array( 2137 'post_type' => ' deal',2171 'post_type' => 'vehicle', 2138 2172 'posts_per_page' => -1, 2139 2173 'post_status' => array( 'publish' ), 2140 2174 'author' => get_current_user_id(), 2141 2175 'meta_query' => array( 2176 'relation' => 'AND', 2142 2177 array( 2143 'key' => ' deal_vehicle_make',2178 'key' => 'vehicle_make_desc_init', 2144 2179 'value' => $car_maker 2180 ), 2181 array( 2182 'key' => '_sold', 2183 'value' => 1 2145 2184 ) 2146 2185 ) … … 2157 2196 while ( $deals_query->have_posts() ) : $deals_query->the_post(); 2158 2197 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); 2160 2209 $cars_age = $cars_age + $age; 2161 2210 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; 2164 2214 2165 2215 endwhile; … … 2169 2219 $total_cars[$i]['make'] = $car_maker; 2170 2220 $total_cars[$i]['amount'] = $total; 2171 $total_cars[$i]['age'] = $cars_age/$total;2221 $total_cars[$i]['age'] = round($cars_age/$total); 2172 2222 $total_cars[$i]['avg_profit'] = $total_profit/$total; 2173 2223 $total_cars[$i]['total_profit'] = $total_profit; … … 2181 2231 // Total Sales by Model 2182 2232 function cardojo_get_total_sales_by_model() { 2183 2184 2233 2185 2234 $search_args = array( 2186 'post_type' => ' deal',2235 'post_type' => 'vehicle', 2187 2236 'post_status' => array( 'publish' ), 2188 2237 '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 ) 2190 2245 ); 2191 2246 … … 2199 2254 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2200 2255 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)); 2202 2257 $car_makers[] = $deal_vehicle_make; 2203 2258 … … 2214 2269 2215 2270 $i++; 2216 2217 2271 2218 2272 $search_args = array( 2219 'post_type' => ' deal',2273 'post_type' => 'vehicle', 2220 2274 'posts_per_page' => -1, 2221 2275 'post_status' => array( 'publish' ), 2222 2276 'author' => get_current_user_id(), 2223 2277 'meta_query' => array( 2278 'relation' => 'AND', 2224 2279 array( 2225 'key' => ' deal_vehicle_model',2280 'key' => 'vehicle_model', 2226 2281 'value' => $car_maker 2282 ), 2283 array( 2284 'key' => '_sold', 2285 'value' => 1 2227 2286 ) 2228 2287 ) … … 2239 2298 while ( $deals_query->have_posts() ) : $deals_query->the_post(); 2240 2299 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); 2244 2313 $cars_age = $cars_age + $age; 2245 2314 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; 2248 2318 2249 2319 endwhile; … … 2253 2323 $total_cars[$i]['make'] = $deal_vehicle_make . " " . $car_maker; 2254 2324 $total_cars[$i]['amount'] = $total; 2255 $total_cars[$i]['age'] = $cars_age/$total;2325 $total_cars[$i]['age'] = round($cars_age/$total); 2256 2326 $total_cars[$i]['avg_profit'] = $total_profit/$total; 2257 2327 $total_cars[$i]['total_profit'] = $total_profit; … … 2268 2338 2269 2339 $search_args = array( 2270 'post_type' => ' deal',2340 'post_type' => 'vehicle', 2271 2341 'post_status' => array( 'publish' ), 2272 2342 '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 ) 2274 2350 ); 2275 2351 … … 2283 2359 while ( $cars_query->have_posts() ) : $cars_query->the_post(); 2284 2360 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)); 2286 2362 $car_makers[] = $deal_vehicle_make; 2287 2363 … … 2298 2374 2299 2375 $i++; 2300 2301 2376 2302 2377 $search_args = array( 2303 'post_type' => ' deal',2378 'post_type' => 'vehicle', 2304 2379 'posts_per_page' => -1, 2305 2380 'post_status' => array( 'publish' ), 2306 2381 'author' => get_current_user_id(), 2307 2382 'meta_query' => array( 2383 'relation' => 'AND', 2308 2384 array( 2309 'key' => ' deal_vehicle_trim',2385 'key' => 'vehicle_trim_id', 2310 2386 'value' => $car_maker 2387 ), 2388 array( 2389 'key' => '_sold', 2390 'value' => 1 2311 2391 ) 2312 2392 ) … … 2323 2403 while ( $deals_query->have_posts() ) : $deals_query->the_post(); 2324 2404 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); 2329 2420 $cars_age = $cars_age + $age; 2330 2421 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; 2333 2425 2334 2426 endwhile; … … 2336 2428 endif; wp_reset_postdata(); 2337 2429 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; 2339 2431 $total_cars[$i]['amount'] = $total; 2340 $total_cars[$i]['age'] = $cars_age/$total;2432 $total_cars[$i]['age'] = round($cars_age/$total); 2341 2433 $total_cars[$i]['avg_profit'] = $total_profit/$total; 2342 2434 $total_cars[$i]['total_profit'] = $total_profit;
Note: See TracChangeset
for help on using the changeset viewer.