/** * confirmDistributorOrders function * this funciton is to confirm all the pending orders's of a particular distributir only, iff he has filled some order's quantity. * it also send a mail to that particular distibutor with his and his dealer's all order's report in excel format, and cc to roadshow's admin's email as well. * the function can be called by ajax method using action command 'confirm_dealer_orders' * @return void * @author Ankit Balyan - sf.ankit@gmail.com **/ function confrimDistributorOrders() { global $wpdb; $table = 'rw_orders'; $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : isLogin(); if ($user_id) { if ($dist = isDistributor()) { $sql = "UPDATE {$table} SET `order_confirm_ind` = '1' WHERE `created_by` = {$user_id} and `total_qty` > 0 "; $update = $wpdb->query($sql); if ($update) { $user = getRwUsers($user_id); $body = "Dear " . $user->user_name . ",<br><br>Your final order has been received,<br><br>Please find attached the details for your order.\n<br> <br> Our team will get in touch for final verification and confirmation. Meanwhile if you have any doubts, please contact our support team at arvindcare@arvindbrands.com<br><br><br>thanks and regards…"; $mailData = array('from' => '', 'to' => isset($user->user_email) ? $user->user_email : '', 'cc' => get_option('admin_email'), 'bcc' => isset($dist[0]) ? $dist[0]->user_email : '', 'replyto' => get_option('admin_email'), 'replytoname' => 'Roadshow Admin', 'subject' => 'Order\'s Report', 'message' => $body, 'attachment' => exportXls(null, FALSE)); echo "All Orders have been Confirmed "; if (rwMail($mailData)) { echo " and mailed "; } echo " sucessfully"; } else { echo "No update Taken place! Please Try After Some Time"; } } } die; }
<?php ob_start(); // add_action('wp_ajax_call_export','exportCsv'); // add_action('wp_ajax_nopriv_call_export','exportCsv'); if (isset($_POST['call_export'])) { exportXls(null, TRUE, isLogin()); } if (isset($_POST['mail_export'])) { exportXls(null, FALSE); } ?> <?php /** * exportXls function * this funciton is to call all the denpendancy function to generate data, excel reports, save it or download at the browser * @todo report type implementation * @param report - type of repoert need to generated, not done, * @param attachment - if true force to download the excel file at browser else save it in rwFiles direcory * @param user_id - generated the report for a particular user * @return sting - path of file stored * @author Ankit Balyan - sf.ankit@gmail.com **/ function exportXls($report = NULL, $attachment = FALSE, $user_id = NULL) { $data = createData($report, $user_id); return genxls($data, $attachment); } /** * createData function