Common.php 11 KB

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