Beispiel #1
0
 public function save()
 {
     $act = str_enhtml($this->input->get('act', TRUE));
     $id = intval($this->input->post('id', TRUE));
     $data['name'] = str_enhtml($this->input->post('name', TRUE));
     if ($act == 'add') {
         $this->purview_model->checkpurview(78);
         strlen($data['name']) < 1 && die('{"status":-1,"msg":"名称不能为空"}');
         $this->mysql_model->db_count(UNIT, '(name="' . $data['name'] . '")') > 0 && die('{"status":-1,"msg":"单位名称重复"}');
         $data['id'] = $this->mysql_model->db_inst(UNIT, $data);
         if ($data['id']) {
             $this->data_model->logs('新增单位:' . $data['name']);
             $this->cache_model->delsome(UNIT);
             die('{"status":200,"msg":"success","data":' . json_encode($data) . '}');
         } else {
             die('{"status":-1,"msg":"添加失败"}');
         }
     } elseif ($act == 'update') {
         $this->purview_model->checkpurview(79);
         strlen($data['name']) < 1 && die('{"status":-1,"msg":"名称不能为空"}');
         $this->mysql_model->db_count(UNIT, '(id<>' . $id . ') and (name="' . $data['name'] . '")') > 0 && die('{"status":-1,"msg":"单位名称重复"}');
         $sql = $this->mysql_model->db_upd(UNIT, $data, '(id=' . $id . ')');
         if ($sql) {
             $data['id'] = $id;
             $this->data_model->logs('修改单位:' . $data['name']);
             $this->cache_model->delsome(UNIT);
             die('{"status":200,"msg":"success","data":' . json_encode($data) . '}');
         } else {
             die('{"status":-1,"msg":"修改失败"}');
         }
     }
 }
Beispiel #2
0
 public function export()
 {
     sys_xls('日志明细.xls');
     $user = str_enhtml($this->input->get('user', TRUE));
     $where = '';
     if ($user) {
         $where .= ' and username="******"';
     }
     $data['list'] = $this->cache_model->load_data(LOG, '(1=1) ' . $where . ' order by id desc');
     $this->load->view('logs/export', $data);
 }
Beispiel #3
0
 public function parameter()
 {
     $this->purview_model->checkpurview(81);
     $data = str_enhtml($this->input->post(NULL, TRUE));
     if (is_array($data) && count($data) > 0) {
         $dir = './data/config/parameter_config.php';
         $err = $this->config_model->set_config($data, $dir);
         if ($err) {
             die('{"status":200,"msg":"success"}');
         } else {
             alert('设置失败');
         }
     } else {
         $this->load->view('settings/parameter', $data);
     }
 }
Beispiel #4
0
 public function editpwd()
 {
     $userpwd = str_enhtml($this->input->post('userpwd', TRUE));
     if (strlen($userpwd) > 0) {
         $data['userpwd'] = md6($userpwd);
         $sql = $this->mysql_model->db_upd(ADMIN, $data, '(uid=' . $this->uid . ')');
         if ($sql) {
             $this->cache_model->delsome(ADMIN);
             $this->load->model('data_model');
             $this->data_model->logs('密码修改成功 用户名:' . $this->name);
             die('{"status":200,"msg":"密码修改成功"}');
         } else {
             die('{"status":-1,"msg":"修改失败"}');
         }
     } else {
         $this->load->view('admin/edit');
     }
 }
Beispiel #5
0
 public function index()
 {
     $data = str_enhtml($this->input->post(NULL, TRUE));
     if (is_array($data) && count($data) > 0) {
         !token(1) && die('token验证失败');
         !isset($data['username']) || strlen($data['username']) < 1 && die('用户名不能为空');
         !isset($data['userpwd']) || strlen($data['userpwd']) < 1 && die('密码不能为空');
         $sql = $this->login_model->login($data['username'], $data['userpwd']);
         if ($sql) {
             if (isset($data['ispwd']) && $data['ispwd'] == 1) {
                 $this->input->set_cookie('username', $data['username'], 3600000);
                 $this->input->set_cookie('userpwd', $data['userpwd'], 3600000);
             }
             $this->input->set_cookie('ispwd', $data['ispwd'], 3600000);
             $this->data_model->logs('登陆成功 用户名:' . $data['username']);
             die('1');
         }
         die('账号或密码错误');
     } else {
         $this->load->view('login', $data);
     }
 }
