This shows you the differences between two versions of the page.
tutorials:zencartmods:inventory_report_5.html [2011/08/29 19:46] daigo |
tutorials:zencartmods:inventory_report_5.html [2016/01/28 18:05] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | We suggest writing a few extra functions in your zencart admin to place into the **/admin/includes/functions/extra_functions/** folder for generating inventory reports. | ||
- | |||
- | |||
- | Here's one of our functions, which simply makes a giant array of how many of each product we've sold in the past week, 2 weeks, 4 kees, 6 weeks, etc. | ||
- | Save this into a file called **admin/includes/functions/extra_functions/stats_functions.php** | ||
- | <code php> | ||
- | <?php | ||
- | function getSalesStats() | ||
- | { | ||
- | global $db; | ||
- | |||
- | |||
- | $all = array(); | ||
- | for ($i = 0; $i < 2000; $i++) | ||
- | { $all[$i] = array(0,0,0,0,0,0,0); } | ||
- | $selectql = $db->Execute("SELECT op.products_id, op.products_quantity, o.date_purchased, DATEDIFF(CURDATE(), o.date_purchased) as diff from orders_products op LEFT JOIN orders o on op.orders_id = o.orders_id WHERE DATEDIFF(CURDATE(), o.date_purchased) < 90"); | ||
- | while(!$selectql->EOF) | ||
- | { | ||
- | $pid = $selectql->fields['products_id']; | ||
- | if($selectql->fields['diff'] <= 7) { $all[$pid][0] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 14) { $all[$pid][1] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 21) { $all[$pid][2] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 28) { $all[$pid][3] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 42) { $all[$pid][4] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 56) { $all[$pid][5] += $selectql->fields['products_quantity']; } | ||
- | if($selectql->fields['diff'] <= 90) { $all[$pid][6] += $selectql->fields['products_quantity']; } | ||
- | $selectql->MoveNext(); | ||
- | } | ||
- | |||
- | return $all; | ||
- | |||
- | } | ||
- | ?> | ||
- | </code> | ||
- | |||
- | And you will be able to call this function from any new report-generating pages that you create. | ||
- | |||
- | |||
- | Here's an example of a report generating page using this custom created function | ||
- | |||
- | {{:tutorials:zencartmods:inventory_report.php.zip|}} | ||
- | |||