Common.php 10 KB

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