Beispiel #6
0
 public function del()
 {
     $this->purview_model->checkpurview(61);
     $id = str_enhtml($this->input->post('id', TRUE));
     if (strlen($id) > 0) {
         $this->mysql_model->db_count(INVSA, '(contactid in(' . $id . '))') > 0 && die('{"status":-1,"msg":"其中有客户发生业务不可删除"}');
         $name = $this->mysql_model->db_select(CONTACT, '(id in(' . $id . '))', 'name');
         if (count($name) > 0) {
             $name = join(',', $name);
         }
         $sql = $this->mysql_model->db_del(CONTACT, '(id in(' . $id . '))');
         if ($sql) {
             $this->cache_model->delsome(CONTACT);
             $this->data_model->logs('删除客户:ID=' . $id . ' 名称:' . $name);
             die('{"status":200,"msg":"success","data":{"msg":"","id":[' . $id . ']}}');
         } else {
             die('{"status":-1,"msg":"删除失败"}');
         }
     }
 }
Beispiel #7
0
 public function export()
 {
     $this->purview_model->checkpurview(10);
     sys_xls('销货记录.xls');
     $id = str_enhtml($this->input->get_post('id', TRUE));
     if (strlen($id) > 0) {
         $data['list1'] = $this->cache_model->load_data(INVSA, '(id in(' . $id . '))');
         $data['list2'] = $this->data_model->invsa_info(' and (a.invsaid in(' . $id . '))');
         $this->data_model->logs('导出销货记录');
         $this->load->view('invsa/export', $data);
     }
 }
Beispiel #8
0
 public function del()
 {
     $this->purview_model->checkpurview(76);
     $id = intval($this->input->post('id', TRUE));
     $type = str_enhtml($this->input->post('typeNumber', TRUE));
     $data = $this->mysql_model->db_one(CATEGORY, '(id=' . $id . ')');
     if (count($data) > 0) {
         $this->mysql_model->db_count(CATEGORY, '(1=1) and (find_in_set(' . $id . ',path))') > 1 && die('{"status":500,"msg":"操作的对象包含了下级类别,请先删除下级类别"}');
         $this->mysql_model->db_count(GOODS, '(categoryid=' . $id . ')') > 0 && die('{"status":500,"msg":"发生业务不可删除"}');
         $this->mysql_model->db_count(CONTACT, '(categoryid=' . $id . ')') > 0 && die('{"status":500,"msg":"发生业务不可删除"}');
         $sql = $this->mysql_model->db_del(CATEGORY, '(id=' . $id . ')');
         if ($sql) {
             $cate = $this->data_model->category_type();
             $this->data_model->logs('删除' . $cate[$data['type']] . ':ID=' . $id . ' 名称:' . $data['name']);
             $this->cache_model->delsome(CATEGORY);
             die('{"status":200,"msg":"success"}');
         } else {
             die('{"status":-1,"msg":"删除失败"}');
         }
     }
 }
Beispiel #9
0
 public function export()
 {
     $this->purview_model->checkpurview(72);
     sys_xls('商品明细.xls');
     $skey = str_enhtml($this->input->get('skey', TRUE));
     $categoryid = intval($this->input->get('assistId', TRUE));
     $where = '';
     if ($skey) {
         $where .= ' and goods like "%' . $skey . '%"';
     }
     if ($categoryid > 0) {
         $cid = $this->cache_model->load_data(CATEGORY, '(1=1) and find_in_set(' . $categoryid . ',path)', 'id');
         if (count($cid) > 0) {
             $cid = join(',', $cid);
             $where .= ' and categoryid in(' . $cid . ')';
         }
     }
     $this->data_model->logs('导出商品');
     $data['list'] = $this->cache_model->load_data(GOODS, '(status=1) ' . $where . ' order by id desc');
     $this->load->view('goods/export', $data);
 }
Beispiel #10
0
 public function type()
 {
     $type = str_enhtml($this->input->get_post('type', TRUE));
     if (strlen($type) > 0) {
         $v = '';
         $data['status'] = 200;
         $data['msg'] = 'success';
         $list = $this->cache_model->load_data(INVOI_TYPE, '(type="' . $type . '") order by id');
         foreach ($list as $arr => $row) {
             $v[$arr]['acctId'] = 0;
             $v[$arr]['calCost'] = 1;
             $v[$arr]['commission'] = false;
             $v[$arr]['direction'] = 1;
             $v[$arr]['free'] = false;
             $v[$arr]['id'] = intval($row['id']);
             $v[$arr]['inOut'] = (double) $row['inout'];
             $v[$arr]['name'] = $row['name'];
             $v[$arr]['process'] = false;
             $v[$arr]['sysDefault'] = true;
             $v[$arr]['sysDelete'] = false;
             $v[$arr]['tableName'] = "t_scm_inventryoi";
             $v[$arr]['typeId'] = intval($row['id']);
             $v[$arr]['voucher'] = true;
         }
         $data['data']['items'] = is_array($v) ? $v : '';
         $data['data']['totalsize'] = $this->cache_model->load_total(INVOI_TYPE, '(type="' . $type . '")');
         die(json_encode($data));
     }
 }
