Colour.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Colour extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_colour','colour');
  7. $this->load->_model('Model_shop','shop');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_fullorder','fullorder');
  10. $this->load->_model('Model_fullordertt','fullordertt');
  11. $this->load->_model('Model_fullordersmt','fullordersmt');
  12. $this->load->_model("Model_logic_order","logic_order");
  13. //getInfo
  14. }
  15. //定义方法的调用规则 获取URI第二段值
  16. public function _remap($arg,$arg_array)
  17. {
  18. if($arg == 'add')
  19. {
  20. $this->_add();
  21. }
  22. else if($arg == 'edit')
  23. {
  24. $this->_edit($arg_array);
  25. }
  26. else if($arg == 'see')
  27. {
  28. $this->_see($arg_array);
  29. }
  30. else if($arg == 'seeindex')
  31. {
  32. $this->_seeindex();
  33. }
  34. else if($arg == 'seephone')
  35. {
  36. $this->_seephone();
  37. }
  38. else if($arg == 'del')
  39. {
  40. $this->_del();
  41. }
  42. else if($arg == 'seebynumber'){
  43. $this->_seebynumber($arg_array);
  44. }
  45. else
  46. {
  47. $this->_index();
  48. }
  49. }
  50. public function _index()
  51. {
  52. if(isset($_SESSION['api']))
  53. {
  54. $user = $this->user->get_api($_SESSION['api']);
  55. $usp = $user;
  56. $fgshop = "";$sid = "";
  57. $usersp = explode('|',trim($user['shop'],'|'));
  58. foreach ($usersp as $value)
  59. {
  60. $fgshop .= " shop = ".$value." or";
  61. $sid .= " id = ".$value." or";
  62. }
  63. $fgshop .= " shop = '0' or";
  64. }
  65. $post = $this->input->post(NULL, TRUE);
  66. if(isset($post['page']))
  67. {
  68. $page = $this->input->post('page',true);
  69. $perpage = $this->input->post('perpage',true);
  70. $number = $this->input->post('number',true);
  71. $shop = $this->input->post('shop',true);
  72. $warehouse = $this->input->post('warehouse',true);
  73. $timetk = $this->input->post('timetk',true);
  74. $timetj = $this->input->post('timetj',true);
  75. $timetk = strtotime($timetk);
  76. $timetj = strtotime($timetj);
  77. $where = "(".rtrim($fgshop,'or').")";
  78. if($number)
  79. {
  80. $where .= " and number like '%$number%'";
  81. }
  82. if($shop)
  83. {
  84. $where .= " and shop = '$shop'";
  85. }
  86. if($warehouse)
  87. {
  88. $where .= " and warehouse = '$warehouse'";
  89. }
  90. if($timetk && $timetj)
  91. {
  92. $where .= " and time > '$timetk' and time < '$timetj'";
  93. }
  94. //数据排序
  95. $order_str = "id desc";
  96. if(empty($page))
  97. {
  98. $start = 0;
  99. $perpage = 1;
  100. }
  101. else
  102. {
  103. $start = ($page - 1)*$perpage;
  104. }
  105. $info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
  106. foreach ($info_list as $key=>$value)
  107. {
  108. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  109. if($value['shop'] == '0')
  110. {
  111. $info_list[$key]['shop'] = '常用色';
  112. }
  113. else
  114. {
  115. $shop = $this->shop->read($value['shop']);
  116. $info_list[$key]['shop'] = $shop['shopname'];
  117. }
  118. $warehouse = $this->warehouse->read($value['warehouse']);
  119. $info_list[$key]['warehouse'] = $warehouse['title'];
  120. }
  121. $total = $this->colour->find_count($where);
  122. $pagenum = ceil($total/$perpage);
  123. $over = $total-($start+$perpage);
  124. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'cs'=>$fgshop);
  125. echo json_encode($rows);exit;
  126. }
  127. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  128. $this->data['wlshop'] = $wlshop;
  129. $this->_Template('colour',$this->data);
  130. }
  131. public function _add()
  132. {
  133. $post = $this->input->post(NULL, TRUE);
  134. if(isset($post['number']))
  135. {
  136. $number = $this->input->post('number',true);
  137. $post['number'] = trim($number,' ');
  138. $post['warehouse'] = $this->input->post('warehouse',true);
  139. $img = $this->input->post('img',true);
  140. $post['img'] = rtrim($img,'|');
  141. $post['content'] = $this->input->post('content',true);
  142. $post['time'] = time();
  143. if(empty($post['number'])){
  144. echo json_encode(array('msg'=>'订单编号不能为空!','success'=>false));exit;
  145. }
  146. if($this->colour->get_number($post['number']))
  147. {
  148. echo json_encode(array('msg'=>'此订单编号已存在!','success'=>false));exit;
  149. }
  150. if(stripos($post['number'],'#') !== false)
  151. {
  152. $post['shop'] = 0;
  153. }
  154. else
  155. {
  156. $number = $this->logic_order->getInfo("number = '".$post['number']."'");
  157. if(empty($number)){
  158. echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
  159. }
  160. // $number = $this->fullorder->get_number($post['number']);
  161. // if(!$number)
  162. // {
  163. // $number = $this->fullordersmt->get_number($post['number']);
  164. // if(!$number)
  165. // {
  166. // $number = $this->fullordertt->get_number($post['number']);
  167. // if(!$number)
  168. // {
  169. // echo json_encode(array('msg'=>'订单中未找到此编号!','success'=>false));exit;
  170. // }
  171. // }
  172. // }
  173. }
  174. $post['shop'] = $number['shop'];
  175. if($this->colour->insert($post))
  176. {
  177. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  178. }
  179. else
  180. {
  181. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  182. }
  183. }
  184. $this->_Template('colour_add',$this->data);
  185. }
  186. public function _edit($arg_array)
  187. {
  188. $user = $this->user->get_api($_SESSION['api']);
  189. $post = $this->input->post(NULL, TRUE);
  190. if(isset($post['id']))
  191. {
  192. $id = $this->input->post('id',true);
  193. $post['warehouse'] = $this->input->post('warehouse',true);
  194. $img = $this->input->post('img',true);
  195. $post['img'] = rtrim($img,'|');
  196. $post['content'] = $this->input->post('content',true);
  197. $post['edittime'] = time();
  198. if($this->colour->save($post,$id))
  199. {
  200. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  201. }
  202. else
  203. {
  204. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  205. }
  206. }
  207. $arg_array = $arg_array[0];
  208. $colour = $this->colour->read($arg_array);
  209. $colourimg = explode('|',$colour['img']);
  210. $img = '';
  211. foreach ($colourimg as $v)
  212. {
  213. $lx = explode(".",$v);
  214. $lx = strtolower(end($lx));
  215. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  216. {
  217. $img .= '<span class="deldata"><video src="'.$v.'" controls="controls"></video>'."<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em></span>";
  218. }
  219. else if($v != '')
  220. {
  221. $url = 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);
  222. $url = explode('&',$url);
  223. $url = $url[0];
  224. $img .= '<span class="deldata"><a href="'.$url.'" target="_blank">'."<img src='".site_url('img/thumb')."?src=".$url."&w=500&h=500' data-src='".$v."'></a>"."<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em></span>";
  225. }
  226. else
  227. {
  228. $img = '';
  229. }
  230. }
  231. $this->data['userid'] = $user['userid'];
  232. $colour['img'] = $img;
  233. $this->data['colour'] = $colour;
  234. $this->_Template('colour_edit',$this->data);
  235. }
  236. public function _see($arg_array)
  237. {
  238. $arg_array = $arg_array[0];
  239. $colour = $this->colour->read($arg_array);
  240. $colourimg = explode('|',$colour['img']);
  241. $img = array();$i = 1;
  242. foreach ($colourimg as $v)
  243. {
  244. $lx = explode(".",$v);
  245. $lx = strtolower(end($lx));
  246. /**
  247. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  248. {
  249. $img .= '<video src="'.$v.'" controls="controls"></video>';
  250. }
  251. else if($v != '')
  252. {
  253. $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>";
  254. }
  255. else
  256. {
  257. $img = '';
  258. }
  259. **/
  260. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  261. {
  262. $img[] = array('sp',$v);
  263. }
  264. else if($v != '')
  265. {
  266. $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>");
  267. }
  268. $i++;
  269. }
  270. $colour['img'] = $img;
  271. $this->data['colour'] = $colour;
  272. $this->data['is_has'] =1;
  273. $this->_Template('colour_see',$this->data);
  274. }
  275. public function _seeindex()
  276. {
  277. if(isset($_SESSION['api']))
  278. {
  279. $user = $this->user->get_api($_SESSION['api']);
  280. $usp = $user;
  281. $fgshop = "";$sid = "";$wid="";$wtype="";
  282. $usersp = explode('|',trim($user['shop'],'|'));
  283. $userwh = explode('|',trim($user['warehouse'],'|'));
  284. foreach ($usersp as $value)
  285. {
  286. $fgshop .= " shop = ".$value." or";
  287. $sid .= " id = ".$value." or";
  288. }
  289. foreach ($userwh as $value)
  290. {
  291. $wid .= " id = ".$value." or";
  292. $wtype .= " warehouse = ".$value." or";
  293. }
  294. $fgshop .= " shop = '0' or";
  295. }
  296. $post = $this->input->post(NULL, TRUE);
  297. if(isset($post['page']))
  298. {
  299. $page = $this->input->post('page',true);
  300. $perpage = $this->input->post('perpage',true);
  301. $number = $this->input->post('number',true);
  302. $shop = $this->input->post('shop',true);
  303. $warehouse = $this->input->post('warehouse',true);
  304. $timetk = $this->input->post('timetk',true);
  305. $timetj = $this->input->post('timetj',true);
  306. $timetk = strtotime($timetk);
  307. $timetj = strtotime($timetj);
  308. $where = "(".rtrim($fgshop,'or').")";
  309. if($number)
  310. {
  311. $where .= " and number like '%$number%'";
  312. }
  313. if($shop)
  314. {
  315. $where .= " and shop = '$shop'";
  316. }
  317. if($warehouse)
  318. {
  319. $where .= " and warehouse = '$warehouse'";
  320. }
  321. if($timetk && $timetj)
  322. {
  323. $where .= " and time > '$timetk' and time < '$timetj'";
  324. }
  325. //数据排序
  326. $order_str = "id desc";
  327. if(empty($page))
  328. {
  329. $start = 0;
  330. $perpage = 1;
  331. }
  332. else
  333. {
  334. $start = ($page - 1)*$perpage;
  335. }
  336. $info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
  337. foreach ($info_list as $key=>$value)
  338. {
  339. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  340. if($value['shop'] == '0')
  341. {
  342. $info_list[$key]['shop'] = '常用色';
  343. }
  344. else
  345. {
  346. $shop = $this->shop->read($value['shop']);
  347. $info_list[$key]['shop'] = $shop['shopname'];
  348. }
  349. $warehouse = $this->warehouse->read($value['warehouse']);
  350. $info_list[$key]['warehouse'] = $warehouse['title'];
  351. }
  352. $total = $this->colour->find_count($where);
  353. $pagenum = ceil($total/$perpage);
  354. $over = $total-($start+$perpage);
  355. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  356. echo json_encode($rows);exit;
  357. }
  358. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  359. $this->data['wlshop'] = $wlshop;
  360. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  361. $this->data['warehouse'] = $warehouse;
  362. $this->_Template('colour_seeindex',$this->data);
  363. }
  364. public function _seephone()
  365. {
  366. $this->_Template('colour_seephone',$this->data);
  367. }
  368. //删除
  369. public function _del()
  370. {
  371. $post = $this->input->post(NULL, TRUE);
  372. if(isset($post['s']))
  373. {
  374. $id_arr = $this->input->post('s');
  375. $id_arr = explode(',',$id_arr);
  376. if(!$id_arr)
  377. {
  378. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  379. }
  380. //循环删除记录
  381. foreach ($id_arr as $v)
  382. {
  383. $this->colour->remove($v);
  384. }
  385. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  386. }
  387. }
  388. public function _seebynumber($arg_array){
  389. $number = $arg_array[0];
  390. $colour = $this->colour->find("number = '$number'");
  391. if(empty($colour)){
  392. $this->data['is_has'] = 0;
  393. $this->_Template('colour_see',$this->data);
  394. die;
  395. }
  396. $colourimg = explode('|',$colour['img']);
  397. $img = array();$i = 1;
  398. foreach ($colourimg as $v)
  399. {
  400. $lx = explode(".",$v);
  401. $lx = strtolower(end($lx));
  402. /**
  403. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  404. {
  405. $img .= '<video src="'.$v.'" controls="controls"></video>';
  406. }
  407. else if($v != '')
  408. {
  409. $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>";
  410. }
  411. else
  412. {
  413. $img = '';
  414. }
  415. **/
  416. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  417. {
  418. $img[] = array('sp',$v);
  419. }
  420. else if($v != '')
  421. {
  422. $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>");
  423. }
  424. $i++;
  425. }
  426. $colour['img'] = $img;
  427. $this->data['colour'] = $colour;
  428. $this->data['is_has'] = 1;
  429. $this->_Template('colour_see',$this->data);
  430. }
  431. }