?> <?php // If the report month known if (isset($_GET['m']) && is_numeric($_GET['m'])) { $_month = $_GET['m']; $_year = $_GET['y']; if (isset($_GET['m']) && $_month == 0) { echo "<h3 style='color:#FF00FF'>200 последних</h3>"; } else { if (isset($_GET['m'])) { echo "<h1 style='color:#FF00FF'>" . ru_month(date('n', mktime(0, 0, 0, $_month, 28, $_year))) . " {$_year}</h1>"; } else { echo "<h1 style='color:#FF00FF'>" . ru_month(date('m')) . " {$_year}</h1>"; } } $sql = "SELECT id, name, contract, contract_date, rezident \r\n FROM `wp_product_brands` \r\n WHERE active =1\r\n ORDER BY `name`"; $response = $wpdb->get_results($sql, ARRAY_A); if ($response != null) { $customer_number = 0; foreach ($response as $artist) { // get all sales for the given month $sql = "SELECT cust.name as smi, date, st.datetime, c.purchaseid, p.id as picture_id, s.name as processed, processed as processed_id, b.name as artist, p.name as title, c.price, totalprice, u.discount, u.display_name, l.user_id, firstname, lastname, email, address, phone, gateway, c.license, c.actual_money, st.downloads, st.active, st.id as downloadid, u.wallet \r\n FROM `wp_purchase_logs` as l, \r\n `wp_purchase_statuses` as s, \r\n `wp_cart_contents` as c, \r\n `wp_product_list` as p,\r\n `wp_download_status` as st,\r\n `wp_product_brands` as b,\r\n `wp_users` as u\r\n LEFT JOIN `al_customers` as cust\r\n ON u.id = cust.user_id\r\n WHERE l.`processed`=s.`id` \r\n AND l.id=c.purchaseid \r\n AND p.id=c.prodid \r\n AND st.purchid=c.purchaseid\r\n AND p.brand=b.id\r\n AND u.id = l.user_id\r\n AND payment_arrived_date BETWEEN '{$start_timestamp}' AND '{$end_timestamp}'\r\n AND l.processed = 5\r\n AND l.user_id != '106'\r\n AND b.id = '" . $artist['id'] . "'\r\n AND st.downloads != '5'\r\n GROUP BY c.license\r\n order by purchaseid"; ///pokazh("product['id']",$artist['id']); $product_list = $wpdb->get_results($sql, ARRAY_A); if ($product_list != null) { ///pokazh($sql); $n = 1; // sequence number of the cartoon sold to one customer
$total_ndfl = 0; // complete NDFL foreach ($result as $r) { $payday = $r['payment_date']; $list = explode('-', $payday); $_year = $list[0]; $_month = $list[1]; $_invoice_number = $r['act_number']; //pokazh($_invoice_number); $start_timestamp = date('y-m-d', mktime(0, 0, 0, $_month, 1, $_year)); $end_timestamp = date('y-m-d', mktime(0, 0, 0, $_month + 1, 0, $_year)); $sql = "SELECT cust.name as smi, date, st.datetime, c.purchaseid, p.id as picture_id, s.name as processed, processed as processed_id, b.name as artist, b.rezident, p.name as title, c.price, totalprice, u.discount, u.display_name, l.user_id, firstname, lastname, email, address, phone, gateway, c.license, c.actual_money, st.downloads, st.active, st.id as downloadid, u.wallet \r\n\tFROM `wp_purchase_logs` as l, \r\n\t\t`wp_purchase_statuses` as s, \r\n\t\t`wp_cart_contents` as c, \r\n\t\t`wp_product_list` as p,\r\n\t\t`wp_download_status` as st,\r\n\t\t`wp_product_brands` as b,\r\n\t\t`wp_users` as u\r\n\tLEFT JOIN `al_customers` as cust\r\n\tON u.id = cust.user_id\r\n\tWHERE\tl.`processed`=s.`id` \r\n\t\tAND l.id=c.purchaseid \r\n\t\tAND p.id=c.prodid \r\n\t\tAND st.purchid=c.purchaseid\r\n\t\tAND p.brand=b.id\r\n\t\tAND p.brand = '" . $_brand . "'\r\n\t\tAND u.id = l.user_id\r\n\t\tAND l.processed = 5\r\n\t\tAND l.user_id != '106'\r\n\t\tAND st.downloads != '5'\r\n\t\tAND payment_arrived_date BETWEEN '{$start_timestamp}' AND '{$end_timestamp}'\r\n\tGROUP BY c.license\r\n\torder by purchaseid"; //pokazh($sql); $product_list = $wpdb->get_results($sql, ARRAY_A); if ($product_list != null) { echo "<h1 style='color:#FF00FF'>" . ru_month($_month) . " {$_year}</h1>"; ///pokazh($sql); $n = 1; // sequence number of the cartoon sold to one customer $count = count($product_list); // number of cartoons sold $total = 0; // total price with discount $the_list = ''; // html list of cartoons with row tags $contract_period = $_month . "." . date("Y"); //$_invoice_number = $_invoice_start_number + $customer_number; foreach ($product_list as $sales) { $discount_price = round($sales['price'], 0) * ((100 - round($sales['discount'], 0)) / 100); //robokassa //actual_money
function getMonthYearNames($date) { //$date = DateTime::createFromFormat('Y-m-j', $date); //2011-12-31 00:00:00 $date = split("-", $date); $_month = $date[1]; $_year = $date[0]; $date = ru_month($_month) . " " . $_year; return $date; }
function RowCallback(&$row) { //$row['date'] = date("jS M Y",$row['date']); $row['firstname'] = '<a href="http://cartoonbank.ru/wp-admin/user-edit.php?user_id=' . $row['user_id'] . '">' . $row['firstname'] . ' ' . $row['lastname'] . '</a> ' . $row['phone'] . ' «' . $row['smi'] . '»'; $row['date'] = date("d.m.y H:m:s", $row['date']); $row['title'] = "<a target='_blank' href='" . get_option('siteurl') . "/?page_id=29&cartoonid=" . $row['id'] . "'>" . nl2br(stripslashes($row['title'])) . "</a>"; //$row['average'] = round($row['average'],2); $row['downloadid'] = "<a href='" . get_option('siteurl') . "/?downloadid=" . $row['downloadid'] . "'>скачать</a>"; //$link = $siteurl."?downloadid=".$download_data['id']; $row['discount'] = round($row['discount'], 0); if ($row['cart_discount'] == '') { $row['totalprice'] = $row['price'] - $row['price'] * $row['discount'] / 100; } else { $row['totalprice'] = $row['price'] - $row['price'] * $row['cart_discount'] / 100; } $row['wallet'] = round($row['wallet'], 0); $row['price'] = round($row['price'], 0); if ($row['processed_id'] == 5) { $payment_date = strtotime($row['payment_arrived_date']); $row['processed'] = '<div title="изменить" style="background-color:#FCF798;cursor:pointer;" class="status_' . $row['purchaseid'] . '" id="status_' . $row['purchaseid'] . '"><div onclick="change_status(\'.status_' . $row['purchaseid'] . '\');">' . $row['processed'] . ' в ' . ru_month(date("m", $payment_date), true) . ' ' . date("Y", $payment_date) . '</div></div>'; //date("M",$row['payment_arrived_date']) //'.$row['payment_arrived_date'].' } else { $row['processed'] = '<div title="изменить" style="cursor:pointer;" class="status_' . $row['purchaseid'] . '" id="status_' . $row['purchaseid'] . '"><div onclick="change_status(\'.status_' . $row['purchaseid'] . '\');">' . $row['processed'] . '</div></div>'; } //robokassa //actual_money if ($row['gateway'] == 'robokassa' || $row['gateway'] == 'paypal_multiple') { if ($row['actual_money'] == '') { $row['actual_money'] = '<div class="edit" id="' . $row['purchaseid'] . '" style="cursor:pointer;">' . $row['totalprice'] * 0.95 . '</div>'; } else { $row['actual_money'] = '<div class="edit" id="' . $row['purchaseid'] . '" style="cursor:pointer;">' . $row['actual_money'] . '</div>'; } } }