function curr_file($file_id) { global $db, $tpf, $settings, $code; $file = $db->fetch_one_array("select * from {$tpf}files where file_id='{$file_id}'"); if (!$file) { $file['is_del'] = 1; } else { $file['dl'] = create_down_url($file); $in_extract = $code == md5($file['file_key']) ? 1 : 0; $file['username'] = $file['p_name'] = @$db->result_first("select username from {$tpf}users where userid='{$file['userid']}' limit 1"); $rs = $db->fetch_one_array("select folder_id,folder_name from {$tpf}folders where userid='{$file['userid']}' and folder_id='{$file['folder_id']}'"); $file['file_category'] = $rs['folder_name'] ? '<a href="' . urr("space", "username="******"&folder_id=" . $rs['folder_id']) . '" target="_blank">' . $rs['folder_name'] . '</a>' : '- ' . __('uncategory') . ' -'; $file_key = trim($file['file_key']); $tmp_ext = $file['file_extension'] ? '.' . $file['file_extension'] : ""; $file_extension = $file['file_extension']; $file_ext = get_real_ext($file_extension); $file['file_description'] = str_replace('<br>', LF, $file[file_description]); $file['a_space'] = urr("space", "username="******"Y-m-d", $file['file_time']); $file['credit_down'] = $file['file_credit'] ? (int) $file['file_credit'] : (int) $settings['credit_down']; $file['username'] = $file[user_hidden] ? __('hidden') : ($file['username'] ? '<a href="' . $file['a_space'] . '">' . $file['username'] . '</a>' : __('hidden')); $file['file_downs'] = $file['stat_hidden'] ? __('hidden') : get_discount($file[userid], $file['file_downs']); $file['file_views'] = $file['stat_hidden'] ? __('hidden') : get_discount($file[userid], $file['file_views']); $file['file_url'] = $settings['phpdisk_url'] . urr("viewfile", "file_id={$file['file_id']}"); if (get_plans(get_profile($file[userid], 'plan_id'), 'open_second_page') == 3) { $file['a_downfile'] = urr("download", "file_id={$file_id}&key=" . random(32)); $file['a_downfile2'] = urr("download", "file_id={$file_id}&key=" . random(32)); } } return $file; }
/** * 生成订单 */ public function creatOrder() { $addr_id = intval($_POST['addr_id']); $addr_info = M('MemberAddrs')->where(array('addr_id' => $addr_id))->find(); $goods_list = M('OrderGoods')->where(array('order_id' => 0, 'member_id' => $this->mid))->select(); if (!empty($addr_info)) { $data['order_sn'] = order_sn(); $data['member_id'] = $this->mid; $data['buyer_name'] = get_member_nickname($this->mid); switch (trim($_POST['pay_type'])) { case 1: $data['payment_name'] = 'alipay'; break; case 2: $data['payment_name'] = 'bdpay'; break; } $data['shipping_fee'] = 0; $data['goods_amount'] = 0; $data['discount'] = 0; $data['order_amount'] = 0; if (empty($goods_list)) { $this->error('您还没有选择好商品哦.', U('Cart/index')); } foreach ($goods_list as $key => $val) { //计算价格同时清除购物车里的商品 $Cart = new Cart(); $Cart->delItem($val['goods_id']); $goods_price = M('Goods')->where(array('goods_id' => $val['goods_id']))->getField('goods_price'); if (get_distributor($this->mid)) { $goods_price = $goods_price * MSC('distributor_discount'); } $data['goods_amount'] += $goods_price * $val['goods_num']; $data['discount'] += $data['goods_amount'] * (1 - get_discount($val['goods_num'])); //冻结库存 M('Goods')->where(array('goods_id' => $val['goods_id']))->setDec('goods_storage', $val['goods_num']); M('Goods')->where(array('goods_id' => $val['goods_id']))->setInc('goods_freez', $val['goods_num']); } $data['order_amount'] = $data['goods_amount'] - $data['discount']; $data['order_message'] = str_rp($_POST['order_message'], 1); $member = M('Member')->where(array('member_id' => $this->mid))->field('mobile,email')->find(); $data['mobile'] = $member['mobile']; $data['email'] = $member['email']; $data['order_state'] = 10; $data['add_time'] = NOW_TIME; $order_id = M('Order')->add($data); if ($order_id) { //认领订单商品 已从购物车页面写入 M('OrderGoods')->where(array('order_id' => 0, 'member_id' => $this->mid))->setField('order_id', $order_id); //生成物流地址 $address_data['order_id'] = $order_id; $address_data['buyer_id'] = $this->mid; $address_data['true_name'] = $addr_info['name']; $address_data['prov_id'] = $addr_info['province_id']; $address_data['city_id'] = $addr_info['city_id']; $address_data['area_id'] = $addr_info['area_id']; $address_data['address'] = $addr_info['addr']; $address_data['zip_code'] = $addr_info['zip']; $address_data['mob_phone'] = $addr_info['mobile']; $address_data['add_time'] = NOW_TIME; M('OrderAddress')->add($address_data); //订单日志 $log_data['order_id'] = $order_id; $log_data['order_state'] = get_order_state_name(10); $log_data['change_state'] = get_order_state_name(20); $log_data['state_info'] = '会员确认订单'; $log_data['log_time'] = NOW_TIME; $log_data['operator'] = '会员'; M('OrderLog')->add($log_data); //进行支付跳转 switch (trim($_POST['pay_type'])) { case 1: $this->success('订单生成成功', U('Pay/alipay', array('order_sn' => $data['order_sn']))); break; case 2: $this->success('订单生成成功', U('Pay/bdpay', array('order_sn' => $data['order_sn']))); break; } } } else { $this->error('请选择收货地址'); } }
if ($card_id) { $vip = (int) @$vip; $sql = mysql_query("SELECT * FROM " . TABLE_CARD . " WHERE card_id='{$card_id}' AND vip='{$vip}' AND active!=0") or Error(1, __FILE__, __LINE__); if ($card = @mysql_fetch_array($sql)) { foreach ($contact_arr as $v) { $card[$v] = htmlspecialchars($card[$v], ENT_COMPAT, 'cp1251'); } $card['active_select'] = array_select('active', array(-1 => 'Заблокирована', 1 => 'Активна'), $card['active'], 0, "onchange=\"blockdiv.style.display = (this.value==-1) ? '' : 'none'\""); $sql = mysql_query("SELECT count(*) FROM " . TABLE_ORDER . " WHERE card_id='{$card_id}' AND card_vip='{$vip}' AND !basket") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $card['order_count'] = (int) @$arr[0]; $card['order_link'] = "?p={$part}&searchorder=1&card_id={$card_id}&vip={$vip}"; $sql = mysql_query("SELECT count(*) FROM " . TABLE_ORDER . " WHERE card_id='{$card_id}' AND card_vip='{$vip}' AND annul='' AND !basket") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $card['active_count'] = (int) @$arr[0]; $card['discount'] = get_discount($card['active_count'] + 1, $vip); $ofcount = 0; $card['office_select'] = mysql_select('office_id', "SELECT office_id, region FROM " . TABLE_OFFICE . " ORDER BY office_id", $card['office_id'], 0, '', $ofcount); $sql = mysql_query("SELECT MIN(card_id) FROM " . TABLE_CARD . " WHERE vip=1 AND active=0") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $card['newcard_id'] = (int) @$arr[0]; $card['admin_cardid'] = $admin_config['cardid']; $card['files'] = get_file_info($file_owner, $card['card_id']); $card['admin_config_card'] = $admin_config['card']; $content = get_template('templ/card.htm', $card); } else { $content = get_template('templ/card.htm', array("error" => 1)); } } else { if ($admin_config['card'] != 2) { $content = 'Нет доступа';
function print_inventory_sales() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200); $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Partial'), _('Net'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission')); $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _('')); $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Series Report'), "Series Report", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; $res = getTransactions($imc, $from); while ($myrow = db_fetch($res)) { $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $res2 = get_return_details($myrow['order_']); $returns = 0; $rtn_dt = 0; while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; $credit_num = $myrow2['customized_no']; $cm_date = $myrow2['tran_date']; $res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; $discount = $myrow['discount']; $invoicetot = $myrow['ov_amount'] + $dt; $sales_discount = ($invoicetot - $total_returns) * ($return_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100); $rep->TextCol(0, 1, $myrow['tran_date']); $rep->TextCol(1, 2, $myrow['br_name']); $rep->TextCol(2, 3, $salesman); $rep->TextCol(3, 4, $myrow['customized_no']); $rep->AmountCol(4, 5, $invoicetot, 2); $rep->TextCol(5, 6, $cm_date); $rep->TextCol(6, 7, $credit_num); $rep->AmountCol(7, 8, $total_returns, 2); $rep->TextCol(8, 9, $return_discount . "%"); $rep->AmountCol(9, 10, $sales_discount, 2); $rep->AmountCol(10, 11, $net_sales, 2); $rep->TextCol(18, 19, $myrow['date']); $rep->TextCol(19, 20, $myrow['commission'] . "%"); $rep->AmountCol(20, 21, $gross_commission, 2); $rep->AmountCol(21, 22, $myrow['with_tax'], 2); $rep->AmountCol(22, 23, $myrow['net_commission'], 2); $or = get_pr_details($myrow['type'], $myrow['trans_no']); while ($pr = db_fetch($or)) { $net_remittance = $net_sales - $pr['amt']; $rep->TextCol(11, 12, $pr['date_alloc']); $rep->TextCol(12, 13, $pr['customized_no']); $rep->TextCol(13, 14, _("DATE")); $rep->TextCol(14, 15, _("OR#")); $rep->TextCol(15, 16, ""); $rep->AmountCol(17, 18, '', 2); } $rep->NewLine(); // } $rep->NewLine(); $rep->End(); }
function print_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $customer = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(4, 40, 60, 100, 200, 250, 300, 320, 400, 450, 500); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); //$params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); $company_data = get_company_prefs(); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); if ($customer && $myrow['debtor_no'] != $customer) { continue; } $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); //$rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); //$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); //$baccount['payment_service'] = $pay_service; $salesman = get_imc_code($branch['branch_code']); $pay_term = get_payment_terms($myrow['payment_terms']); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $invoice_no = get_custom_no($myrow['trans_no'], $myrow['type']); $contact = getContactPerson($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $rep->NewLine(8); $rep->TextCol(2, 7, _("CHARGE INVOICE # " . $invoice_no)); $rep->TextCol(8, 9, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 7, $branch['br_name']); if ($dt != 0) { //$display_bulk_discount = (($sub_total - $myrow['Total']) / $sub_total) * 100; $tot = $myrow['Total'] + $dt; $dscnt = ($tot - $myrow['Total']) / $tot * 100; //$dscnt = ($dt / $myrow['Total']) * 100; $significant = strlen(substr(strrchr($dscnt, "."), 1)); if ($significant > 2) { $rep->TextCol(7, 9, floor($dscnt) . "%"); } else { $rep->TextCol(7, 9, $dscnt . "%"); } } $rep->NewLine(); $rep->TextCol(2, 7, $branch['branch_ref']); $rep->TextCol(8, 9, $salesman); $rep->NewLine(); $rep->TextCol(2, 6, $contact); if ($pay_term['terms'] == 'Cash Only') { $rep->TextCol(8, 9, $pay_term['terms']); } else { $rep->TextCol(7, 10, $pay_term['terms']); } $rep->NewLine(); $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(2, 6, $branch['br_address'], -2); $rep->row = $oldrow; $rep->NewLine(5); $rep->Font('bold'); //$rep->Line($rep->row + 10); //$rep->TextCol(2,5, _("Item Description")); //$rep->TextCol(5,6, _("Quantity")); //$rep->TextCol(7,8, _("Unit Price")); //$rep->TextCol(9,10, _("Total Amount")); //$rep->Line($rep->row - 4); $rep->NewLine(2); $rep->Font(); while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $Net2 = round2($sign * ($myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); $dNet = number_format2($Net2, $dec); /*if ($myrow2["discount_percent"]==0) $DisplayDiscount =""; else $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";*/ //if ($myrow["ov_discount"]==0) // $DisplayDiscount =""; //else //$DisplayDiscount = number_format2($myrow["ov_discount"]/$myrow["ov_amount"] * 100,user_percent_dec()) . "%"; //$rep->TextCol(0, 3, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(0, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(5, 6, $DisplayQty . " " . $myrow2['units']); //$rep->TextCol(5, 6, $myrow2['units'], -2); $rep->TextCol(7, 8, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(8, 10, $dNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplayNet = number_format2($SubTotal, $dec); $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); $DisplayTots = number_format2($myrow['Total'], $dec); $DisplayDiscount = number_format2($SubTotal - $myrow['Total'], $dec); $rep->row = $rep->bottomMargin + 30 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(9, 10, $DisplayNet, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Less discount: ")); $rep->TextCol(9, 10, $DisplayDiscount, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Net Amount : "), -2); $rep->TextCol(9, 10, $DisplayTots, -2); $rep->NewLine(); /*$tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) continue; $DisplayTax = number_format2($sign*$tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) $tax_type_name = $tax_item['tax_type_name']; else $tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) "; if ($tax_item['included_in_price']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign*$tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } else { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign*($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"]+$myrow["ov_freight_tax"]),$dec);*/ //$rep->Font('bold'); //$rep->TextCol(3, 6, _("TOTAL INVOICE"), - 2); //$rep->TextCol(6, 7, $DisplayTotal, -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); //if ($words != "") //{ // $rep->NewLine(1); // $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); //} //$rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
exit(__('log_day_error')); } $tmp = $log_day * 86400; $db->query_unbuffered("delete from " . get_table_credit_log() . " where in_time<{$timestamp}-{$tmp}"); exit('true|' . __('adm_del_log_success')); break; case 'dostat': $act = gpc('act', 'P', ''); $dd = gpc('dd', 'P', ''); if ($act && $dd) { if (in_array($act, array('views', 'downs', 'money'))) { //$all = (float)@$db->result_first("select sum($act) from {$tpf}stat_user where dd='$dd'"); $all = 0; $q = $db->query("select views,downs,money,userid from {$tpf}stat_user where dd='{$dd}'"); while ($rs = $db->fetch_array($q)) { $all += get_discount($rs[userid], $rs[$act]); } $db->free($q); unset($rs); echo 'true|' . round($all, 4); } else { echo 'Error Act'; } } else { echo 'Error action!'; } break; case 'vip_count': $vip_id = (int) gpc('vip_id', 'P', 0); $num = (int) @$db->result_first("select count(*) from {$tpf}users where vip_id='{$vip_id}'"); echo 'true|' . $num;
function print_statements() { global $path_to_root, $systypes_array; include_once $path_to_root . "/reporting/includes/pdf_report2.inc"; $from = date2sql($_POST['PARAM_0']); $to = date2sql($_POST['PARAM_1']); $customer = $_POST['PARAM_2']; $currency = $_POST['PARAM_3']; $email = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $orientation = $orientation ? 'L' : 'P'; $dec = 2; $cols = array(4, 64, 180, 250, 300, 350, 400, 480); //$headers in doctext.inc $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_pref('curr_default'); $PastDueDays1 = get_company_pref('past_due_days'); $PastDueDays2 = 2 * $PastDueDays1; if ($email == 0) { $rep = new FrontReport(_('CUSTOMER ACCOUNT STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } $sql = "SELECT b.debtor_no, b.name AS DebtorName, b.address, b.tax_id, b.curr_code, cust.salesman, \n\tcurdate() AS tran_date, CONCAT (d.name, d.name2) AS contactPerson, d.phone, d.phone2 \n\tFROM " . TB_PREF . "debtors_master b INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id\nINNER JOIN " . TB_PREF . "cust_branch cust on b.debtor_no=cust.debtor_no"; if ($customer != ALL_TEXT) { $sql .= " WHERE c.type='customer' and cust.salesman = " . db_escape($customer); } else { $sql .= " where c.type='customer' and cust.salesman = " . db_escape($customer) . " ORDER by b.name"; } $result = db_query($sql, "The customers could not be retrieved"); while ($debtor_row = db_fetch($result)) { $date = date('Y-m-d'); if ($from != $to) { // find the latest point where the balance was null $start = findLatestNullDate($debtor_row['debtor_no'], $from); // but not earlier than the $to date. if (date1_greater_date2(sql2date($start), sql2date($to))) { $start = $to; } if (date1_greater_date2(sql2date($from), sql2date($start))) { $start = $from; } } else { $start = $from; } $debtor_row['order_'] = ""; $TransResult = getTransactions($debtor_row['debtor_no'], $start, $date); $baccount = get_default_bank_account($debtor_row['curr_code']); $params['bankaccount'] = $baccount['id']; if (db_num_rows($TransResult) == 0) { continue; } if ($email == 1) { $rep = new FrontReport("CUSTOMER ACCOUNT STATEMENT", "", user_pagesize(), 9, $orientation); $rep->title = _('STATEMENT OF ACCOUNT'); $rep->filename = "Statement" . $debtor_row['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } $rep->filename = "ST-" . strtr($debtor_row['DebtorName'], " '", "__") . "--" . strtr(Today(), "/", "-") . ".pdf"; $contacts = get_customer_contacts($debtor_row['debtor_no'], 'invoice'); $rep->SetHeaderType('customheader'); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $rep->SetCommonData($debtor_row, null, null, $baccount, ST_STATEMENT, $contacts); $rep->NewPage(); $doctype = ST_STATEMENT; //$rep->TextCol(0,4,"yeah"); $current = false; $balance = getInitialBalance($debtor_row['debtor_no'], $start); if (true || Abs($balance) > 1.0E-6) { if (Abs($balance) < 1.0E-6) { $rep->SetTextColor(190, 190, 190); } else { if ($balance > 0) { $rep->SetTextColor(190, 0, 0); } } $rep->SetTextColor(0, 0, 0); } $overdue = 0; $prev = ''; $gross_amount = 0; $gross_amount2 = 0; $payment_tot = 0; $tots = 0; $discount_amount = 0; $percent = 0; while ($transaction_row = db_fetch($TransResult)) { if ($myrow['IsVoid'] == '') { $company_data = get_company_prefs(); $branch = get_branch($transaction_row["branch_code"]); $branch_data = get_branch_accounts($transaction_row['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $transaction_row['type'], $transaction_row['trans_no']); $DisplayTotal = number_format2(Abs($transaction_row["TotalAmount"] + $dt), $dec); $DisplayAlloc = number_format2($transaction_row["Allocated"], $dec); $DisplayNet = number_format2($transaction_row["TotalAmount"] - $transaction_row["Allocated"], $dec); /*if ($dt != 0 && $transaction_row['type'] == ST_SALESINVOICE || $transaction_row['type'] == ST_CUSTCREDIT) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; }*/ $amount = $transaction_row["TotalAmount"] + $dt; $balance += $transaction_row["TotalAmount"]; $invoice_no = get_custom_no($transaction_row['trans_no'], $transaction_row['type']); $enter1 = 0; if ($systypes_array[$transaction_row['type']] == "Customer Payment") { $open_pay = get_payment_invoice_details($transaction_row["trans_no"], ST_CUSTPAYMENT); if ($open_pay) { $stat2 = false; } else { $stat2 = true; $payment_tot += $amount; $text = "pr#"; } } if ($systypes_array[$transaction_row['type']] == "Sales Invoice") { if ($transaction_row['ov_amount'] > $transaction_row['alloc'] || $transaction_row['alloc'] == 0) { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount += $amount; $text = ''; $stat3 = true; } else { $stat3 = false; } } if ($systypes_array[$transaction_row['type']] == "Customer Credit Note") { $open = get_sales_invoice_details($transaction_row['order_'], ST_SALESINVOICE); if ($open) { $stat = false; } else { $discount_amount += $dt; $ctr = $transaction_row['bulk_discount']; $gross_amount2 += $amount; $stat = true; } $text = "cm#"; } $current = $text; $tot = $gross_amount + $gross_amount2 - $discount_amount; if ($current != '') { if ($prev == $current) { } else { if ($prev == "" && $text == "cm#" && $stat) { $rep->NewLine(); $rep->TextCol(1, 2, "Less Returns"); $rep->NewLine(); } if ($text == 'pr#' && $prev == "cm#" && $stat2) { $rep->AmountCol(6, 7, $tot, 2); $rep->NewLine(2); $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } if ($prev == '' && $text == 'pr#' && $stat2) { $rep->TextCol(1, 2, "Less Payments:"); $rep->NewLine(); } } $prev = $current; } if ($transaction_row['type'] == ST_SALESINVOICE && $stat3) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTCREDIT && $stat) { $rep->TextCol(1, 2, $text . $invoice_no, -2); $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(3, 4, $DisplayTotal, -2); $rep->NewLine(); } if ($transaction_row['type'] == ST_CUSTPAYMENT && $stat2) { if ($invoice_no == "") { $rep->TextCol(1, 2, $text . $transaction_row['reference'], -2); } else { $rep->TextCol(1, 2, $text . $invoice_no, -2); } $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2); $rep->TextCol(5, 6, $DisplayTotal, -2); $rep->NewLine(); } $rep->SetTextColor(0, 0, 0); //$rep->NewLine(); if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) { $rep->NewPage(); } } } if (!$current) { $overdue = $balance; $balance = 0; } $rep->NewLine(); $net = $gross_amount - abs($gross_amount2); $percent = $ctr / $net * 100; $per = number_format2($percent, 2); if ($per != 0) { $rep->TextCol(1, 2, "Less " . $ctr . "% discount"); $rep->AmountCol(5, 6, $discount_amount, 2); } $rep->SetTextColor(0, 0, 0); $rep->fontSize += 2; $rep->NewLine(5); $rep->TextCol(1, 2, 'Amount Due'); //$rep->TextCol(6,7, " ____________", -2); if ($payment_tot != 0) { $rep->TextCol(6, 7, number_format2($tot - abs($payment_tot), $dec)); } else { $rep->AmountCol(6, 7, $tot, 2); } $rep->NewLine(5); $rep->TextCol(2, 4, "Verified & Checked by:"); $rep->TextCol(4, 6, "___________________"); $rep->NewLine(); $rep->TextCol(4, 6, "Credit & Collection"); $rep->fontSize -= 2; } //$rep->NewPage(); if ($email == 0) { $rep->End(); } }
/** * 获得指定品牌下的推荐和促销商品 * * @access private * @param string $type * @param integer $brand * @return array */ function brand_recommend_goods($type, $brand, $cat = 0) { static $result = NULL; $time = gmtime(); if ($result === NULL) { if ($cat > 0) { $cat_where = "AND " . get_children($cat); } else { $cat_where = ''; } $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.comments_number,g.sales_volume,g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, ' . 'b.brand_name, g.is_best, g.is_new, g.is_hot, g.is_promote ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand}' AND " . "(g.is_best = 1 OR (g.is_promote = 1 AND promote_start_date <= '{$time}' AND " . "promote_end_date >= '{$time}')) {$cat_where}" . 'ORDER BY g.sort_order, g.last_update DESC'; $result = $GLOBALS['db']->getAll($sql); } /* 取得每一项的数量限制 */ $num = 0; $type2lib = array('best' => 'recommend_best', 'new' => 'recommend_new', 'hot' => 'recommend_hot', 'promote' => 'recommend_promotion'); $num = get_library_number($type2lib[$type]); $idx = 0; $goods = array(); foreach ($result as $row) { if ($idx >= $num) { break; } if ($type == 'best' && $row['is_best'] == 1 || $type == 'promote' && $row['is_promote'] == 1 && $row['promote_start_date'] <= $time && $row['promote_end_date'] >= $time) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['sales_volume'] = $row['sales_volume']; $goods[$idx]['comments_number'] = $row['comments_number']; /* 折扣节省计算 by ecmoban start */ if ($row['market_price'] > 0) { $discount_arr = get_discount($row['goods_id']); //函数get_discount参数goods_id } $goods[$idx]['zhekou'] = $discount_arr['discount']; //zhekou $goods[$idx]['jiesheng'] = $discount_arr['jiesheng']; //jiesheng /* 折扣节省计算 by ecmoban end */ $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['short_style_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); $idx++; } } return $goods; }
$bids .= $rs[touserid] . ','; } $db->free($q); unset($rs); $sql_do = $bids ? substr($bids, 0, -1) : ''; $buddys = array(); if ($sql_do) { $perpage = 20; $sql_do = "{$tpf}buddys b,{$tpf}users u where b.userid in ({$sql_do}) and b.touserid=u.userid"; $rs = $db->fetch_one_array("select count(*) as total_num from {$sql_do}"); $total_num = $rs['total_num']; $start_num = ($pg - 1) * $perpage; $q = $db->query("select u.credit,u.username,u.qq,u.userid,b.is_system from {$sql_do} order by bdid desc limit {$start_num},{$perpage}"); //$buddys = array(); while ($rs = $db->fetch_array($q)) { $rs[credit] = get_discount($rs[userid], $rs[credit]); $rs[is_system] = $rs[is_system] ? '系统分配' : '自己推广'; $rs[a_space] = urr("space", "username="******"_blank" href="http://wpa.qq.com/msgrd?v=3&uin=' . $rs[qq] . '&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:' . $rs[qq] . ':52" alt="点击这里给我发消息" title="点击这里给我发消息"/></a>' : ''; $buddys[] = $rs; } $db->free($q); unset($rs); $page_nav = multi($total_num, $perpage, $pg, "mydisk.php?item=profile&action={$action}"); } require_once template_echo('profile', $user_tpl_dir); break; case 'guest': if ($task == 'guest') { auth_task_guest(); } else {
<td align="center"><a href="<?php echo $v['a_space']; ?> " target="_blank"><?php echo $v['username']; ?> </a></td> <?php } ?> <td align="center"><?php echo get_discount($v[userid], $v['file_views']); ?> </td> <td align="center"><?php echo get_discount($v[userid], $v['file_downs']); ?> </td> <td align="center"><?php echo $v['file_size']; ?> </td> <td align="center" width="150" class="td_line txtgray"><?php echo $v['file_time']; ?> </td> </tr> <?php } unset($files_array); } else {
public function reserve() { if (!$this->mid) { // json_return(300,'请先登录.',array(),U('Login/index')); $this->error('请先登录', U('Login/index')); } $goods_id = intval($_POST['goods_id']); $spec_id = intval($_POST['spec_id']); $num = intval($_POST['num']); if ($num) { if ($spec_id) { $goods_id = M('GoodsSpec')->where(array('spec_id' => $spec_id))->getField('goods_id'); } $goods = M('Goods')->where(array('goods_id' => $goods_id))->find(); if (get_distributor($this->mid)) { $cdisc = MSC('distributor_discount'); } else { $cdisc = 1; } $data['order_sn'] = order_sn(); $data['member_id'] = $this->mid; $data['order_type'] = 2; $data['goods_amount'] = $cdisc * get_discount($num) * $num * $goods['goods_price']; $data['discount'] = 0; $data['order_amount'] = $data['goods_amount'] - $data['discount']; $data['order_state'] = 0; $data['add_time'] = NOW_TIME; $data['goods_id'] = $goods_id; $data['spec_id'] = $spec_id; $data['reserve_num'] = $num; $res = M('Reserve')->add($data); if ($res) { $this->success('预订成功', $_SERVER['HTTP_REFERER']); // json_return(200,'预订成功.'); } else { $this->error('预订失败'); // json_return(300,'预定失败.'); } } else { $this->error('预订数量不能为空'); json_return(300, '预订数量不能为空'); } }
function print_cash_sale() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 250, 350, 400, 450, 500, 550, 600, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200); $headers = array(_('DATE'), _('CLIENT NAME'), _('IMC'), _('CASH SALES'), _('INVOICE'), _('CASH'), _('SALES'), _('RETURNS'), _('SALES DISCOUNT'), _('SUNDRIES'), _('DR'), _('CR')); $header2 = array(_(''), '', _('CODE'), _('INVOICE'), _('AMOUNT'), _('DR'), _('CR'), _(' DR'), _('DR'), _(''), _('')); $aligns = array('left', 'left', 'center', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Cash Sales Report'), "CashSalesReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from); while ($myrow = db_fetch($res)) { $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $sales_acct = get_discount($branch_data['sales_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $invoicetot = $myrow['ov_amount'] + $dt; $invoice_discount = $dt / $invoicetot * 100; $rep->TextCol(0, 1, $myrow['tranDate']); $rep->TextCol(1, 2, $myrow['br_name']); $rep->TextCol(2, 3, $salesman); $rep->TextCol(3, 4, $myrow['customized_no']); if ($myrow['IsVoid'] == '') { $rep->AmountCol(4, 5, $invoicetot, 2); $rep->AmountCol(5, 6, $myrow['ov_amount'], 2); $rtn_dt = 0; $res2 = get_return_details($myrow['order_']); while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; $res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $net_sales = abs($sales_acct) - $dt - $rtn_dt; $rep->AmountCol(6, 7, $net_sales, 2); if ($rtn_dt != 0) { $rep->AmountCol(7, 8, $rtn_dt, 2); } if ($dt != 0) { $rep->AmountCol(8, 9, $dt, 2); } $rep->NewLine(); } else { $rep->TextCol(4, 5, "Voided"); } $net_invoice += $invoicetot; $net_dr += $myrow['ov_amount']; $net_cr += $net_sales; $net_return += $rtn_dt; $net_ret_dt += $dt; } $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(1, 2, "TOTAL"); $rep->AmountCol(4, 5, $net_invoice, 2); $rep->AmountCol(5, 6, $net_dr, 2); $rep->AmountCol(6, 7, $net_cr, 2); $rep->AmountCol(7, 8, $net_return, 2); $rep->AmountCol(8, 9, $net_ret_dt, 2); $rep->End(); }
function conv_credit($uid) { global $db, $tpf; $myinfo[credit] = get_profile($uid, 'credit'); $myinfo[dl_credit] = get_profile($uid, 'dl_credit'); if (get_income_rate($uid)) { $money = get_discount($uid, $myinfo[credit]) * get_income_rate($uid); $dl_money = get_discount($uid, $myinfo['dl_credit']) * get_income_rate($uid, 1); $add_wealth = round($money + $dl_money, 4); $db->query_unbuffered("update {$tpf}users set credit=0,dl_credit=0,wealth=wealth+{$add_wealth} where userid='{$uid}' limit 1"); //echo $add_wealth; return true; } }
public function cartsummary() { $this->load->model('Memorial_model'); $this->load->model('Affiliate_model'); $comm = $this->Affiliate_model->get_affiliate($this->session->userdata('affiliate_id')); $this->load->model('Group_model'); $cart = $this->Order_model->get_cart($this->session->userdata('cart_id')); $totals = array('itemtotal' => 0, 'shipping' => 0, 'service' => 0, 'surcharge' => 0, 'tax' => 0, 'coupon' => 0, 'coupon_code' => '', 'discount' => 0, 'grandtotal' => 0, 'discount_type' => 'percentage', 'coupon_type' => 'percentage'); $coupon_discount = 0; $this->load->model('Company_model'); $this->load->model('Customer_model'); $cartdiscount = 0; $cartcoupon = 0; $cartdiscounttype = 'percentage'; $cartcoupontype = 'percentage'; foreach ($cart as $item) { $totals['itemtotal'] += $item->product_price; foreach ($item->addons as $addon) { $totals['itemtotal'] += $addon->addon_price * $addon->addon_quantity; } } if ($user_discount = $this->Customer_model->getDiscount($this->session->userdata('customer_id'))) { $totals['discount'] = $totals['itemtotal'] * $user_discount / 100; } else { if ($this->session->userdata('coupon')) { if ($coupon = get_coupon_discount($this->session->userdata('coupon'), $totals['itemtotal'])) { $totals['coupon_code'] = $coupon->discount_name; if ($coupon->discount_amount > 0) { $cartcoupon = $coupon->discount_amount; $cartcoupontype = 'amount'; } else { $cartcoupon = $coupon->discount_percentage; $cartcoupontype = 'percentage'; } } } if ($cartcoupon <= 0) { if ($discount = get_discount($totals['itemtotal'])) { if ($discount->discount_amount > 0) { $cartdiscount = $discount->discount_amount; $cartdiscounttype = 'amount'; } else { $cartdiscount = $discount->discount_percentage; $cartdiscounttype = 'percentage'; } } } } $itemscount = count($cart); foreach ($cart as $item) { $ptotal = $item->product_price; foreach ($item->addons as $addon) { $ptotal += $addon->addon_price * $addon->addon_quantity; } $addition = $this->Order_model->get_add_estimate($item->orderitem_id); //$addition = $this->Group_model->get_add_charges($item->product_id,$item->postalcode); //san has changed on 13-7-2013 //$totals['shipping'] += 10; ///$addition['shipping']; $totals['shipping'] += $addition['shipping']; $totals['service'] += $addition['service']; $totals['surcharge'] += $addition['surcharge']; if ($cartcoupon > 0) { if ($cartcoupontype == 'percentage') { $totals['coupon'] += $cartcoupon * $ptotal / 100; $ptotal -= $cartcoupon * $ptotal / 100; } else { $part = $cartcoupon / $itemscount; $totals['coupon'] += $part; $ptotal -= $part; } } else { if ($cartdiscounttype == 'percentage') { $totals['discount'] += $cartdiscount * $ptotal / 100; $ptotal -= $cartdiscount * $ptotal / 100; } else { $part = $cartdiscount / $itemscount; $totals['discount'] += $part; $ptotal -= $part; } } $ptotal += $addition['shipping']; $ptotal += $addition['service']; $ptotal += $addition['surcharge']; $totals['tax'] += $addition['tax'] * $ptotal / 100; //$addition['tax'] } $totals['grandtotal'] = number_format($totals['itemtotal'], 2) + number_format($totals['shipping'], 2) + number_format($totals['service'], 2) + number_format($totals['surcharge'], 2) + number_format($totals['tax'], 2) - number_format($totals['discount'], 2) - number_format($totals['coupon'], 2); $data['p'] = (object) $_POST; $data['totals'] = $totals; $data['cart'] = $cart; //$data['commission'] = ($this->cart->total() * $comm->commission)/100; $result = array('cartsummary' => $this->load->view('mymemorial/summary', $data, true), 'shipping' => $totals['shipping'], 'tax' => $totals['tax'], 'commission' => 0); echo json_encode($result); }
function checkout() { use_ssl(TRUE); $cart_id = $this->session->userdata('cart_id'); if ($this->Order_model->is_cart_empty($cart_id)) { redirect('/shop/cart'); exit; } elseif (!$this->Order_model->is_delivery_entered($cart_id)) { redirect('/shop/delivery'); exit; } elseif (!$this->Order_model->is_billing_entered($cart_id)) { redirect('/shop/billing'); exit; } else { $this->load->model('Group_model'); $cart = $this->Order_model->get_fullcart($this->session->userdata('cart_id')); $totals = array('itemtotal' => 0, 'shipping' => 0, 'service' => 0, 'surcharge' => 0, 'tax' => 0, 'discount' => 0, 'coupon' => 0, 'coupon_code' => '', 'companyless' => 0, 'grandtotal' => 0); $order_items = ''; $oformat = file_get_contents('assets/email_items.html'); $aoformat = $itemformat = ''; $aitemformat = ''; $icnt = 0; $itemprc = 0; $this->load->model('Company_model'); $this->load->model('Customer_model'); $conversion = ''; $cartitems = array(); foreach ($cart as $item) { $itemprc = 0; $ptotal = $item->product_price; $icnt++; $itemf = $oformat; $itemf = str_replace('{counter}', $icnt, $itemf); $itemf = str_replace('{firstname}', $item->firstname, $itemf); $itemf = str_replace('{lastname}', $item->lastname, $itemf); $itemf = str_replace('{address1}', $item->address1, $itemf); $itemf = str_replace('{address2}', $item->address2, $itemf); $itemf = str_replace('{city}', $item->city, $itemf); $itemf = str_replace('{postalcode}', $item->postalcode, $itemf); $itemf = str_replace('{province}', $item->province, $itemf); $itemf = str_replace('{country}', $item->country_id, $itemf); $itemf = str_replace('{phone}', $item->dayphone . ' ' . $item->evephone, $itemf); $itemf = str_replace('{message}', $item->card_message, $itemf); // $itemf = str_replace('{delivery_date}',date('d M Y',strtotime($item->delivery_date)),$itemf); $itemf = str_replace('{delivery_date}', date('d M Y', strtotime($item->delivery_date)) . ' - ' . $item->delivery_time, $itemf); $itemf = str_replace('{shipping_method}', $item->infotext, $itemf); $itemf = str_replace('{delivery_info}', $item->delivery_description, $itemf); $itemf = str_replace('{product_image}', '<img src="' . $this->config->item('base_url') . img_format('productres/' . $item->product_picture, 'thumb') . '" />', $itemf); $itemf = str_replace('{product_code}', $item->product_code, $itemf); $itemf = str_replace('{product_name}', $item->product_name . '<br/><small>(' . $item->price_name . ')</small>', $itemf); $itemf = str_replace('{price}', '$' . number_format($item->product_price, 2), $itemf); $itemf = str_replace('{quantity}', '1', $itemf); $itemprc += $item->product_price; if ($item->delivery_method_id == 1) { $itemf = str_replace('{delivery_by}', 'Delivery by Local', $itemf); } else { $itemf = str_replace('{delivery_by}', 'This bouquet comes to via UPS.', $itemf); } $itemf = str_replace('{total}', '$' . number_format($item->product_price, 2), $itemf); $totals['itemtotal'] += $item->product_price; if (array_key_exists($item->product_id, $cartitems)) { $cartitems[$item->product_id]['sku'] = $item->product_code; $cartitems[$item->product_id]['qty'] = $cartitems[$item->product_id]['qty'] + 1; $cartitems[$item->product_id]['amt'] = $cartitems[$item->product_id]['amt'] + $item->product_price * 100; $cartitems[$item->product_id]['name'] = urlencode($item->product_name); $cartitems[$item->product_id]['category'] = urlencode($item->category); } else { $cartitems[$item->product_id]['sku'] = $item->product_code; $cartitems[$item->product_id]['qty'] = 1; $cartitems[$item->product_id]['amt'] = $item->product_price * 100; $cartitems[$item->product_id]['name'] = urlencode($item->product_name); $cartitems[$item->product_id]['category'] = urlencode($item->category); } $addontot = 0; if (count($item->addons)) { $order_items = ''; foreach ($item->addons as $addon) { $order_items .= '+(' . $addon->addon_name . " " . $addon->addon_quantity . 'x$' . number_format($addon->addon_price, 2) . ") \$" . number_format($addon->addon_price * $addon->addon_quantity, 2) . "<br/>\n"; $totals['itemtotal'] += $addon->addon_price * $addon->addon_quantity; $itemprc += $addon->addon_price * $addon->addon_quantity; $addontot += $addon->addon_price * $addon->addon_quantity; $ptotal += $addon->addon_price * $addon->addon_quantity; if (array_key_exists($addon->addon_id, $cartitems)) { $cartitems[$addon->addon_id]['sku'] = $addon->addon_id; $cartitems[$addon->addon_id]['qty'] = $cartitems[$addon->addon_id]['qty'] + $addon->addon_quantity; $cartitems[$addon->addon_id]['amt'] = $cartitems[$addon->addon_id]['amt'] + $addon->addon_price * 100; $cartitems[$addon->addon_id]['name'] = urlencode($addon->addon_name); $cartitems[$item->product_id]['category'] = urlencode($item->category); } else { $cartitems[$addon->addon_id]['sku'] = $addon->addon_id; $cartitems[$addon->addon_id]['qty'] = $addon->addon_quantity; $cartitems[$addon->addon_id]['amt'] = $addon->addon_price * 100; $cartitems[$addon->addon_id]['name'] = urlencode($addon->addon_name); $cartitems[$item->product_id]['category'] = urlencode($item->category); } //echo $order_items; } //echo $order_items; } else { $order_items .= 'None'; } $conversion .= 'bta.addConversionLegacy("$", "' . $item->product_name . '", "' . number_format($itemprc, 2) . '");' . "\n"; $itemf = str_replace('{addons}', $order_items, $itemf); $itemf = str_replace('{addon_price}', '$' . number_format($addontot, 2), $itemf); $addition = $this->Order_model->get_add_charges($item->orderitem_id); if (!($waiver = $this->Company_model->checkWaiver($this->session->userdata('customer_id')))) { $totals['shipping'] += $addition['shipping']; $totals['service'] += $addition['service']; $totals['surcharge'] += $addition['surcharge']; } $totals['tax'] += $addition['tax'] * $ptotal / 100; $aitemformat .= str_replace('{product_description}', '', $itemf); $itemf = str_replace('{product_description}', substr($item->product_description, 0, 50), $itemf); $itemformat .= $itemf; } $ggitems = ''; foreach ($cartitems as $citem) { $productids[] = $citem['sku'] . ':' . str_replace('+', '', $citem['name']); $itemvalues[] = $citem['amt']; $units[] = $citem['qty']; $skulist[] = $citem['sku']; $qlist[] = $citem['qty']; $amtlist[] = $citem['amt']; $namelist[] = $citem['name']; } $coupon_discount = 0; if ($user_discount = $this->Customer_model->getDiscount($this->session->userdata('customer_id'))) { $totals['discount'] = $totals['itemtotal'] * $user_discount / 100; } else { if ($this->session->userdata('coupon')) { $coupon = get_coupon_discount($this->session->userdata('coupon'), $totals['itemtotal']); $totals['coupon_code'] = $coupon->discount_name; $totals['coupon'] = $coupon->discount_amount ? $coupon->discount_amount : $coupon->discount_percentage * $totals['itemtotal'] / 100; } $totals['discount'] = get_discount($totals['itemtotal']); $totals['companyless'] = get_company_discount($totals['itemtotal'], $this->session->userdata('customer_id') ? $this->session->userdata('customer_id') : '0'); } if ($totals['discount'] > 0) { $skulist[] = 'Discount'; $qlist[] = 0; $amtlist[] = $totals['discount'] * -100; $namelist[] = 'Discount'; $productids[] = 'Discount'; $itemvalues[] = round($totals['discount'] * 100); $units[] = 1; } else { $productids[] = 'Discount'; $itemvalues[] = 0; $units[] = 1; } $totals['grandtotal'] = $totals['itemtotal'] + $totals['shipping'] + $totals['service'] + $totals['surcharge'] + $totals['tax'] - $totals['discount'] - $totals['coupon'] - $totals['companyless']; $invoiceTotal = number_format($totals['grandtotal'], 2); $customer_id = $this->session->userdata('customer_id') ? $this->session->userdata('customer_id') : '0'; $affiliate_id = $this->session->userdata('referer') ? $this->session->userdata('referer') : ''; $this->form_validation->set_rules("cardnumber", 'Credit Card Number', 'required|numeric|min_length[15]|max_length[16]'); $this->form_validation->set_rules("expiry_month", 'Expiry Month', 'required|min_length[2]|max_length[5]'); $this->form_validation->set_rules("expiry_year", 'Expiry Year', 'required|min_length[2]|max_length[5]'); $this->form_validation->set_rules("cvv", 'CVV2', 'required|min_length[3]|max_length[5]'); $this->form_validation->set_error_delimiters('<span class="error error_span">', '</span>'); if ($this->form_validation->run() == TRUE) { $eformat = file_get_contents('assets/email_format.html'); $eheader = file_get_contents('assets/email_header.html'); $this->load->library('plugnpay'); $order = unserialize(base64_decode($_POST['data'])); $country = $this->Country_model->get_country($order->country_id); $order->country = $country->country_name; $order->ipaddress = $_SERVER['REMOTE_ADDR']; $order->nameoncard = $this->input->post('nameoncard'); $order->cardnumber = $this->input->post('cardnumber'); $order->cvv = $this->input->post('cvv'); $order->expiry = $this->input->post('expiry_month') . '/' . $this->input->post('expiry_year'); $order->total = $totals['grandtotal']; $order->affiliate_id = $this->session->userdata('referer') ? $this->session->userdata('referer') : '0'; $eheader = str_replace('{firstname}', $order->firstname, $eheader); $eformat = str_replace('{firstname}', $order->firstname, $eformat); $eformat = str_replace('{lastname}', $order->lastname, $eformat); $eformat = str_replace('{address1}', $order->address1, $eformat); $eformat = str_replace('{address2}', $order->address2, $eformat); $eformat = str_replace('{city}', $order->city, $eformat); $eformat = str_replace('{postalcode}', $order->postalcode, $eformat); $eformat = str_replace('{country}', $order->country, $eformat); $eformat = str_replace('{email}', $order->email, $eformat); $eformat = str_replace('{dayphone}', $order->dayphone, $eformat); $eformat = str_replace('{evephone}', $order->dayphone, $eformat); $eformat = str_replace('{product_price}', '$' . number_format($totals['itemtotal'], 2), $eformat); $eformat = str_replace('{delivery_charge}', '$' . number_format($totals['shipping'], 2), $eformat); $eformat = str_replace('{service_charge}', '$' . number_format($totals['service'], 2), $eformat); $eformat = str_replace('{surcharge}', '$' . number_format($totals['surcharge'], 2), $eformat); $eformat = str_replace('{discount}', '$' . number_format($totals['discount'] - $totals['coupon'] - $totals['companyless'], 2), $eformat); $eformat = str_replace('{tax}', '$' . number_format($totals['tax'], 2), $eformat); $eformat = str_replace('{grand_total}', '$' . number_format($totals['grandtotal'], 2), $eformat); if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' && ENVIRONMENT == 'development') { $result['FinalStatus'] = 'success'; $payment_method = 'credit_card'; } else { $result = $this->plugnpay->pay($order); /* echo 'Website on Test...<br/>'; echo $result['MErrMsg']; echo '<pre>'; die(print_r($result)); echo '</pre>'; */ $payment_method = 'credit_card'; } if ($result['FinalStatus'] == 'success') { if ($oid = $this->Order_model->create_Order($this->session->userdata('cart_id'), $totals, $customer_id, $affiliate_id, $payment_method)) { //$linkimg = '<img src="http://track.linksynergy.com/ // ep?mid=xxxx&ord=xx&skulist=xxxx // &qlist=xxx&amtlist=xxxx&cur=xxx&namelist=xxxxx">'; $cart_id = $this->session->userdata('cart_id'); $this->db->where('cart_id', $cart_id); $this->db->update('carts', array('completed' => '1')); $this->session->set_userdata('cart_id', '0'); $temptot = $totals['itemtotal'] - $totals['discount'] - $totals['coupon']; $linkimg = '<img src="http://track.linksynergy.com/ep?mid=37609&ord=' . $oid; $linkimg .= '&skulist=' . implode('|', $skulist); $linkimg .= '&qlist=' . implode('|', $qlist); $linkimg .= '&amtlist=' . implode('|', $amtlist); $linkimg .= '&cur=CAD'; $linkimg .= '&namelist=' . implode('|', $namelist) . '">'; $tsa = '<script src="https://thesearchagency.net/tsawaypoint.php?siteid=855&wayid=7685&'; $tsa .= 'value=' . round($totals['grandtotal'] * 100); $tsa .= '&units=1|' . implode('|', $units) . '|1'; $tsa .= '&productID=order|' . implode('|', $productids) . '|Shipping'; $tsa .= '&itemValues=' . round($totals['grandtotal'] * 100) . '|' . implode('|', $itemvalues) . '|' . ($totals['shipping'] + $totals['service'] + $totals['surcharge']) * 100; $tsa .= '&backref=' . $oid . '" language="JavaScript" type="text/javascript"></script>'; $emlimg = '<img src="http://email.1800florists.ca/public/?q=direct_add&fn=Public_DirectAddForm&id=bvvqnvtvffundtrubmhhrsjocigpbmg&email='; $emlimg .= $order->email . '&field1=lastorderdate,set,'; $emlimg .= date('Y-m-d', time()) . '&field2=lastordertotal,set,'; $emlimg .= number_format($temptot, 2) . '&list1=0bba03ec00000000000000000000000492e6" width="0" height="0" border="0" alt=""/>'; $ggtrans = 'pageTracker._addTrans('; $ggtrans .= '"' . $oid . '",'; $ggtrans .= '"1-800-Flowers Canada",'; $ggtrans .= '"' . $temptot . '",'; $ggtrans .= '"' . number_format($totals['tax'], 2) . '",'; $ggtrans .= '"' . number_format($totals['shipping'] + $totals['service'] + $totals['surcharge'], 2) . '",'; $ggtrans .= '"Toronto",'; $ggtrans .= '"Ontario",'; $ggtrans .= '"Canada");'; $ggitems = ''; foreach ($cartitems as $citem) { $skulist[] = $citem['sku']; $qlist[] = $citem['qty']; $amtlist[] = $citem['amt']; $namelist[] = $citem['name']; $ggitems .= 'pageTracker._addItem('; $ggitems .= '"' . $oid . '",'; $ggitems .= '"' . $citem['sku'] . '",'; $ggitems .= '"' . $citem['name'] . '",'; $ggitems .= '"' . $citem['category'] . '",'; $ggitems .= '"' . number_format($citem['amt'] / 100, 2) . '",1'; $ggitems .= ');' . "\n"; } $data['googlecode'] = $ggtrans . "\n\n" . $ggitems; $data['linkimg'] = $linkimg; $data['tsa'] = $tsa; $data['emlimg'] = $emlimg; $data['conversion'] = $conversion; $data['invoiceTotal'] = $invoiceTotal; $eformat = str_replace('{invoice_num}', $oid, $eformat); $admin_format = $eformat; $admin_format = str_replace('{items}', $aitemformat, $admin_format); $admin_format = str_replace('{email_header}', 'User Type:' . strtoupper($this->session->userdata('user_role')), $admin_format); $eformat = str_replace('{items}', $itemformat, $eformat); $eformat = str_replace('{email_header}', $eheader, $eformat); $this->load->library('email'); $email_config['mailtype'] = 'html'; $this->email->initialize($email_config); $this->email->from('*****@*****.**', '1-800-Flowers'); //$this->email->to($order->email); $this->email->to($order->email); $this->email->subject('1-800-Flowers Order Confirmation'); $this->email->message($eformat); if ($this->email->send()) { $success = true; } $this->email->from('*****@*****.**', '1-800-Flowers'); $this->email->to('*****@*****.**'); $this->email->subject('1-800-Flowers Order Confirmation'); $this->email->message($admin_format); if ($this->email->send()) { $success = true; } $this->unset_cart(); $data['items'] = $this->Order_model->getDelivery($cart_id); $data['message'] = 'Your order completed successfully'; $data['invoice_number'] = $oid; $data['totals'] = $totals; $data['billing'] = $this->Order_model->getBilling($cart_id); $data['page'] = $this->Pages_model->return_page('order-thanks'); $data['paths'] = array('Home' => path(), 'Checkout' => '#', 'Thank you' => ''); $this->load->view('thankyou', $data); exit; } } else { $elist = '<ul class="elist">'; if ($cerrors = explode('|', $result['MErrMsg'])) { foreach ($cerrors as $ce) { if (!empty($ce)) { $elist .= '<li>' . $ce . '</li>'; } } } else { $elist = '<li>' . $result['MErrMsg'] . '<li>'; } $elist .= '</ul>'; $elist = '<div class="show_errors"><h3>' . 'Error in Payment' . '</h3>' . $elist . '</div>'; } } $this->load->Model('Occasion_model'); $data['elist'] = isset($elist) ? $elist : ''; $data['countries'] = $this->Country_model->get_countries(); $data['items'] = $this->Order_model->getDelivery($cart_id); $data['occasions'] = $this->Occasion_model->get_occasions_array(); $data['billing'] = $this->Order_model->getBilling($cart_id); if ($this->session->userdata('user_role') == 'company') { $this->load->model('Company_model'); $pmethod = $this->Company_model->get_pmethod($this->session->userdata('customer_id')); if ($pmethod == 1) { $data['on_account'] = 1; } else { $data['on_account'] = 0; } } else { $data['on_account'] = 0; } $data['encoded'] = base64_encode(serialize($data['billing'])); $data['totals'] = $totals; $data['current_page'] = 'revieworder'; $data['page'] = $this->Pages_model->return_page('checkout'); $data['paths'] = array('Home' => path(), 'Checkout' => '#', 'Review & Pay' => ''); $this->load->View('checkout', $data); } }
function cal_downs($file_id) { global $db, $tpf, $timestamp, $onlineip, $my_sid, $auth, $settings; $down_file = gpc('down_file_log', 'C', 0); $rs = $db->fetch_one_array("select userid,file_size from {$tpf}files where file_id='{$file_id}'"); if ($rs) { $userid = $rs[userid]; $file_size = $rs[file_size]; } unset($rs); $ip_interval = get_plans(get_profile($userid, 'plan_id'), 'ip_interval'); $ip_interval = $ip_interval ? (int) $ip_interval : 24; $db->query_unbuffered("update {$tpf}files set file_last_view='{$timestamp}' where file_id='{$file_id}'"); if (!$down_file && check_download_ok($my_sid, $ip_interval * 60)) { //if(1){ pd_setcookie('down_file_log', 1, $ip_interval * 60); $id = (int) @$db->result_first("select id from " . get_table_day_down() . " where file_id='{$file_id}' and d_day='" . date('Ymd') . "'"); if (!$id) { $ins = array('d_year' => date('Y'), 'd_month' => date('Ym'), 'd_day' => date('Ymd'), 'd_week' => date('YW'), 'file_id' => $file_id, 'down_count' => 1, 'userid' => $userid); $db->query_unbuffered("insert into " . get_table_day_down() . " set " . $db->sql_array($ins) . ""); if ($auth[open_plan_active] && $settings[open_plan_active]) { $dday = date('Ymd', strtotime('-1 day')); $dweek = date('YW', strtotime('-1 week')); if ($settings[down_active_interval] == 'week') { $sql_do = " and d_week='{$dweek}'"; } else { $sql_do = " and d_day='{$dday}'"; } $mydowns = (int) @$db->result_first("select sum(down_count) from " . get_table_day_down() . " where userid='{$userid}' {$sql_do}"); //echo $mydowns.','; $mydowns = $mydowns ? get_discount($userid, $mydowns) : 1; $to_plan_id = @$db->result_first("select plan_id from {$tpf}plans where {$mydowns}>=down_active_num_min and {$mydowns}<down_active_num_max and is_hidden=0"); //echo $to_plan_id; if ($to_plan_id && date('Ymd', get_profile($userid, 'plan_conv_time')) != date('Ymd')) { conv_credit($userid); $ins = array('open_plan' => 1, 'plan_id' => $to_plan_id, 'credit_rate' => get_plans($to_plan_id, 'income_rate'), 'plan_conv_time' => $timestamp); $db->query_unbuffered("update {$tpf}users set " . $db->sql_array($ins) . " where userid='{$userid}'"); } } } else { $db->query_unbuffered("update " . get_table_day_down() . " set down_count=down_count+1 where id='{$id}'"); } $add_credit = 1; if ($settings[promo_time] != '') { $hour = date('G'); $arr = explode(',', $settings[promo_time]); if (in_array($hour, $arr)) { $add_credit = 2; } } add_credit_log($file_id, $add_credit, 'download', $userid); $db->query_unbuffered("update {$tpf}users set credit=credit+{$add_credit} where userid='{$userid}'"); $db->query_unbuffered("update {$tpf}files set file_downs=file_downs+1 where file_id='{$file_id}'"); $db->query_unbuffered("update {$tpf}users set dl_credit=dl_credit+1 where userid=(select userid from {$tpf}buddys where touserid='{$userid}')"); $upline_userid = (int) @$db->result_first("select userid from {$tpf}buddys where touserid='{$userid}'"); $db->query_unbuffered("update {$tpf}users set dl_credit2=dl_credit2+1 where userid=(select userid from {$tpf}buddys where touserid='{$upline_userid}')"); } echo 'true'; }
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $display = $GLOBALS['display']; //获取显示商品条件 add by hg for date 2014-03-26 $agency_where = agency_goods(); if ($agency_where != null) { $agency_where = 'g.' . $agency_where; } $where = "{$agency_where} g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 AND ({$children} OR " . get_extension_goods($children) . ')'; if ($brand > 0) { $where .= "AND g.brand_id={$brand} "; } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style,g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE {$where} {$ext} ORDER BY {$sort} {$order}"; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['sales_volume'] = $row['sales_volume']; $arr[$row['goods_id']]['comments_number'] = $row['comments_number']; /* 折扣节省计算 by ecmoban start */ if ($row['market_price'] > 0) { $discount_arr = get_discount($row['goods_id']); //函数get_discount参数goods_id } $arr[$row['goods_id']]['zhekou'] = $discount_arr['discount']; //zhekou $arr[$row['goods_id']]['jiesheng'] = $discount_arr['jiesheng']; //jiesheng /* 折扣节省计算 by ecmoban end */ $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = !preg_match('/¥/', price_format($row['shop_price'])) ? '<span style="font-size:12px;text-decoration:line-through;font-weight:normal;color:#666666;">市场价:' . price_format($row['market_price'], true, true) . '</span>' : price_format($row['shop_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $goods_thumb = ''; $goods_thumb = get_image_path($row['goods_id'], $row['goods_thumb'], true); $strp = strstr($goods_thumb, 'http://'); $arr[$row['goods_id']]['goods_thumb'] = $strp ? $goods_thumb : img_url() . $goods_thumb; $goods_img = ''; $goods_img = get_image_path($row['goods_id'], $row['goods_img']); $trpos = strstr($goods_img, 'http://'); $arr[$row['goods_id']]['goods_img'] = $trpos ? $goods_img : img_url() . $goods_img; $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $arr; }
echo __('user_credit'); ?> :<input type="text" name="credit" value="<?php echo $myinfo['credit']; ?> " size="10" maxlength="10"/> <?php if ($auth[open_discount]) { ?> <span class="txtred" title="<?php echo __('discount_show'); ?> "><?php echo get_discount($user[userid], $myinfo[credit]); ?> </span> <?php } ?> <?php echo __('downline_credit'); ?> :<input type="text" name="dl_credit" value="<?php echo $myinfo['dl_credit']; ?> " size="10" maxlength="10"/>
/** * 获得分类下的商品 * * @access public * @param string $children * @return array */ function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order) { $display = $GLOBALS['display']; $where = "g.is_on_sale = 1 AND g.is_alone_sale = 1 AND " . "g.is_delete = 0 AND ({$children} OR " . get_extension_goods($children) . ')'; if ($brand > 0) { $where .= "AND g.brand_id={$brand} "; } if ($min > 0) { $where .= " AND g.shop_price >= {$min} "; } if ($max > 0) { $where .= " AND g.shop_price <= {$max} "; } /* 获得商品列表 */ $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.comments_number,g.sales_volume,g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, g.goods_type, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE {$where} {$ext} ORDER BY {$sort} {$order}"; $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); } else { $promote_price = 0; } /* 处理商品水印图片 */ $watermark_img = ''; if ($promote_price != 0) { $watermark_img = "watermark_promote_small"; } elseif ($row['is_new'] != 0) { $watermark_img = "watermark_new_small"; } elseif ($row['is_best'] != 0) { $watermark_img = "watermark_best_small"; } elseif ($row['is_hot'] != 0) { $watermark_img = 'watermark_hot_small'; } if ($watermark_img != '') { $arr[$row['goods_id']]['watermark_img'] = $watermark_img; } $arr[$row['goods_id']]['goods_id'] = $row['goods_id']; if ($display == 'grid') { $arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; } else { $arr[$row['goods_id']]['goods_name'] = $row['goods_name']; } $arr[$row['goods_id']]['name'] = $row['goods_name']; $arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; $arr[$row['goods_id']]['sales_volume'] = $row['sales_volume']; $arr[$row['goods_id']]['comments_number'] = $row['comments_number']; /* 折扣节省计算 by ecmoban start */ if ($row['market_price'] > 0) { $discount_arr = get_discount($row['goods_id']); //函数get_discount参数goods_id } $arr[$row['goods_id']]['zhekou'] = $discount_arr['discount']; //zhekou $arr[$row['goods_id']]['jiesheng'] = $discount_arr['jiesheng']; //jiesheng /* 折扣节省计算 by ecmoban end */ $arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']); $arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); $arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); $arr[$row['goods_id']]['type'] = $row['goods_type']; $arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; $arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $arr; }
function print_summary() { global $path_to_root; $imc = $_POST['PARAM_0']; $from = $_POST['PARAM_1']; $to = $_POST['PARAM_2']; $status = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 520, 550); $headers = array(_('IMC'), _('Gross'), _('Returns'), _('Discount'), _('% To Sales'), _('Net Sales'), _('Full Payment'), _('% To Sales'), _('Partial Payments'), _('% To Sales'), _('Accounts Receivables'), _('% To Sales')); $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $aligns2 = $aligns; $summary = 1; $rep = new FrontReport(_('Sales Status'), "Sales Status", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info(null, $cols, $headers, $aligns); $rep->NewPage(); $result = getTransactions($imc, $from, $to, ST_SALESINVOICE, $status); $InvoiceTotal = 0; $TotalReturn = 0; $DiscountTotal = 0; $NetSales = 0; $FullAlloc = 0; $PartialAlloc = 0; $ReceivablesTotal = 0; $Percentage1 = 0; $Percentage2 = 0; $Percentage3 = 0; $Percentage4 = 0; $TotalInvoice = 0; $TotalReturn_2 = 0; $TotalSales = 0; $TotalFullAlloc = 0; $TotalPartialAlloc = 0; $TotalReceivables = 0; $TotalDiscount = 0; $previous = ''; while ($myrow = db_fetch($result)) { $company_data = get_company_prefs(); $imc = $myrow['imc_code']; $imc_code = $myrow['salesman_code']; $DiscountTotal = getDiscountTotal($imc_code, $from, $to, ST_SALESINVOICE, get_company_pref('default_sales_discount_act'), $status); $ReturnDiscount = getDiscountTotal($imc_code, $from, $to, ST_CUSTCREDIT, get_company_pref('default_sales_discount_act'), $status); $InvoiceTotal = $myrow['InvoiceTotal'] + $DiscountTotal; $TotalDiscount = $ReturnDiscount + $DiscountTotal; $net_partial = 0; $net_full_payment = 0; $TotalReturn = 0; $Transact = getAllocTransact($from, $to, $imc_code, $status); while ($row = db_fetch($Transact)) { $branch = get_branch($row["branch_code"]); $branch_data = get_branch_accounts($row['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $row['type'], $row['trans_no']); $res2 = get_return_details($row['order_']); $returns = 0; $rtn_dt = 0; $num = db_num_rows($res2); $var = array(); while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; $var = array($myrow2['trans_no']); } foreach ($var as $vars) { $res2 = get_return_discount($branch_data['sales_discount_account'], ST_CUSTCREDIT, $vars); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; $TotalReturn += $total_returns; $invoicetot = $row['ov_amount'] + $dt; $invoice_discount = $dt / $invoicetot * 100; $sales_discount = ($invoicetot - $total_returns) * ($invoice_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; if ($row['IsVoid'] == '') { $partial_payment = 0; $zero; $or = get_pr_details($row['type'], $row['trans_no']); $num2 = db_num_rows($or); $date_alloc = ''; $ctr = 0; $bal = 0; $bal1 = 0; $bal2 = 0; $ppayment = 0; $fpayment = 0; $all_bal = 0; $payment = get_total_payment($row['type'], $row['trans_no']); while ($pr = db_fetch($or)) { $partial_payment += $pr['amt']; $ctr++; if ($num2 > 1) { $bal = $net_sales - $partial_payment; if (number_format($payment, 2) == number_format($net_sales, 2)) { if ($status == 1 || $status == "" || $status == 0) { $fpayment += $pr['amt']; } } else { if ($status == 2 || $status == "" || $status == 0) { $ppayment += $pr['amt']; $all_bal += $bal; } } } else { $bal = $net_sales - $partial_payment; if ($bal == 0) { $bal = number_format($net_sales, 2) - number_format($partial_payment, 2); if ($status == 1 || $status == "" || $status == 0) { $fpayment += $partial_payment; $bal1 += $bal; } } else { $bal = $net_sales - $pr['amt']; if ($status == 2 || $status == "" || $status == 0) { $ppayment += $partial_payment; $bal2 += $bal; } } } } $net_partial += $ppayment; $net_full_payment += $fpayment; } } $Percentage1 = $TotalReturn / $InvoiceTotal * 100; $NetSales = $InvoiceTotal - $TotalReturn; $Percentage2 = $net_full_payment / $NetSales * 100; $Percentage3 = $net_partial / $NetSales * 100; $ReceivablesTotal = $NetSales - $fpayment - $ppayment; $Percentage4 = $ReceivablesTotal / $NetSales * 100; $rep->TextCol(0, 1, $myrow['imc_code']); $rep->AmountCol(1, 2, $InvoiceTotal, 2); $rep->AmountCol(2, 3, $TotalReturn, 2); $rep->AmountCol(3, 4, $TotalDiscount, 2); $rep->AmountCol(4, 5, $Percentage1, 2); $rep->AmountCol(5, 6, $NetSales, 2); $rep->AmountCol(6, 7, $net_full_payment, 2); $rep->AmountCol(7, 8, $Percentage2, 2); $rep->AmountCol(8, 9, $net_partial, 2); $rep->AmountCol(9, 10, $Percentage3, 2); if ($status != 1) { $rep->AmountCol(10, 11, $ReceivablesTotal, 2); } $rep->AmountCol(11, 12, $Percentage4, 2); $rep->NewLine(); $TotalInvoice += $InvoiceTotal; $TotalReturn_2 += $TotalReturn; $TotalSales += $NetSales; $TotalFullAlloc += $net_full_payment; $TotalPartialAlloc += $net_partial; if ($status != 1) { $TotalReceivables += $ReceivablesTotal; } } $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 1, "TOTAL"); $rep->AmountCol(1, 2, $TotalInvoice, 2); $rep->AmountCol(2, 3, $TotalReturn_2, 2); $rep->AmountCol(5, 6, $TotalSales, 2); $rep->AmountCol(6, 7, $TotalFullAlloc, 2); $rep->AmountCol(8, 9, $TotalPartialAlloc, 2); $rep->AmountCol(10, 11, $TotalReceivables, 2); $rep->NewLine(); $rep->NewLine(); $rep->End(); }
?> : <?php echo $file['file_size']; ?> </li> <li><?php echo __('file_views'); ?> : <?php echo get_discount($file[userid], $file['file_views']); ?> <?php echo __('file_downs'); ?> : <?php echo get_discount($file[userid], $file['file_downs']); ?> </li> <li><input type="submit" class="btn" value="<?php echo __('btn_submit'); ?> " /></li> </form> </div> </div> <script type="text/javascript"> function sel_folder_id(){ getId('folder_name').value = getId('folder_ids').options[getId('folder_ids').selectedIndex].text; } </script> <?php
//echo $get_discount; $tnt_discount = $get_discount / 100 * $get_menu_price['menu_price']; $tnt_grand_price = $get_menu_price['menu_price'] - $tnt_discount; $data = "'',\n\t\t\t\t\t'{$table_id}',\n\t\t\t\t\t'" . $_SESSION['user_id'] . "',\n\t\t\t\t\t'{$member_id}', \n\t\t\t\t\t'{$menu_id}',\n\t\t\t\t\t'" . $get_menu_price['menu_price'] . "',\n\t\t\t\t\t'{$tnt_discount}',\n\t\t\t\t\t'{$tnt_grand_price}',\n\t\t\t\t\t'1',\n\t\t\t\t\t'{$tnt_grand_price}'\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t"; create_config("transaction_new_tmp", $data); } header("Location: transaction_new.php?page=list&table_id={$table_id}&member_id={$member_id}"); break; case 'add_menu_edit': $member_id = get_isset($_GET['member_id']); $menu_id = get_isset($_GET['menu_id']); $table_id = get_isset($_GET['table_id']); $get_menu_price = get_menu_price($menu_id); $check_menu = check_menu($table_id, $menu_id); if ($check_menu == 0) { $get_discount = get_discount($member_id, $menu_id); //echo $get_discount; $tnt_discount = $get_discount / 100 * $get_menu_price['menu_price']; $tnt_grand_price = $get_menu_price['menu_price'] - $tnt_discount; $get_transaction_id = get_transaction_id($table_id); $data = "'',\n\t\t\t\t\t'{$get_transaction_id}',\n\t\t\t\t\t'{$menu_id}', \n\t\t\t\t\t'" . $get_menu_price['menu_original_price'] . "',\n\t\t\t\t\t'" . $get_menu_price['menu_margin_price'] . "',\n\t\t\t\t\t'" . $get_menu_price['menu_price'] . "',\n\t\t\t\t\t'" . $tnt_discount . "',\n\t\t\t\t\t'{$tnt_grand_price}',\n\t\t\t\t\t'1',\n\t\t\t\t\t'{$tnt_grand_price}'\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t"; create_config("transaction_tmp_details", $data); } header("Location: transaction_new.php?page=list_edit&table_id={$table_id}"); break; case 'save': extract($_POST); $i_date = get_isset($_GET['date']); $i_date = format_back_date($i_date); $i_jam = date("h:i:s"); $table_id = get_isset($_GET['table_id']);
$user[readonly] = ''; } $q = $db->query("select u.username,u.userid from {$tpf}buddys b,{$tpf}users u where b.touserid=u.userid and b.userid='{$user['userid']}'"); $buddy_list = array(); while ($rs = $db->fetch_array($q)) { $rs['a_user_edit'] = urr(ADMINCP, "item=users&menu=user&action=user_edit&uid={$rs['userid']}"); $buddy_list[] = $rs; } $db->free($q); unset($rs); } $curr_credit_rate = $myinfo[credit_rate] ? exp_credit_rate($myinfo[credit_rate]) : ($settings[how_downs_credit] && $settings[how_money_credit] ? $settings[how_downs_credit] . '==' . $settings[how_money_credit] : __('not_set')); $curr_downline_rate = $myinfo[downline_income] ? $myinfo[downline_income] . '%' : ($settings[downline_income] ? $settings[downline_income] . '%' : __('not_set')); $curr_downline_rate2 = $myinfo[downline_income2] ? $myinfo[downline_income2] . '%' : ($settings[downline_income2] ? $settings[downline_income2] . '%' : __('not_set')); $curr_discount_rate = $myinfo[discount_rate] ? $myinfo[discount_rate] . '%' : ($settings[discount_rate] ? $settings[discount_rate] . '%' : __('not_set')); $add_discount = get_discount($uid, $myinfo[credit], 'desc'); if ($auth[pd_a]) { $s = get_seo('space', $uid); } require_once template_echo($item, $admin_tpl_dir, '', 1); } break; case 'adminlogout': $db->query_unbuffered("update {$tpf}adminsession set hashcode='' where userid='{$pd_uid}'"); $sysmsg[] = __('system_logout_success'); redirect('javascript:self.parent.close();', $sysmsg); break; case 'orders': admin_no_power($task, 7, $pd_uid); if ($task == 'update') { form_auth(gpc('formhash', 'P', ''), formhash());
if(count($bd)) { if($replace['birthdays']) $replace['birthdays'] .= "<br>"; $bd_str = count($bd) > 1 ? join("<br>", $bd) : $bd[0]; $replace['birthdays'] .= $bd_str; } }*/ $replace['recomm'] = nl2br(htmlspecialchars($replace['recomm'], ENT_COMPAT, 'cp1251')); $replace['recomm_provider'] = nl2br(htmlspecialchars($replace['recomm_provider'], ENT_COMPAT, 'cp1251')); $replace['recomm_commission'] = nl2br(htmlspecialchars($replace['recomm_commission'], ENT_COMPAT, 'cp1251')); $replace['gdiscount'] = ''; if ($replace['card_id']) { $sql = mysql_query("SELECT count(*) FROM " . TABLE_ORDER . " \n\t\t\tWHERE card_id='{$replace['card_id']}' AND card_vip='{$replace['card_vip']}' AND annul='' AND !basket AND order_id<={$order_id}") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $active_count = (int) @$arr[0]; $replace['gdiscount'] = get_discount($active_count, $replace['card_vip']); } $replace['onechecked'] = $replace['one'] ? 'checked' : ''; if ($replace['discount']) { $replace['discountrub'] = 'selected'; $replace['discountpr'] = ''; } else { $replace['discountrub'] = ''; $replace['discountpr'] = 'selected'; $replace['discount'] = $replace['skidka'] ? $replace['skidka'] : $replace['gdiscount']; } $replace['all_link'] = $all_link; $replace['doplata'] = $replace['prepayment'] && $replace['inall'] > $replace['prepayment'] ? $replace['inall'] - $replace['prepayment'] : 0; if ($replace['fio']) { $replace['fio_list'] = preg_split("/[\r\n,+]+/", $replace['fio']); $replace['fio_count'] = count($replace['fio_list']);
?> </td> </tr> <tr> <td style="border-bottom:none;"> </td> <td style="border-bottom:none;"><?php echo __('today_credit'); ?> :<b class="f14"><?php echo get_discount($pd_uid, $today_credit); ?> </b> , <?php echo __('yesterday_credit'); ?> :<b class="f14"><?php echo get_discount($pd_uid, $yesterday_credit); ?> </b> </td> </tr> </tbody> </table></td> <td valign="top" style="border-left:1px #CCCCCC solid;"> <table width="100%" cellpadding="4" cellspacing="0" border="0" class="td_line"> <tr> <td colspan="2" class="f14"><img src="images/ann_icon.gif" align="absmiddle" border="0" />网站公告</td> </tr> <?php show_announces(); ?> </table> </td>
function print_summary() { global $path_to_root; $sman = $_POST['PARAM_0']; $from = $_POST['PARAM_1']; $to = $_POST['PARAM_2']; $stat = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 520, 550); $headers = array(_('IMC'), _('Gross'), _('Returns'), _('% To Sales'), _('Net Sales'), _('Full Payment'), _('% To Sales'), _('Partial Payments'), _('% To Sales'), _('Accounts Receivables'), _('% To Sales')); $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $aligns2 = $aligns; $summary = 1; $rep = new FrontReport(_('Sales Status'), "Sales Status", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $cols2 = $cols; $rep->Font(); $rep->Info(null, $cols, $headers, $aligns); $rep->NewPage(); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; $slist = array(); if ($sman == "") { $row = get_all_salesman(); while ($r = db_fetch($row)) { array_push($slist, $r['salesman_code']); } foreach ($slist as $slists) { $res = getTransactions($from, $to, $slists, $stat); } } else { $res = getTransactions($from, $to, $sman, $stat); } $prev = ''; while ($myrow = db_fetch($res)) { $current = $myrow['salesman_code']; if ($myrow['salesman_code'] != "") { if ($current == $prev) { } else { } $prev = $current; } $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $res2 = get_return_details($myrow['order_']); $returns = 0; $rtn_dt = 0; $credit_num = ""; $cm_date = ""; $num = db_num_rows($res2); $var = array(); while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; if ($num > 1) { $credit_num .= $myrow2['customized_no'] . "/"; $cm_date = $myrow2['tran_date'] . "/"; } else { $credit_num .= $myrow2['customized_no']; $cm_date = $myrow2['tran_date']; } $var = array($myrow2['trans_no']); } foreach ($var as $vars) { $res2 = get_return_discount($branch_data['sales_discount_account'], ST_CUSTCREDIT, $vars); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; $invoicetot = $myrow['ov_amount'] + $dt; $invoice_discount = $dt / $invoicetot * 100; $sales_discount = ($invoicetot - $total_returns) * ($invoice_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100); $tot_invoice = $invoicetot - $invoicetot * ($invoice_discount / 100); if ($myrow['IsVoid'] == '') { $myrow4 = db_fetch(get_commission_details($myrow['type'], $myrow['trans_no'])); $comm = ($invoicetot - $total_returns) * ($myrow4['commission'] / 100); $partial_payment = 0; $zero; $or = get_pr_details($myrow['type'], $myrow['trans_no']); $ref = ''; $num2 = db_num_rows($or); $date_alloc = ''; $ctr = 0; $bal = 0; $bal1 = 0; $bal2 = 0; $ppayment = 0; $fpayment = 0; $all_bal = 0; $payment = get_total_payment($myrow['type'], $myrow['trans_no']); while ($pr = db_fetch($or)) { $partial_payment += $pr['amt']; $date_alloc = $pr['prDate'] . " "; $pr_number = $pr['customized_no'] . " "; $ref = $pr['reference']; $net_remittance = $net_sales - $partial_payment; $ctr++; if ($num2 > 1) { $bal = $net_sales - $partial_payment; if (number_format($payment, 2) == number_format($net_sales, 2)) { $fpayment += $pr['amt']; } else { $ppayment += $pr['amt']; $all_bal += $bal; } } else { $bal = $net_sales - $partial_payment; if ($bal == 0) { $bal = number_format($net_sales, 2) - number_format($partial_payment, 2); $fpayment += $partial_payment; $bal1 += $bal; } else { $bal = $net_sales - $pr['amt']; $ppayment += $partial_payment; $bal2 += $bal; } } if ($num2 > 1) { $rep->NewLine(); } } $net_invoice += $invoicetot; $net_discount += $sales_discount; $net_returns += $total_returns; $sale_amount += $net_sales; $net_partial += $ppayment; $net_rem += $net_remittance; $net_bal += $bal; $net_balance = $net_rem + $net_bal; $net_comm += $comm; $net_tax += $myrow4['with_tax']; $net_net_comm += $myrow4['net_commission']; $net_full_payment += $fpayment; } } $Percentage1 = $net_returns / $net_invoice * 100; $NetSales = $net_invoice - $net_returns; $Percentage2 = $net_full_payment / $NetSales * 100; $Percentage3 = $net_partial / $NetSales * 100; $ReceivablesTotal = $NetSales - $net_full_payment - $net_partial; $Percentage4 = $ReceivablesTotal / $NetSales * 100; $rep->Font('bold'); $rep->NewLine(); $rep->TextCol(0, 1, $salesman); $rep->AmountCol(1, 2, $net_invoice, 2); $rep->AmountCol(2, 3, $net_returns, 2); $rep->AmountCol(3, 4, $Percentage1, 2); $rep->AmountCol(4, 5, $NetSales, 2); $rep->AmountCol(5, 6, $net_full_payment, 2); $rep->AmountCol(6, 7, $Percentage2, 2); $rep->AmountCol(7, 8, $net_partial, 2); $rep->AmountCol(8, 9, $Percentage3, 2); $rep->AmountCol(9, 10, $ReceivablesTotal, 2); $rep->AmountCol(10, 11, $Percentage4, 2); $rep->NewLine(); $rep->End(); }
$res = $db->query($sql); $arr = array(); $ids = $_REQUEST['goods']; $attr_name = array(); $type_id = 0; while ($row = $db->fetchRow($res)) { $goods_id = $row['goods_id']; $type_id = $row['goods_type']; $arr[$goods_id]['goods_id'] = $goods_id; $arr[$goods_id]['url'] = build_uri('goods', array('gid' => $goods_id), $row['goods_name']); $arr[$goods_id]['goods_name'] = $row['goods_name']; $arr[$goods_id]['comments_number'] = $row['comments_number']; $arr[$goods_id]['sales_volume'] = $row['sales_volume']; /* 折扣节省计算 by ecmoban start */ if ($row['market_price'] > 0) { $discount_arr = get_discount($row['goods_id']); //函数get_discount参数goods_id } $arr[$goods_id]['zhekou'] = $discount_arr['discount']; //zhekou $arr[$goods_id]['jiesheng'] = $discount_arr['jiesheng']; //jiesheng /* 折扣节省计算 by ecmoban end */ $arr[$goods_id]['shop_price'] = price_format($row['shop_price']); $arr[$goods_id]['rank_price'] = price_format($row['rank_price']); $arr[$goods_id]['goods_weight'] = intval($row['goods_weight']) > 0 ? ceil($row['goods_weight']) . $_LANG['kilogram'] : ceil($row['goods_weight'] * 1000) . $_LANG['gram']; $arr[$goods_id]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$goods_id]['goods_brief'] = $row['goods_brief']; $arr[$goods_id]['brand_name'] = $row['brand_name']; $arr[$goods_id]['properties'][$row['attr_id']]['name'] = $row['attr_name']; if (!empty($arr[$goods_id]['properties'][$row['attr_id']]['value'])) {
function get_child_tree_goods($tree_id = 0, $limit = 6) { $three_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '{$tree_id}' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) { $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '{$tree_id}' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($child_sql); foreach ($res as $row) { if ($row['is_show']) { $three_arr[$row['cat_id']]['id'] = $row['cat_id']; } $three_arr[$row['cat_id']]['name'] = $row['cat_name']; $three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); $children = get_children($row['cat_id']); $sql = 'SELECT g.goods_id,g.cat_id, g.goods_name, g.comments_number,g.sales_volume,g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ORDER BY g.sort_order, g.goods_id DESC LIMIT ' . $limit; $goods_res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($goods_res as $idx => $row) { if ($row['promote_price'] > 0) { $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ''; } else { $goods[$idx]['promote_price'] = ''; } $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; /* 折扣节省计算 by ecmoban start */ if ($row['market_price'] > 0) { $discount_arr = get_discount($row['goods_id']); //函数get_discount参数goods_id } $goods[$idx]['zhekou'] = $discount_arr['discount']; //zhekou $goods[$idx]['jiesheng'] = $discount_arr['jiesheng']; //jiesheng /* 折扣节省计算 by ecmoban end */ $goods[$idx]['comments_number'] = $row['comments_number']; $goods[$idx]['sales_volume'] = $row['sales_volume']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['market_price'] = $row['market_price']; $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } $three_arr[$row['cat_id']]['goods'] = $goods; if (isset($row['cat_id']) != NULL) { $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id'], $limit); } } } return $three_arr; }
function print_inventory_sales() { global $path_to_root; $from = $_POST['PARAM_0']; $destination = $_POST['PARAM_1']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $dec = user_price_dec(); if ($category == ALL_NUMERIC) { $category = 0; } if ($category == 0) { $cat = _('All'); } else { $cat = get_category_name($category); } $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200); $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Amount'), _('Partial'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission')); $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _('')); $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => '')); $rep = new FrontReport(_('Series Report'), "SeriesReport", user_pagesize(), 8, 'L'); $rep->Font(); $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns); $rep->NewPage(); $total = $grandtotal = 0.0; $total1 = $grandtotal1 = 0.0; $total2 = $grandtotal2 = 0.0; $catt = ''; $res = getTransactions($imc, $from); while ($myrow = db_fetch($res)) { $company_data = get_company_prefs(); $branch = get_branch($myrow["branch_code"]); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $salesman = get_imc_code($myrow['branch_code']); $res2 = get_return_details($myrow['order_']); $returns = 0; $rtn_dt = 0; $credit_num = ""; $cm_date = ""; $num = db_num_rows($res2); $var = array(); while ($myrow2 = db_fetch($res2)) { $returns += $myrow2['ov_amount']; if ($num > 1) { $credit_num .= $myrow2['customized_no'] . "/"; $cm_date = $myrow2['tran_date'] . "/"; } else { $credit_num .= $myrow2['customized_no']; $cm_date = $myrow2['tran_date']; } $var = array($myrow2['trans_no']); //$res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']); // while ($myrow3 = db_fetch($res2)){ // $rtn_dt += abs($myrow3['amount']); // } } foreach ($var as $vars) { $res2 = get_return_discount($branch_data['sales_discount_account'], ST_CUSTCREDIT, $vars); while ($myrow3 = db_fetch($res2)) { $rtn_dt += abs($myrow3['amount']); } } $total_returns = $returns + $rtn_dt; $return_discount = $rtn_dt / $total_returns * 100; //$discount = $myrow['discount']; $invoicetot = $myrow['ov_amount'] + $dt; $invoice_discount = $dt / $invoicetot * 100; $sales_discount = ($invoicetot - $total_returns) * ($invoice_discount / 100); $net_sales = $invoicetot - $total_returns - $sales_discount; $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100); $tot_invoice = $invoicetot - $invoicetot * ($invoice_discount / 100); $sample = $invoicetot - $total_returns; $rep->TextCol(0, 1, $myrow['tranDate']); $rep->TextCol(1, 2, $myrow['br_name']); $rep->TextCol(2, 3, $salesman); $rep->TextCol(3, 4, $myrow['customized_no']); if ($myrow['IsVoid'] == '') { $rep->AmountCol(4, 5, $invoicetot, 2); $rep->TextCol(5, 6, $cm_date); $rep->TextCol(6, 7, $credit_num); if ($total_returns != 0) { $rep->AmountCol(7, 8, $total_returns, 2); } if ($invoice_discount < 0) { $rep->TextCol(8, 9, "CLIENT SALES/SALES DISCOUNT NOT DEFINED."); } else { $rep->TextCol(8, 9, $invoice_discount . "%"); } if ($sales_discount < 0) { $rep->TextCol(9, 10, "ERROR."); } else { if ($sales_discount != 0) { $rep->AmountCol(9, 10, $sales_discount, 2); } } if ($net_sales != 0) { $rep->AmountCol(10, 11, $net_sales, 2); } $partial_payment = 0; $or = get_pr_details($myrow['type'], $myrow['trans_no']); $ref = ''; $num2 = db_num_rows($or); $date_alloc = ''; while ($pr = db_fetch($or)) { $partial_payment += $pr['amt']; $date_alloc = $pr['prDate'] . " "; $pr_number = $pr['customized_no'] . " "; if ($num2 > 1) { $ref .= $pr['reference'] . "/"; } else { $ref = $pr['reference']; } } $net_remittance = $net_sales - $partial_payment; $rep->TextCol(11, 12, $date_alloc); $rep->TextCol(12, 13, $ref); $rep->TextCol(13, 14, $date_alloc); $rep->TextCol(14, 15, _("")); if ($partial_payment == $tot_invoice) { $rep->AmountCol(15, 16, $partial_payment, 2); } if ($partial_payment != 0) { if ($partial_payment < $tot_invoice) { $bal = $tot_invoice - $partial_payment; $rep->AmountCol(16, 17, $partial_payment, 2); $rep->AmountCol(17, 18, $bal, 2); } } //$rep->AmountCol(15,16, $partial_payment, 2); //$rep->AmountCol(17,18, $net_remittance, 2); $myrow4 = db_fetch(get_commission_details($myrow['type'], $myrow['trans_no'])); $comm = ($invoicetot - $total_returns) * ($myrow4['commission'] / 100); $rep->TextCol(18, 19, $myrow4['tranDate']); if ($myrow4['commission'] != 0) { $rep->TextCol(19, 20, $myrow4['commission'] . "%"); } if ($comm != 0) { $rep->AmountCol(20, 21, $comm, 2); } if ($myrow4['with_tax'] != 0) { $rep->AmountCol(21, 22, $myrow4['with_tax'], 2); } if ($myrow4['net_commission'] != 0) { $rep->AmountCol(22, 23, $myrow4['net_commission'], 2); } $net_invoice += $invoicetot; $net_discount += $sales_discount; $net_returns += $total_returns; $sale_amount += $net_sales; $net_partial += $partial_payment; $net_rem += $net_remittance; $net_bal += $bal; $net_balance = $net_rem + $net_bal; $net_comm += $comm; $net_tax += $myrow4['with_tax']; $net_net_comm += $myrow4['net_commission']; } else { $rep->TextCol(4, 5, "Voided"); } $rep->NewLine(); } $rep->Font('bold'); $rep->NewLine(); $rep->TextCol(1, 2, "TOTAL"); $rep->AmountCol(4, 5, $net_invoice, 2); $rep->AmountCol(7, 8, $net_returns, 2); $rep->AmountCol(9, 10, $net_discount, 2); $rep->AmountCol(10, 11, $sale_amount, 2); $rep->AmountCol(16, 17, $net_partial, 2); //$rep->AmountCol(17,18, $net_balance, 2); $rep->AmountCol(20, 21, $net_comm, 2); $rep->AmountCol(21, 22, $net_tax, 2); $rep->AmountCol(22, 23, $net_net_comm, 2); $rep->NewLine(); $rep->End(); }
function get_totals($cartid) { $cart = $this->Order_model->get_fullcart($this->session->userdata('cart_id')); $totals = array('itemtotal' => 0, 'shipping' => 0, 'service' => 0, 'surcharge' => 0, 'tax' => 0, 'discount' => 0, 'coupon' => 0, 'coupon_code' => '', 'companyless' => 0, 'grandtotal' => 0); $cartdiscount = 0; $cartcoupon = 0; $cartdiscounttype = 'percentage'; $cartcoupontype = 'percentage'; foreach ($cart as $item) { $totals['itemtotal'] += $item->product_price; $ptotal = $item->product_price; foreach ($item->addons as $addon) { $totals['itemtotal'] += $addon->addon_price * $addon->addon_quantity; } } if ($this->session->userdata('coupon')) { if ($coupon = get_coupon_discount($this->session->userdata('coupon'), $totals['itemtotal'])) { $totals['coupon_code'] = $coupon->discount_name; if ($coupon->discount_amount > 0) { $cartcoupon = $coupon->discount_amount; $cartcoupontype = 'amount'; } else { $cartcoupon = $coupon->discount_percentage; $cartcoupontype = 'percentage'; } } } if ($cartcoupon <= 0) { if ($discount = get_discount($totals['itemtotal'])) { if ($discount->discount_amount > 0) { $cartdiscount = $discount->discount_amount; $cartdiscounttype = 'amount'; } else { $cartdiscount = $discount->discount_percentage; $cartdiscounttype = 'percentage'; } } } $addition = $this->Order_model->get_add_charges($item->orderitem_id); $totals['shipping'] += $addition['shipping']; $totals['service'] += $addition['service']; $totals['surcharge'] += $addition['surcharge']; if ($cartcoupon > 0) { if ($cartcoupontype == 'percentage') { $totals['coupon'] += $cartcoupon * $ptotal / 100; $ptotal -= $cartcoupon * $ptotal / 100; } else { $part = $cartcoupon / $itemscount; $totals['coupon'] += $part; $ptotal -= $part; } } else { if ($cartdiscounttype == 'percentage') { $totals['discount'] += $cartdiscount * $ptotal / 100; $ptotal -= $cartdiscount * $ptotal / 100; } else { $part = $cartdiscount / $itemscount; $totals['discount'] += $part; $ptotal -= $part; } } $ptotal += $addition['shipping']; $ptotal += $addition['service']; $ptotal += $addition['surcharge']; $totals['tax'] += $addition['tax'] * $ptotal / 100; $affid = $this->session->userdata('referer'); if ($affid != '') { $totals['grandtotal'] = round($totals['itemtotal'], 2) + round($totals['shipping'], 2) + round($totals['service'], 2) + round($totals['surcharge'], 2) + round($totals['tax'], 2) - round($totals['discount'], 2) - round($totals['coupon'], 2); } else { $totals['grandtotal'] = round($totals['itemtotal'], 2) + round($totals['shipping'], 2) + round($totals['service'], 2) + round($totals['surcharge'], 2) + round($totals['tax'], 2) - round($totals['discount'], 2) - round($totals['coupon'], 2); } return $totals; }