123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Colour extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_colour','colour');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'add')
- {
- $this->_add();
- }
- else if($arg == 'edit')
- {
- $this->_edit($arg_array);
- }
- else if($arg == 'see')
- {
- $this->_see($arg_array);
- }
- else if($arg == 'seeindex')
- {
- $this->_seeindex();
- }
- else if($arg == 'seephone')
- {
- $this->_seephone();
- }
- else if($arg == 'del')
- {
- $this->_del();
- }
- else
- {
- $this->_index();
- }
- }
-
- public function _index()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $fgshop .= " shop = '0' or";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $number = $this->input->post('number',true);
- $shop = $this->input->post('shop',true);
- $warehouse = $this->input->post('warehouse',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "(".rtrim($fgshop,'or').")";
- if($number)
- {
- $where .= " and number like '%$number%'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
- if($value['shop'] == '0')
- {
- $info_list[$key]['shop'] = '常用色';
- }
- else
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- }
- $total = $this->colour->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$fgshop);
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('colour',$this->data);
- }
-
- public function _add()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['number']))
- {
- $number = $this->input->post('number',true);
- $post['number'] = trim($number,' ');
- $post['warehouse'] = $this->input->post('warehouse',true);
- $img = $this->input->post('img',true);
- $post['img'] = rtrim($img,'|');
- $post['content'] = $this->input->post('content',true);
- $post['time'] = time();
- if($this->colour->get_number($post['number']))
- {
- echo json_encode(array('msg'=>'此订单编号已存在!','success'=>false));exit;
- }
- if(stripos($post['number'],'#') !== false)
- {
- $post['shop'] = 0;
- }
- else
- {
- $number = $this->fullorder->get_number($post['number']);
- if(!$number)
- {
- $number = $this->fullordersmt->get_number($post['number']);
- if(!$number)
- {
- $number = $this->fullordertt->get_number($post['number']);
- if(!$number)
- {
- echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
- }
-
- }
- }
- }
- $post['shop'] = $number['shop'];
- if($this->colour->insert($post))
- {
- echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
- }
- }
- $this->_Template('colour_add',$this->data);
- }
-
- public function _edit($arg_array)
- {
- $user = $this->user->get_api($_SESSION['api']);
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- $img = $this->input->post('img',true);
- $post['img'] = rtrim($img,'|');
- $post['content'] = $this->input->post('content',true);
- $post['edittime'] = time();
- if($this->colour->save($post,$id))
- {
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
- }
- }
- $arg_array = $arg_array[0];
- $colour = $this->colour->read($arg_array);
- $colourimg = explode('|',$colour['img']);
- $img = '';
- foreach ($colourimg as $v)
- {
- $lx = explode(".",$v);
- $lx = strtolower(end($lx));
- if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
- {
- $img .= '<video src="'.$v.'" controls="controls" title="点击视频左上角删除"></video>';
- }
- else if($v != '')
- {
- $img .= "<img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','/img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'>";
- }
- else
- {
- $img = '';
- }
- }
- $this->data['userid'] = $user['userid'];
- $colour['img'] = $img;
- $this->data['colour'] = $colour;
- $this->_Template('colour_edit',$this->data);
- }
-
- public function _see($arg_array)
- {
- $arg_array = $arg_array[0];
- $colour = $this->colour->read($arg_array);
- $colourimg = explode('|',$colour['img']);
- $img = array();$i = 1;
- foreach ($colourimg as $v)
- {
- $lx = explode(".",$v);
- $lx = strtolower(end($lx));
- /**
- if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
- {
- $img .= '<video src="'.$v.'" controls="controls"></video>';
- }
- else if($v != '')
- {
- $img .= "<a href='".$v."' download='".$colour['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>";
- }
- else
- {
- $img = '';
- }
- **/
- if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
- {
- $img[] = array('sp',$v);
- }
- else if($v != '')
- {
- $img[] = array('tp',"<a href='".$v."' download='".$colour['number']."第".$i."张图片'><img src='".site_url('img/thumb')."?src=".str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','img/thumb?src='),'',$v)."&w=500&h=500' data-src='".$v."'></a>");
- }
- $i++;
- }
- $colour['img'] = $img;
- $this->data['colour'] = $colour;
- $this->_Template('colour_see',$this->data);
- }
-
- public function _seeindex()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$wid="";$wtype="";
- $usersp = explode('|',trim($user['shop'],'|'));
- $userwh = explode('|',trim($user['warehouse'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- foreach ($userwh as $value)
- {
- $wid .= " id = ".$value." or";
- $wtype .= " warehouse = ".$value." or";
- }
- $fgshop .= " shop = '0' or";
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $number = $this->input->post('number',true);
- $shop = $this->input->post('shop',true);
- $warehouse = $this->input->post('warehouse',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "(".rtrim($fgshop,'or').")";
- if($number)
- {
- $where .= " and number like '%$number%'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
- if($value['shop'] == '0')
- {
- $info_list[$key]['shop'] = '常用色';
- }
- else
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- }
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- }
- $total = $this->colour->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
- $this->data['warehouse'] = $warehouse;
- $this->_Template('colour_seeindex',$this->data);
- }
-
- public function _seephone()
- {
- $this->_Template('colour_seephone',$this->data);
- }
-
- //删除
- public function _del()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $this->colour->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- }
- }
|