示例#1
0
文件: func_admin.php 项目: nikuha/rs
function attention_list($limit = 0)
{
    global $settings, $attention_win;
    global $admin_config;
    $where = "!z.basket AND z.status!=0 AND !z.noatten" . get_order_cond($admin_config, 'attention');
    $where_tr = array();
    $where_tr[] = "(z.inall+z.debt < z.provider_sum AND z.provider_sum>0 AND z.inall>0)";
    $where_tr[] = "(z.inall+z.debt>z.provider_sum AND z.provider_sum>0 AND (z.inall+z.debt-z.provider_sum)>z.inall*" . ATTENTION_PERCENT . ")";
    $where_tr[] = "z.provider_id=0";
    //$where_tr[] = "((cl.birthday_city='' OR cl.birthday_city IS NULL) AND !cl.city_id AND !z.porder_id)";
    $where_tr[] = "(!cl.city_id AND !z.porder_id)";
    $where_tr1 = " (" . implode(' OR ', $where_tr) . " ) AND z.date > CURDATE() - INTERVAL " . (int) $settings['attention_days'] . " DAY ";
    $where_tr = array();
    $where_tr[] = "(!z.paid AND !z.prepaid)";
    $where_tr[] = "( (!z.paid AND z.prepaid AND z.inall>z.prepayment) AND !z.nameste)";
    $where_tr[] = " (!z.paytoprovider AND !z.paid_provider)";
    $where_tr2 = " (" . implode(' OR ', $where_tr) . " ) AND z.date_from < CURDATE() + INTERVAL " . (int) $settings['nopay_days'] . " DAY \n\t\t  AND z.date_from > CURDATE() - INTERVAL 3 MONTH ";
    $where .= " AND ( ({$where_tr1}) OR ({$where_tr2}) )";
    $provider_sum = get_sql_provider_sum();
    if (!$limit) {
        $limit = ATTENTION_LIMIT;
    }
    $sql = mysql_query("\n\t\tSELECT \n\t\t\tz.order_id, z.paid, z.prepaid, z.user_id,\n\t\t\tz.provider_id, z.inall, z.provider_sum, z.debt,\n\t\t\tob.name as object_name, u.name as user_name, cl.city_id,\n\t\t\t({$where_tr2}) as nopaid\n\t\tFROM \n\t\t\t" . TABLE_ORDER . " z \n\t\t\tLEFT JOIN " . TABLE_OFFICE . " r on (r.office_id=z.office_id) \n\t\t\tLEFT JOIN " . TABLE_OBJECT . " ob on (ob.object_id=z.object_id) \n\t\t\tLEFT JOIN " . TABLE_USER . " u on (u.user_id=z.user_id) \n\t\t\tLEFT JOIN " . TABLE_CLIENT . " cl on (cl.client_id=SUBSTRING_INDEX( z.clients, ',', 1 )) \n\t\tWHERE\n\t\t\t{$where}\n\t\tGROUP BY\n\t\t\tz.order_id\n\t\tORDER BY \n\t\t\tz.date desc, z.porder_id, z.order_id desc\n\t\tLIMIT " . $limit) or Error(1, __FILE__, __LINE__);
    $list = array();
    while ($info = @mysql_fetch_array($sql)) {
        $info['object_name'] = htmlspecialchars($info['object_name'], ENT_COMPAT, 'cp1251');
        $info['problem'] = '';
        if ($info['inall'] + $info['debt'] < $info['provider_sum'] && $info['inall'] > 0) {
            $info['problem'] = 'отриц. баланс';
        } elseif ($info['inall'] + $info['debt'] > $info['provider_sum'] && $info['provider_sum'] > 0 && $info['inall'] + $info['debt'] - $info['provider_sum'] > $info['inall'] * ATTENTION_PERCENT) {
            $pr = (int) (($info['inall'] + $info['debt'] - $info['provider_sum']) * 100 / $info['inall']);
            $info['problem'] = 'сверхпр.' . " {$pr}% ";
        } elseif ($info['provider_id'] == 0) {
            $info['problem'] = 'без постав.';
        } elseif ($info['nopaid']) {
            $info['problem'] = 'неоплачена';
        } elseif (!$info['city_id']) {
            $info['problem'] = 'не указан город';
        }
        if ($admin_config['attention_status']) {
            $info['edit'] = "?p=search&noatten={$info['order_id']}";
        }
        if ($info['user_id'] == $_SESSION['admin_id']) {
            $attention_win[$info['order_id']] = "<a href=\"?p=order&order_id={$info['order_id']}\">{$info['order_id']}</a>  {$info['problem']}";
        }
        $list[] = $info;
    }
    return $list;
}
示例#2
0
文件: search.php 项目: nikuha/rs
 $replace['sort'] = $sort;
 $d_field = $datesel == 1 ? 'date_from' : 'date';
 if (!$mindate) {
     $arr = $maxdate ? $maxdate : date("Y-m-d");
     list($y, $m, $d) = split("-", $arr);
     $mindate = date("Y-m-d", mktime(0, 0, 0, $m - 6, $d, $y));
 }
 if ($mindate) {
     $where .= " AND z.{$d_field}>='{$mindate}'";
 }
 if ($maxdate) {
     $where .= " AND z.{$d_field}<='{$maxdate}'";
 }
 $replace['mindate'] = $mindate ? sql_to_text_date($mindate, 0, 1) : '';
 $replace['maxdate'] = $maxdate ? sql_to_text_date($maxdate, 0, 1) : '';
 $sql_provider_sum = get_sql_provider_sum();
 $sql_balance = get_sql_balance();
 $sql = mysql_query("\n\t\tSELECT \n\t\t\tcount(distinct order_id) as allcount\n\t\tFROM \n\t\t\t" . TABLE_ORDER . " z \n\t\t\tLEFT JOIN " . TABLE_OFFICE . " r on (r.office_id=z.office_id) \n\t\t\tLEFT JOIN " . TABLE_OBJECT . " ob on (ob.object_id=z.object_id) \n\t\t\tLEFT JOIN " . TABLE_CITY . " ct ON (ob.city_id=ct.city_id)\n\t\t\tLEFT JOIN " . TABLE_AGENCY . " ag ON (ag.agency_id=z.agency_id)\n\t\t\tLEFT JOIN " . TABLE_CORPORATE . " cr ON (cr.corporate_id=z.corporate_id)\n\t\t\tLEFT JOIN " . TABLE_USER . " u on (u.user_id=z.user_id) \n\t\t\tLEFT JOIN " . TABLE_CLIENT . " cl on (cl.client_id=SUBSTRING_INDEX( z.clients, ',', 1 )) \n\t\tWHERE\n\t\t\t1 {$where}") or Error(1, __FILE__, __LINE__);
 $arr = mysql_fetch_array($sql);
 $replace['all'] = $all = $arr['allcount'];
 list($limit, $replace['pages']) = pages($all, ADMIN_URL . "?p={$part}&all=1&");
 $replace['current_page'] = $current_page;
 $sql = mysql_query("\n\t\tSELECT \n\t\t\tz.order_id, z.date, z.status as orderstatus, z.date_from, z.note, {$sql_balance} as balance,\n\t\t\tz.client,\n\t\t\tz.annul, z.tphone, z.fio, z.tphone, z.card_id, z.card_vip,  \n\t\t\tcl.phone as client_phone, cl.name as client_name, cl.birthday_city,\n\t\t\tr.region,\n\t\t\tob.name as object_name, \n\t\t\tct.city_id, ct.name as city_name, c.name as country_name, u.name as user_name,\n\t\t\tag.name as agency_name, cr.name as corporate_name, z.agency_id, cr.corporate_id\n\t\tFROM \n\t\t\t" . TABLE_ORDER . " z \n\t\t\tLEFT JOIN " . TABLE_OFFICE . " r on (r.office_id=z.office_id) \n\t\t\tLEFT JOIN " . TABLE_OBJECT . " ob on (ob.object_id=z.object_id) \n\t\t\tLEFT JOIN " . TABLE_CITY . " ct ON (ob.city_id=ct.city_id)\n\t\t\tLEFT JOIN " . TABLE_COUNTRY . " c ON (ct.country_id=c.country_id)\n\t\t\tLEFT JOIN " . TABLE_AGENCY . " ag ON (ag.agency_id=z.agency_id)\n\t\t\tLEFT JOIN " . TABLE_CORPORATE . " cr ON (cr.corporate_id=z.corporate_id)\n\t\t\tLEFT JOIN " . TABLE_USER . " u on (u.user_id=z.user_id) \n\t\t\tLEFT JOIN " . TABLE_CLIENT . " cl on (cl.client_id=SUBSTRING_INDEX( z.clients, ',', 1 )) \n\t\tWHERE\n\t\t\t1 {$where}\n\t\tGROUP BY\n\t\t\tz.order_id\n\t\tORDER BY \n\t\t\t{$ord}\n\t\tLIMIT {$limit}") or Error(1, __FILE__, __LINE__);
 $list = array();
 $i = ($current_page - 1) * $_SESSION['on_page'];
 $j = 0;
 while ($info = @mysql_fetch_array($sql)) {
     $i++;
     $j++;
     $info['i'] = $i;
     $info['j'] = $j;