<?php
class remarks
{
  public function cids($pid = 0, $status = 0)
  {
    if ($status > 0)
      $where = "status=$status";
    else
      $where = "1=1";
    $order = $_POST['order'] != '' ? $_POST['order'] : 'asc';
    $data = db()->select_all("product_type", "id, title, pid", $where . ' order by sort ' . $order . ', id desc');
    $res = reSort($data, $pid, 0, TRUE);
    $arr = [];
    foreach ($res as $key => $value) {
      $arr[$value['id']] = $value['title'];
    }
    return $arr;
  }
  function listwhere($where)
  {
    if ($_POST['name']) {
      $where .= " and `name` like '%" . $_POST['name'] . "%'";
    }
    if ($_POST['tel']) {
      $where .= ' and tel=' . $_POST['tel'];
    }
    if ($_POST['goods']) {
      $where .= " and `goods` like '%" . $_POST['goods'] . "%'";
    }
    if ($_POST['sdate'] || $_POST['edate']) {
      $sday = $_POST['sdate'] ? strtotime($_POST['sdate'] . ' 00:00:00') : 0;
      $eday = $_POST['edate'] ? strtotime($_POST['edate'] . ' 23:59:59') : TIME;
      $where .= ' and addtime>"' . $sday . '" and addtime<"' . $eday . ' "';
    }
    return $where;
  }

  function list($list)
  {
    foreach ($list as $key => $value) {
      $list[$key]['goods'] = $value['goods'] ? $value['goods'] : '无';
      $list[$key]['remarks'] = $value['remarks'] ? $value['remarks'] : '无';
      $list[$key]['money'] = $value['money'] ? $value['money'] : '无';
    }
    return $list;
  }
}
