Colour.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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->_Template('colour_see',$this->data);
  273. }
  274. public function _seeindex()
  275. {
  276. if(isset($_SESSION['api']))
  277. {
  278. $user = $this->user->get_api($_SESSION['api']);
  279. $usp = $user;
  280. $fgshop = "";$sid = "";$wid="";$wtype="";
  281. $usersp = explode('|',trim($user['shop'],'|'));
  282. $userwh = explode('|',trim($user['warehouse'],'|'));
  283. foreach ($usersp as $value)
  284. {
  285. $fgshop .= " shop = ".$value." or";
  286. $sid .= " id = ".$value." or";
  287. }
  288. foreach ($userwh as $value)
  289. {
  290. $wid .= " id = ".$value." or";
  291. $wtype .= " warehouse = ".$value." or";
  292. }
  293. $fgshop .= " shop = '0' or";
  294. }
  295. $post = $this->input->post(NULL, TRUE);
  296. if(isset($post['page']))
  297. {
  298. $page = $this->input->post('page',true);
  299. $perpage = $this->input->post('perpage',true);
  300. $number = $this->input->post('number',true);
  301. $shop = $this->input->post('shop',true);
  302. $warehouse = $this->input->post('warehouse',true);
  303. $timetk = $this->input->post('timetk',true);
  304. $timetj = $this->input->post('timetj',true);
  305. $timetk = strtotime($timetk);
  306. $timetj = strtotime($timetj);
  307. $where = "(".rtrim($fgshop,'or').")";
  308. if($number)
  309. {
  310. $where .= " and number like '%$number%'";
  311. }
  312. if($shop)
  313. {
  314. $where .= " and shop = '$shop'";
  315. }
  316. if($warehouse)
  317. {
  318. $where .= " and warehouse = '$warehouse'";
  319. }
  320. if($timetk && $timetj)
  321. {
  322. $where .= " and time > '$timetk' and time < '$timetj'";
  323. }
  324. //数据排序
  325. $order_str = "id desc";
  326. if(empty($page))
  327. {
  328. $start = 0;
  329. $perpage = 1;
  330. }
  331. else
  332. {
  333. $start = ($page - 1)*$perpage;
  334. }
  335. $info_list = $this->colour->find_all($where,'id,number,shop,warehouse,time',$order_str,$start,$perpage);
  336. foreach ($info_list as $key=>$value)
  337. {
  338. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  339. if($value['shop'] == '0')
  340. {
  341. $info_list[$key]['shop'] = '常用色';
  342. }
  343. else
  344. {
  345. $shop = $this->shop->read($value['shop']);
  346. $info_list[$key]['shop'] = $shop['shopname'];
  347. }
  348. $warehouse = $this->warehouse->read($value['warehouse']);
  349. $info_list[$key]['warehouse'] = $warehouse['title'];
  350. }
  351. $total = $this->colour->find_count($where);
  352. $pagenum = ceil($total/$perpage);
  353. $over = $total-($start+$perpage);
  354. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  355. echo json_encode($rows);exit;
  356. }
  357. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  358. $this->data['wlshop'] = $wlshop;
  359. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  360. $this->data['warehouse'] = $warehouse;
  361. $this->_Template('colour_seeindex',$this->data);
  362. }
  363. public function _seephone()
  364. {
  365. $this->_Template('colour_seephone',$this->data);
  366. }
  367. //删除
  368. public function _del()
  369. {
  370. $post = $this->input->post(NULL, TRUE);
  371. if(isset($post['s']))
  372. {
  373. $id_arr = $this->input->post('s');
  374. $id_arr = explode(',',$id_arr);
  375. if(!$id_arr)
  376. {
  377. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  378. }
  379. //循环删除记录
  380. foreach ($id_arr as $v)
  381. {
  382. $this->colour->remove($v);
  383. }
  384. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  385. }
  386. }
  387. public function _seebynumber($arg_array){
  388. $number = $arg_array[0];
  389. $colour = $this->colour->find("number = '$number'");
  390. if(empty($colour)){
  391. $this->data['is_has'] = 0;
  392. }
  393. $colourimg = explode('|',$colour['img']);
  394. $img = array();$i = 1;
  395. foreach ($colourimg as $v)
  396. {
  397. $lx = explode(".",$v);
  398. $lx = strtolower(end($lx));
  399. /**
  400. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  401. {
  402. $img .= '<video src="'.$v.'" controls="controls"></video>';
  403. }
  404. else if($v != '')
  405. {
  406. $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>";
  407. }
  408. else
  409. {
  410. $img = '';
  411. }
  412. **/
  413. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  414. {
  415. $img[] = array('sp',$v);
  416. }
  417. else if($v != '')
  418. {
  419. $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>");
  420. }
  421. $i++;
  422. }
  423. $colour['img'] = $img;
  424. $this->data['colour'] = $colour;
  425. $this->data['is_has'] = 1;
  426. $this->_Template('colour_see',$this->data);
  427. }
  428. }