Common.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Common {
  3. var $ci;
  4. function __construct(){
  5. $this->ci = &get_instance();
  6. }
  7. /*分类*/
  8. function _typeclass($classid,$en=3,$num=900,$order=NULL)
  9. {
  10. $this->ci->load->_model('Model_typeclass','typeclass');
  11. $where = "classid = '$classid'";
  12. if($en == '2')
  13. {
  14. $where .= " and spare != '0' and spare != '' and spare != 'null'";
  15. }
  16. if($en == '1')
  17. {
  18. $where .= " and ae != ''";
  19. }
  20. $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
  21. return $result;
  22. }
  23. /*分类2 这个是按照要求部分花型不显示出来*/
  24. function _typeclassyc($classid,$num=900,$order=NULL)
  25. {
  26. $this->ci->load->_model('Model_typeclass','typeclass');
  27. $where = "classid = '$classid'";
  28. $where .= " and id != 105 and id != 107 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189 and id != 53 and id != 67";
  29. $result = $this->ci->typeclass->find_all($where,'*',$order,0,$num);
  30. return $result;
  31. }
  32. /*店铺*/
  33. function _shop($type,$num=900,$order=NULL)
  34. {
  35. $this->ci->load->_model('Model_shop','shop');
  36. $where = '1=1';
  37. if($type)
  38. {
  39. $where .= " and type = '$type'";
  40. }
  41. $result = $this->ci->shop->find_all($where,'*',$order,0,$num);
  42. return $result;
  43. }
  44. /*USER店铺*/
  45. function _usershop($num=100,$order=NULL)
  46. {
  47. $this->ci->load->_model('Model_shop','shop');
  48. $user = $this->ci->user->get_api($_SESSION['api']);
  49. $usersp = explode('|',trim($user['shop'],'|'));$sid = '';
  50. foreach ($usersp as $v)
  51. {
  52. $sid .= " id = ".$v." or";
  53. }
  54. $result = $this->ci->shop->find_all(rtrim($sid,'or'),'*',$order,0,$num);
  55. return $result;
  56. }
  57. /*仓库*/
  58. function _warehouse($classid,$num=100,$order='px asc')
  59. {
  60. $this->ci->load->_model('Model_warehouse','warehouse');
  61. $this->ci->load->_model('Model_user','user');
  62. $this->ci->load->library('session');
  63. $user = $this->ci->user->get_api($_SESSION['api']);
  64. $where = "id != 2 and id != 14 and id != 11 and id != 15 and id != 10 and id != 1 and id != 4";
  65. $result = $this->ci->warehouse->find_all($where,'*',$order,0,$num);
  66. return $result;
  67. }
  68. /*独立站仓库*/
  69. function _dlzwarehouse($classid,$num=100,$order='px asc')
  70. {
  71. $this->ci->load->_model('Model_warehouse','warehouse');
  72. $where = "id != 2 and id != 7 and id != 8 and id != 9 and id != 14 and id != 11 and id != 15 and id != 10 and id != 1 and id != 4";
  73. $result = $this->ci->warehouse->find_all($where,'*',$order,0,$num);
  74. return $result;
  75. }
  76. /*快递*/
  77. function _express($num=100,$ae,$order=NULL)
  78. {
  79. $this->ci->load->_model('Model_express','express');
  80. $where = "off != '1'";
  81. if($ae == 'smt')
  82. {
  83. $where .= " and aecode != 'Others'";
  84. }
  85. $result = $this->ci->express->find_all($where,'*',$order,0,$num);
  86. return $result;
  87. }
  88. /*供应商*/
  89. function _purchase($classid,$num=100,$order=NULL)
  90. {
  91. $this->ci->load->_model('Model_purchase','purchase');
  92. $where = "1 = 1";
  93. $result = $this->ci->purchase->find_all($where,'*',$order,0,$num);
  94. return $result;
  95. }
  96. /*国家*/
  97. function _country($num=500,$order=NULL)
  98. {
  99. $this->ci->load->_model('Model_country','country');
  100. $where = "1 = 1";
  101. $result = $this->ci->country->find_all($where,'*',$order,0,$num);
  102. return $result;
  103. }
  104. /*海关申报*/
  105. function _customsdeclaration($num=500,$order=NULL)
  106. {
  107. $this->ci->load->_model('Model_customsdeclaration','customsdeclaration');
  108. $where = "1 = 1";
  109. $result = $this->ci->customsdeclaration->find_all($where,'*',$order,0,$num);
  110. return $result;
  111. }
  112. /*仓库产品位置*/
  113. function _whlabelwz($num=100,$order=NULL)
  114. {
  115. $this->ci->load->_model('Model_whlabelwz','whlabelwz');
  116. $where = "1 = 1";
  117. $result = $this->ci->whlabelwz->find_all($where,'*',$order,0,$num);
  118. return $result;
  119. }
  120. /*IOSS*/
  121. function _ioss($num=500,$order=NULL)
  122. {
  123. $this->ci->load->_model('Model_ioss','ioss');
  124. $where = "1 = 1";
  125. $result = $this->ci->ioss->find_all($where,'*',$order,0,$num);
  126. return $result;
  127. }
  128. /*email*/
  129. function _email($num=500,$shop,$order=NULL)
  130. {
  131. $this->ci->load->_model('Model_email','email');
  132. $where = "1 = 1";
  133. if($shop)
  134. {
  135. $where .= "shop = '$shop'";
  136. }
  137. $result = $this->ci->email->find_all($where,'*',$order,0,$num);
  138. return $result;
  139. }
  140. /*品牌*/
  141. function _brand($num=100,$order=NULL)
  142. {
  143. $this->ci->load->_model('Model_brand','brand');
  144. $where = "1 = 1";
  145. $result = $this->ci->brand->find_all($where,'*',$order,0,$num);
  146. return $result;
  147. }
  148. /*备货类型*/
  149. function _whlabel_type($num=100,$order=NULL)
  150. {
  151. $this->ci->load->_model('Modelwhlabel_type','whlabel_type');
  152. $where = "1 = 1";
  153. $result = $this->ci->whlabel_type->find_all($where,'*',$order,0,$num);
  154. return $result;
  155. }
  156. }
  157. /*通用类对象*/
  158. function get_common(){
  159. return new Common();
  160. }
  161. /*分类*/
  162. function typeclass($classid,$en=3,$num=900,$order='sequence asc'){
  163. $com = &get_common();
  164. return $com->_typeclass($classid,$en,$num,$order);
  165. }
  166. /*分类2 这个是按照要求部分花型不显示出来*/
  167. function typeclassyc($classid,$num=900,$order='sequence asc'){
  168. $com = &get_common();
  169. return $com->_typeclassyc($classid,$num,$order);
  170. }
  171. /*店铺*/
  172. function shop($type=269,$num=900,$order='id asc'){
  173. $com = &get_common();
  174. return $com->_shop($type,$num,$order);
  175. }
  176. /*USER店铺*/
  177. function usershop($num=100,$order='px asc'){
  178. $com = &get_common();
  179. return $com->_usershop($num,$order);
  180. }
  181. /*仓库*/
  182. function warehouse($num=900,$order='id asc'){
  183. $com = &get_common();
  184. return $com->_warehouse($num,$order);
  185. }
  186. /*独立站仓库*/
  187. function dlzwarehouse($num=20,$order='id asc'){
  188. $com = &get_common();
  189. return $com->_warehouse($num,$order);
  190. }
  191. /*快递*/
  192. function express($num=20,$ae=1,$order='idsort desc'){
  193. $com = &get_common();
  194. return $com->_express($num,$ae,$order);
  195. }
  196. /*供应商*/
  197. function purchase($num=20,$order='id asc'){
  198. $com = &get_common();
  199. return $com->_purchase($num,$order);
  200. }
  201. /*国家*/
  202. function country($num=500,$order='ename asc'){
  203. $com = &get_common();
  204. return $com->_country($num,$order);
  205. }
  206. /*海关申报*/
  207. function customsdeclaration($num=500,$order='px asc'){
  208. $com = &get_common();
  209. return $com->_customsdeclaration($num,$order);
  210. }
  211. /*仓库产品位置*/
  212. function whlabelwz($num=100,$order='id asc'){
  213. $com = &get_common();
  214. return $com->_whlabelwz($num,$order);
  215. }
  216. /*IOSS*/
  217. function ioss($num=500,$order='id asc'){
  218. $com = &get_common();
  219. return $com->_ioss($num,$order);
  220. }
  221. /*email*/
  222. function email($num=500,$shop='',$order='id asc'){
  223. $com = &get_common();
  224. return $com->_email($num,$shop,$order);
  225. }
  226. /*品牌*/
  227. function brand($num=500,$order='id asc'){
  228. $com = &get_common();
  229. return $com->_brand($num,$order);
  230. }
  231. /*备货类型*/
  232. function whlabel_type($num=500,$order='id asc'){
  233. $com = &get_common();
  234. return $com->_whlabel_type($num,$order);
  235. }
  236. /*载入编辑器*/
  237. function load_editor($id='content',$top = '0px',$height='300px',$content='<p><br></p>')
  238. {
  239. /**
  240. return
  241. '<script type="text/plain" id="'.$id.'" style="width:'.$width.';height:'.$height.';">'.$content.'</script>
  242. <script charset="utf-8" src="'.base_url().'/style/NEWUM/umeditor.config.js"></script>
  243. <script charset="utf-8" src="'.base_url().'/style/NEWUM/umeditor.min.js"></script>
  244. <script charset="utf-8" src="'.base_url().'/style/NEWUM/lang/zh-cn/zh-cn.js"></script>
  245. <script>var um = UM.getEditor("'.$id.'"); </script>'
  246. **/
  247. $content = str_replace("'","&#39;",$content);
  248. return
  249. "
  250. <div style='margin-top:$top;'>
  251. <div id='tool-".$id."' style='border-bottom: 1px solid #ccc;'></div>
  252. <div id='".$id."' style='min-height:$height;'></div>
  253. </div>
  254. <textarea name='Editorcontent' class='none'>$content</textarea>
  255. <link href='".base_url()."/style/Editor/Editor.css' rel='stylesheet' type='text/css' />
  256. <script charset='utf-8' src='".base_url()."/style/Editor/Editor.js'></script>
  257. <script>
  258. const { createEditor, createToolbar } = window.wangEditor
  259. const editorConfig = {
  260. placeholder: '输入内容...',
  261. onChange(editor) {
  262. const html = editor.getHtml()
  263. $('textarea[name=$id]').val(html);
  264. console.log('editor content', html)
  265. },
  266. MENU_CONF: {}
  267. }
  268. editorConfig.MENU_CONF['uploadImage'] = {
  269. server: '/img/textimg',
  270. fieldName: 'upfile',
  271. timeout: 10 * 1000, // 5s
  272. maxFileSize: 10 * 1024 * 1024, // 10M
  273. }
  274. const editor = createEditor({
  275. selector: '#".$id."',
  276. html: $('textarea[name=Editorcontent]').val(),
  277. config: editorConfig,
  278. mode: 'default', // or 'simple'
  279. })
  280. const toolbarConfig = { excludeKeys: [
  281. 'blockquote',//引用
  282. 'code',//行内代码
  283. 'sup',//上标
  284. 'sub',//下标
  285. 'bulletedList',//序号
  286. 'numberedList',//序号
  287. 'uploadVideo',//上传视频
  288. 'codeBlock',
  289. 'insertTable',//表格
  290. 'divider',//分割线
  291. 'undo',//撤销
  292. 'redo',//重做
  293. 'fullScreen',//全屏
  294. ]}
  295. const toolbar = createToolbar({
  296. editor,
  297. selector: '#tool-".$id."',
  298. config: toolbarConfig,
  299. mode: 'default', // or 'simple'
  300. })
  301. $('#w-e-textarea-1').css('min-height','$height');
  302. </script>
  303. ";
  304. ;}
  305. function p($arr){
  306. echo "<pre>";print_r($arr);echo "<pre>";
  307. exit;
  308. }
  309. /* End of file Common.php */
  310. /* Location: ./app/libraries/Common.php */