Beispiel #11
0
 public function balance_detail_xls()
 {
     $this->purview_model->checkpurview(56);
     sys_xls('balance_detail.xls');
     $data['stt'] = str_enhtml($this->input->get_post('beginDate', TRUE));
     $data['ett'] = str_enhtml($this->input->get_post('endDate', TRUE));
     $accountno = str_enhtml($this->input->get_post('accountNo', TRUE));
     $where1 = '';
     $where2 = '';
     if ($accountno) {
         $where1 .= ' and number in(' . str_quote($accountno) . ')';
     }
     if ($data['stt']) {
         $where2 .= ' and billdate>="' . $data['stt'] . '"';
     }
     if ($data['ett']) {
         $where2 .= ' and billdate<="' . $data['ett'] . '"';
     }
     $data['list1'] = $this->cache_model->load_data(CONTACT, '(status=1) and type=1 ' . $where1 . ' order by id');
     $data['list2'] = $this->cache_model->load_data(INVSA, '(1=1) ' . $where2 . ' order by id');
     $this->load->view('report/balance_detail_xls', $data);
 }
Beispiel #12
0
 public function export()
 {
     $this->purview_model->checkpurview(13);
     sys_xls('盘点表.xls');
     $categoryid = intval($this->input->get_post('categoryId', TRUE));
     $goods = str_enhtml($this->input->get_post('goods', TRUE));
     $qty = intval($this->input->get_post('showZero', TRUE));
     $where = '';
     $order = 'order by a.id desc';
     if ($categoryid > 0) {
         $cid = $this->cache_model->load_data(CATEGORY, '(1=1) and find_in_set(' . $categoryid . ',path)', 'id');
         if (count($cid) > 0) {
             $cid = join(',', $cid);
             $where .= ' and a.categoryid in(' . $cid . ')';
         }
     }
     if ($qty > 0) {
         $order = ' HAVING (qty<=0)';
     }
     if ($goods) {
         $where .= ' and a.goods like "%' . $goods . '%"';
     }
     $this->data_model->logs('导出盘点记录');
     $data['list'] = $this->data_model->inventory($where, $order);
     $this->load->view('inventory/export', $data);
 }
Beispiel #13
0
 public function admin_checkname()
 {
     $username = str_enhtml($this->input->get('userName', TRUE));
     $this->cache_model->load_total(ADMIN, '(username="******")') > 0 && die('{"status":200,"msg":"success"}');
     die('{"status":502,"msg":"用户名不存在"}');
 }
Beispiel #14
0
 public function recovery()
 {
     $name = str_enhtml($this->input->get_post('name', TRUE));
     $path = $this->conf['db_url'] . $name;
     $info = read_file($path);
     if ($info) {
         $this->db->trans_begin();
         $list = explode(";\n", $info);
         foreach ($list as $sql) {
             $this->db->query($sql);
         }
         if ($this->db->trans_status() === FALSE) {
             $this->db->trans_rollback();
             die('{"status":-1,"msg":"恢复失败"}');
         } else {
             $this->db->trans_commit();
             $this->data_model->logs('备份与恢复,恢复文件名:' . $name);
             die('{"status":200,"msg":"success"}');
         }
     } else {
         die('{"status":-1,"msg":"恢复失败"}');
     }
 }
Beispiel #15
0
 public function del()
 {
     $this->purview_model->checkpurview(66);
     $id = str_enhtml($this->input->post('id', TRUE));
     if (strlen($id) > 0) {
         $this->mysql_model->db_count(INVPU, '(contactid in(' . $id . '))') > 0 && die('{"status":-1,"msg":"其中有供应商发生业务不可删除"}');
         $sql = $this->mysql_model->db_del(CONTACT, '(id in(' . $id . '))');
         if ($sql) {
             $this->cache_model->delsome(CONTACT);
             $this->data_model->logs('删除供应商:ID=' . $id);
             die('{"status":200,"msg":"success","data":{"msg":"","id":[' . $id . ']}}');
         } else {
             die('{"status":-1,"msg":"删除失败"}');
         }
     }
 }
Beispiel #16
0
 public function doset()
 {
     $act = $this->input->get('act', TRUE);
     $username = str_enhtml($this->input->get('username', TRUE));
     $username == 'admin' && die('{"status":-1,"msg":"管理员不可操作"}');
     switch ($act) {
         case 'isstatus':
             $data['status'] = 1;
             break;
         case 'nostatus':
             $data['status'] = 0;
             break;
         default:
             die('{"status":-1,"msg":"操作失败"}');
     }
     $sql = $this->mysql_model->db_upd(ADMIN, $data, '(username="******")');
     if ($sql) {
         $this->cache_model->delsome(ADMIN);
         die('{"status":200,"data":{"userName":"******"},"msg":"success"}');
     } else {
         die('{"status":-1,"msg":"操作失败"}');
     }
 }