Common.php 11 KB

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