Common.php 12 KB

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