ecshop物料库藏管理

WBOY
Freigeben: 2016-06-13 12:14:40
Original
1058 Leute haben es durchsucht

ecshop物料库存管理

1、创建物流库存表。sql语句:

CREATE TABLE IF NOT EXISTS `emws_materials` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL,
`modulus` varchar(60) NOT NULL,
`stock_number` smallint(5) unsigned NOT NULL default '0',
`stock_in` smallint(5) unsigned NOT NULL default '0',
`stock_out` smallint(5) unsigned NOT NULL default '0',
`safe_day` smallint(5) unsigned NOT NULL default '0',
`intent_day` smallint(5) unsigned NOT NULL default '0',
`is_buy` tinyint(1) unsigned NOT NULL default '1',
`buy_url` varchar(60) NOT NULL,
`price` decimal(10,2) NOT NULL,
`weight` smallint(5) unsigned NOT NULL default '0',
`img` varchar(60) NOT NULL,
`desc_info` varchar(60) NOT NULL,
`remark` varchar(60) NOT NULL,
`admin_id` smallint(5) unsigned NOT NULL,
`update_time` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

 

2、php程序,materials.php:

<span style="color: #008080;">  1</span> <span style="color: #000000;">php</span><span style="color: #008080;">  2</span> <span style="color: #008080;">define</span>('IN_ECS', <span style="color: #0000ff;">true</span><span style="color: #000000;">);</span><span style="color: #008080;">  3</span> <span style="color: #0000ff;">require</span>(<span style="color: #008080;">dirname</span>(<span style="color: #ff00ff;">__FILE__</span>) . '/includes/init.php'<span style="color: #000000;">);</span><span style="color: #008080;">  4</span> <span style="color: #0000ff;">include_once</span>(ROOT_PATH . 'includes/cls_image.php'<span style="color: #000000;">);</span><span style="color: #008080;">  5</span> <span style="color: #800080;">$image</span> = <span style="color: #0000ff;">new</span> cls_image(<span style="color: #800080;">$_CFG</span>['bgcolor'<span style="color: #000000;">]);</span><span style="color: #008080;">  6</span> <span style="color: #800080;">$exc</span> = <span style="color: #0000ff;">new</span> exchange(<span style="color: #800080;">$ecs</span>->table("materials"), <span style="color: #800080;">$db</span>, 'id', 'name'<span style="color: #000000;">);</span><span style="color: #008080;">  7</span> <span style="color: #800080;">$_REQUEST</span>['act']=!<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_REQUEST</span>['act']) ? <span style="color: #800080;">$_REQUEST</span>['act']:'list'<span style="color: #000000;">;</span><span style="color: #008080;">  8</span> admin_priv('stock_alert');<span style="color: #008000;">//</span><span style="color: #008000;">权限:库存数量修改</span><span style="color: #008080;">  9</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$_REQUEST</span>['act'] == 'list'<span style="color: #000000;">)</span><span style="color: #008080;"> 10</span> <span style="color: #000000;">{</span><span style="color: #008080;"> 11</span>     <span style="color: #800080;">$stock_list</span>=<span style="color: #000000;">material_list();</span><span style="color: #008080;"> 12</span>     <span style="color: #800080;">$smarty</span>->assign('ur_here',      '物料库存列表'<span style="color: #000000;">);</span><span style="color: #008080;"> 13</span>     <span style="color: #800080;">$smarty</span>->assign('stock_list',     <span style="color: #800080;">$stock_list</span>['stock_list'<span style="color: #000000;">]);</span><span style="color: #008080;"> 14</span>     <span style="color: #800080;">$smarty</span>->assign('filter',       <span style="color: #800080;">$stock_list</span>['filter'<span style="color: #000000;">]);</span><span style="color: #008080;"> 15</span>     <span style="color: #800080;">$smarty</span>->assign('record_count', <span style="color: #800080;">$stock_list</span>['record_count'<span style="color: #000000;">]);</span><span style="color: #008080;"> 16</span>     <span style="color: #800080;">$smarty</span>->assign('page_count',   <span style="color: #800080;">$stock_list</span>['page_count'<span style="color: #000000;">]);</span><span style="color: #008080;"> 17</span>     <span style="color: #008080;"> 18</span>     <span style="color: #800080;">$smarty</span>->assign('shelf_list',     <span style="color: #800080;">$shelf_list</span><span style="color: #000000;">);</span><span style="color: #008080;"> 19</span>     <span style="color: #800080;">$smarty</span>->assign('full_page',    1<span style="color: #000000;">);</span><span style="color: #008080;"> 20</span>     <span style="color: #800080;">$smarty</span>->assign('action_link',  <span style="color: #0000ff;">array</span>('href' => 'goods_stock.php?act=list', 'text' => '商品库存列表'<span style="color: #000000;">));</span><span style="color: #008080;"> 21</span>     <span style="color: #800080;">$smarty</span>->assign('action_link2',  <span style="color: #0000ff;">array</span>('href' => 'materials.php?act=export', 'text' => '导出采购单'<span style="color: #000000;">));</span><span style="color: #008080;"> 22</span>     <span style="color: #800080;">$smarty</span>->assign('action_link3',  <span style="color: #0000ff;">array</span>('href' => 'materials.php?act=add', 'text' => '添加物料'<span style="color: #000000;">));</span><span style="color: #008080;"> 23</span>     <span style="color: #008080;"> 24</span>     <span style="color: #800080;">$smarty</span>->display('material_list.htm'<span style="color: #000000;">);</span><span style="color: #008080;"> 25</span> <span style="color: #000000;">}</span><span style="color: #008080;"> 26</span> <span style="color: #0000ff;">elseif</span>(<span style="color: #800080;">$_REQUEST</span>['act'] == 'add'<span style="color: #000000;">)</span><span style="color: #008080;"> 27</span> <span style="color: #000000;">{    </span><span style="color: #008080;"> 28</span>     <span style="color: #800080;">$smarty</span>->assign('ur_here',      "添加物料"<span style="color: #000000;">);</span><span style="color: #008080;"> 29</span>     <span style="color: #800080;">$smarty</span>->assign('action_link', <span style="color: #0000ff;">array</span>('href' => 'materials.php?act=list', 'text' => '返回物料库存列表'<span style="color: #000000;">));</span><span style="color: #008080;"> 30</span>     <span style="color: #800080;">$smarty</span>->assign('form_action', "insert"<span style="color: #000000;">);</span><span style="color: #008080;"> 31</span> <span style="color: #008080;"> 32</span> <span style="color: #000000;">    assign_query_info();</span><span style="color: #008080;"> 33</span>     <span style="color: #800080;">$smarty</span>->display('material_info.htm'<span style="color: #000000;">);</span><span style="color: #008080;"> 34</span> <span style="color: #000000;">}</span><span style="color: #008080;"> 35</span> <span style="color: #0000ff;">elseif</span>(<span style="color: #800080;">$_REQUEST</span>['act'] == 'insert'<span style="color: #000000;">)</span><span style="color: #008080;"> 36</span> <span style="color: #000000;">{</span><span style="color: #008080;"> 37</span>     <span style="color: #800080;">$material</span>['is_buy']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['is_buy']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['is_buy']) : 1<span style="color: #000000;">;</span><span style="color: #008080;"> 38</span>     <span style="color: #800080;">$material</span>['name']      = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['name']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['name']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 39</span>     <span style="color: #800080;">$material</span>['modulus']   = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['modulus']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['modulus']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 40</span>     <span style="color: #800080;">$material</span>['safe_day']  = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['safe_day']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['safe_day']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 41</span>     <span style="color: #800080;">$material</span>['intent_day']= <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['intent_day']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['intent_day']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 42</span>     <span style="color: #800080;">$material</span>['price']     = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['price']) ? <span style="color: #008080;">floatval</span>(<span style="color: #800080;">$_REQUEST</span>['price']) : '0.00'<span style="color: #000000;">;</span><span style="color: #008080;"> 43</span>     <span style="color: #800080;">$material</span>['weight']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['weight']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['weight']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 44</span>     <span style="color: #800080;">$material</span>['desc_info'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['desc_info']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['desc_info']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 45</span>     <span style="color: #800080;">$material</span>['remark']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['remark']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['remark']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 46</span>     <span style="color: #800080;">$material</span>['update_time']=<span style="color: #000000;"> gmtime();</span><span style="color: #008080;"> 47</span>     <span style="color: #800080;">$material</span>['admin_id']   = <span style="color: #800080;">$_SESSION</span>['admin_id'<span style="color: #000000;">];</span><span style="color: #008080;"> 48</span>     <span style="color: #008080;"> 49</span>     <span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['name']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['modulus']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['safe_day']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['intent_day'<span style="color: #000000;">]))</span><span style="color: #008080;"> 50</span> <span style="color: #000000;">    {</span><span style="color: #008080;"> 51</span>         sys_msg('名称、系数、安全天数、目标天数,不能为空或者格式不正确', 1<span style="color: #000000;">);</span><span style="color: #008080;"> 52</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 53</span>     <span style="color: #008080;"> 54</span>     <span style="color: #800080;">$is_only</span> = <span style="color: #800080;">$exc</span>->is_only('name', <span style="color: #800080;">$material</span>['name'<span style="color: #000000;">]);</span><span style="color: #008080;"> 55</span>     <span style="color: #0000ff;">if</span> (!<span style="color: #800080;">$is_only</span><span style="color: #000000;">)</span><span style="color: #008080;"> 56</span> <span style="color: #000000;">    {</span><span style="color: #008080;"> 57</span>         sys_msg(<span style="color: #800080;">$material</span>['name'].',已存在', 1<span style="color: #000000;">);</span><span style="color: #008080;"> 58</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 59</span> <span style="color: #008080;"> 60</span>      <span style="color: #008000;">/*</span><span style="color: #008000;">处理图片</span><span style="color: #008000;">*/</span><span style="color: #008080;"> 61</span>     <span style="color: #800080;">$material</span>['img'] = <span style="color: #008080;">basename</span>(<span style="color: #800080;">$image</span>->upload_image(<span style="color: #800080;">$_FILES</span>['img'],'material'<span style="color: #000000;">));</span><span style="color: #008080;"> 62</span>      <span style="color: #008000;">/*</span><span style="color: #008000;">处理URL</span><span style="color: #008000;">*/</span><span style="color: #008080;"> 63</span>     <span style="color: #800080;">$material</span>['buy_url'] = sanitize_url(<span style="color: #800080;">$_POST</span>['buy_url'<span style="color: #000000;">]);</span><span style="color: #008080;"> 64</span>     <span style="color: #008000;">/*</span><span style="color: #008000;">插入数据</span><span style="color: #008000;">*/</span><span style="color: #008080;"> 65</span>     <span style="color: #800080;">$db</span>->autoExecute(<span style="color: #800080;">$ecs</span>->table('materials'), <span style="color: #800080;">$material</span>, 'INSERT', '', 'SILENT'<span style="color: #000000;">);</span><span style="color: #008080;"> 66</span> <span style="color: #008080;"> 67</span>     <span style="color: #800080;">$link</span>[0]['text'] = '继续添加'<span style="color: #000000;">;</span><span style="color: #008080;"> 68</span>     <span style="color: #800080;">$link</span>[0]['href'] = 'materials.php?act=add'<span style="color: #000000;">;</span><span style="color: #008080;"> 69</span>     <span style="color: #800080;">$link</span>[1]['text'] = '返回列表'<span style="color: #000000;">;</span><span style="color: #008080;"> 70</span>     <span style="color: #800080;">$link</span>[1]['href'] = 'materials.php?act=list'<span style="color: #000000;">;</span><span style="color: #008080;"> 71</span>     sys_msg('添加成功', 0, <span style="color: #800080;">$link</span><span style="color: #000000;">);</span><span style="color: #008080;"> 72</span> <span style="color: #000000;">}</span><span style="color: #008080;"> 73</span> <span style="color: #0000ff;">elseif</span>(<span style="color: #800080;">$_REQUEST</span>['act'] == 'updata'<span style="color: #000000;">)</span><span style="color: #008080;"> 74</span> <span style="color: #000000;">{</span><span style="color: #008080;"> 75</span>     <span style="color: #800080;">$id</span>    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['id']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['id']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 76</span>     <span style="color: #800080;">$material</span>['is_buy']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['is_buy']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['is_buy']) : 1<span style="color: #000000;">;</span><span style="color: #008080;"> 77</span>     <span style="color: #800080;">$material</span>['name']      = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['name']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['name']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 78</span>     <span style="color: #800080;">$material</span>['modulus']   = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['modulus']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['modulus']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 79</span>     <span style="color: #800080;">$material</span>['safe_day']  = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['safe_day']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['safe_day']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 80</span>     <span style="color: #800080;">$material</span>['intent_day']= <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['intent_day']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['intent_day']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 81</span>     <span style="color: #800080;">$material</span>['price']     = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['price']) ? <span style="color: #008080;">floatval</span>(<span style="color: #800080;">$_REQUEST</span>['price']) : '0.00'<span style="color: #000000;">;</span><span style="color: #008080;"> 82</span>     <span style="color: #800080;">$material</span>['weight']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['weight']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['weight']) : 0<span style="color: #000000;">;</span><span style="color: #008080;"> 83</span>     <span style="color: #800080;">$material</span>['desc_info'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['desc_info']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['desc_info']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 84</span>     <span style="color: #800080;">$material</span>['remark']    = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['remark']) ? <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['remark']) : ''<span style="color: #000000;">;</span><span style="color: #008080;"> 85</span>     <span style="color: #800080;">$material</span>['update_time']=<span style="color: #000000;"> gmtime();</span><span style="color: #008080;"> 86</span>     <span style="color: #800080;">$material</span>['admin_id']   = <span style="color: #800080;">$_SESSION</span>['admin_id'<span style="color: #000000;">];</span><span style="color: #008080;"> 87</span>     <span style="color: #008080;"> 88</span>     <span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$id</span><span style="color: #000000;">))</span><span style="color: #008080;"> 89</span> <span style="color: #000000;">    {</span><span style="color: #008080;"> 90</span>         sys_msg('ID不能为空', 1<span style="color: #000000;">);</span><span style="color: #008080;"> 91</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 92</span>     <span style="color: #008080;"> 93</span>     <span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['name']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['modulus']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['safe_day']) || <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$material</span>['intent_day'<span style="color: #000000;">]))</span><span style="color: #008080;"> 94</span> <span style="color: #000000;">    {</span><span style="color: #008080;"> 95</span>         sys_msg('名称、系数、安全天数、目标天数,不能为空或者格式不正确', 1<span style="color: #000000;">);</span><span style="color: #008080;"> 96</span> <span style="color: #000000;">    }</span><span style="color: #008080;"> 97</span> <span style="color: #008080;"> 98</span>      <span style="color: #008000;">/*</span><span style="color: #008000;">处理图片</span><span style="color: #008000;">*/</span><span style="color: #008080;"> 99</span>      <span style="color: #0000ff;">if</span>(!<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_FILES</span>['img']['name'<span style="color: #000000;">]))</span><span style="color: #008080;">100</span> <span style="color: #000000;">     {</span><span style="color: #008080;">101</span>         <span style="color: #800080;">$material</span>['img'] = <span style="color: #008080;">basename</span>(<span style="color: #800080;">$image</span>->upload_image(<span style="color: #800080;">$_FILES</span>['img'],'material'<span style="color: #000000;">));</span><span style="color: #008080;">102</span> <span style="color: #000000;">     }</span><span style="color: #008080;">103</span>      <span style="color: #008000;">/*</span><span style="color: #008000;">处理URL</span><span style="color: #008000;">*/</span><span style="color: #008080;">104</span>     <span style="color: #800080;">$material</span>['buy_url'] = sanitize_url(<span style="color: #800080;">$_POST</span>['buy_url'<span style="color: #000000;">]);</span><span style="color: #008080;">105</span>     <span style="color: #008000;">/*</span><span style="color: #008000;">插入数据</span><span style="color: #008000;">*/</span><span style="color: #008080;">106</span>     <span style="color: #800080;">$db</span>->autoExecute(<span style="color: #800080;">$ecs</span>->table('materials'), <span style="color: #800080;">$material</span>, 'UPDATE', "id = '<span style="color: #800080;">$id</span>'"<span style="color: #000000;">);</span><span style="color: #008080;">107</span> <span style="color: #008080;">108</span>     <span style="color: #800080;">$link</span>[0]['text'] = '继续编辑'<span style="color: #000000;">;</span><span style="color: #008080;">109</span>     <span style="color: #800080;">$link</span>[0]['href'] = 'materials.php?act=edit&id='.<span style="color: #800080;">$id</span><span style="color: #000000;">;</span><span style="color: #008080;">110</span>     <span style="color: #800080;">$link</span>[1]['text'] = '返回列表'<span style="color: #000000;">;</span><span style="color: #008080;">111</span>     <span style="color: #800080;">$link</span>[1]['href'] = 'materials.php?act=list'<span style="color: #000000;">;</span><span style="color: #008080;">112</span>     sys_msg('编辑成功', 0, <span style="color: #800080;">$link</span><span style="color: #000000;">);</span><span style="color: #008080;">113</span> <span style="color: #000000;">}</span><span style="color: #008080;">114</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] =='edit'<span style="color: #000000;">)</span><span style="color: #008080;">115</span> <span style="color: #000000;">{</span><span style="color: #008080;">116</span>     <span style="color: #800080;">$sql</span> = "SELECT * FROM " .<span style="color: #800080;">$ecs</span>->table('materials'). " WHERE id='<span style="color: #800080;">$_REQUEST</span>[id]'"<span style="color: #000000;">;</span><span style="color: #008080;">117</span>     <span style="color: #800080;">$material</span> = <span style="color: #800080;">$db</span>->GetRow(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">118</span>     <span style="color: #800080;">$smarty</span>->assign('ur_here',     "编辑物料"<span style="color: #000000;">);</span><span style="color: #008080;">119</span>     <span style="color: #800080;">$smarty</span>->assign('action_link', <span style="color: #0000ff;">array</span>('href' => 'materials.php?act=list', 'text' => '返回物料库存列表'<span style="color: #000000;">));</span><span style="color: #008080;">120</span>     <span style="color: #800080;">$smarty</span>->assign('material',    <span style="color: #800080;">$material</span><span style="color: #000000;">);</span><span style="color: #008080;">121</span>     <span style="color: #800080;">$smarty</span>->assign('form_action', 'updata'<span style="color: #000000;">);</span><span style="color: #008080;">122</span> <span style="color: #000000;">    assign_query_info();</span><span style="color: #008080;">123</span>     <span style="color: #800080;">$smarty</span>->display('material_info.htm'<span style="color: #000000;">);</span><span style="color: #008080;">124</span> <span style="color: #000000;">}</span><span style="color: #008080;">125</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'remove'<span style="color: #000000;">)</span><span style="color: #008080;">126</span> <span style="color: #000000;">{</span><span style="color: #008080;">127</span>     <span style="color: #800080;">$id</span> = <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_GET</span>['id'<span style="color: #000000;">]);</span><span style="color: #008080;">128</span>     <span style="color: #800080;">$exc</span>->drop(<span style="color: #800080;">$id</span><span style="color: #000000;">);</span><span style="color: #008080;">129</span>     <span style="color: #800080;">$url</span> = 'materials.php?act=query&' . <span style="color: #008080;">str_replace</span>('act=remove', '', <span style="color: #800080;">$_SERVER</span>['QUERY_STRING'<span style="color: #000000;">]);</span><span style="color: #008080;">130</span>     ecs_header("Location: <span style="color: #800080;">$url</span>\n"<span style="color: #000000;">);</span><span style="color: #008080;">131</span>     <span style="color: #0000ff;">exit</span><span style="color: #000000;">;</span><span style="color: #008080;">132</span> <span style="color: #000000;">}</span><span style="color: #008080;">133</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'drop_img'<span style="color: #000000;">)</span><span style="color: #008080;">134</span> <span style="color: #000000;">{</span><span style="color: #008080;">135</span>     <span style="color: #800080;">$id</span> = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_GET</span>['id']) ? <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_GET</span>['id']) : 0<span style="color: #000000;">;</span><span style="color: #008080;">136</span> <span style="color: #008080;">137</span>     <span style="color: #800080;">$sql</span> = "SELECT img FROM " .<span style="color: #800080;">$ecs</span>->table('materials'). " WHERE id = '<span style="color: #800080;">$id</span>'"<span style="color: #000000;">;</span><span style="color: #008080;">138</span>     <span style="color: #800080;">$img_name</span> = <span style="color: #800080;">$db</span>->getOne(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">139</span> <span style="color: #008080;">140</span>     <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$img_name</span><span style="color: #000000;">))</span><span style="color: #008080;">141</span> <span style="color: #000000;">    {</span><span style="color: #008080;">142</span>         @<span style="color: #008080;">unlink</span>(ROOT_PATH . DATA_DIR . '/material/' .<span style="color: #800080;">$img_name</span><span style="color: #000000;">);</span><span style="color: #008080;">143</span>         <span style="color: #800080;">$sql</span> = "UPDATE " .<span style="color: #800080;">$ecs</span>->table('materials'). " SET img = '' WHERE id = '<span style="color: #800080;">$id</span>'"<span style="color: #000000;">;</span><span style="color: #008080;">144</span>         <span style="color: #800080;">$db</span>->query(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">145</span> <span style="color: #000000;">    }</span><span style="color: #008080;">146</span>     <span style="color: #800080;">$link</span>= <span style="color: #0000ff;">array</span>(<span style="color: #0000ff;">array</span>('text' => '继续编辑', 'href' => 'materials.php?act=edit&id=' . <span style="color: #800080;">$id</span>), <span style="color: #0000ff;">array</span>('text' => '返回物料库存列表', 'href' => 'materials.php?act=list'<span style="color: #000000;">));</span><span style="color: #008080;">147</span>     sys_msg('图片删除成功', 0, <span style="color: #800080;">$link</span><span style="color: #000000;">);</span><span style="color: #008080;">148</span> <span style="color: #000000;">}    </span><span style="color: #008080;">149</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'edit_stock_in') <span style="color: #008000;">//</span><span style="color: #008000;">更改入库</span><span style="color: #008080;">150</span> <span style="color: #000000;">{</span><span style="color: #008080;">151</span>     <span style="color: #800080;">$id</span> = <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_POST</span>['id'<span style="color: #000000;">]);</span><span style="color: #008080;">152</span>     <span style="color: #800080;">$val</span> = json_str_iconv(<span style="color: #008080;">trim</span>(<span style="color: #800080;">$_POST</span>['val'<span style="color: #000000;">]));</span><span style="color: #008080;">153</span>     <span style="color: #008000;">/*</span><span style="color: #008000;"> 检查格式 </span><span style="color: #008000;">*/</span><span style="color: #008080;">154</span>     <span style="color: #0000ff;">if</span>(!<span style="color: #008080;">is_numeric</span>(<span style="color: #800080;">$val</span>) || <span style="color: #800080;">$val</span> )<span style="color: #008080;">155</span> <span style="color: #000000;">    {</span><span style="color: #008080;">156</span>         make_json_error(<span style="color: #008080;">sprintf</span>("格式不正确!",  <span style="color: #800080;">$val</span><span style="color: #000000;">));</span><span style="color: #008080;">157</span> <span style="color: #000000;">    }</span><span style="color: #008080;">158</span>     <span style="color: #008080;">159</span>     <span style="color: #800080;">$exc</span>->edit("stock_in='<span style="color: #800080;">$val</span>'", <span style="color: #800080;">$id</span><span style="color: #000000;">);</span><span style="color: #008080;">160</span>     make_json_result(<span style="color: #008080;">stripslashes</span>(<span style="color: #800080;">$val</span><span style="color: #000000;">));</span><span style="color: #008080;">161</span> <span style="color: #000000;">}</span><span style="color: #008080;">162</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'edit_stock_out') <span style="color: #008000;">//</span><span style="color: #008000;">更改出库</span><span style="color: #008080;">163</span> <span style="color: #000000;">{</span><span style="color: #008080;">164</span>     <span style="color: #800080;">$id</span> = <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_POST</span>['id'<span style="color: #000000;">]);</span><span style="color: #008080;">165</span>     <span style="color: #800080;">$val</span> = json_str_iconv(<span style="color: #008080;">trim</span>(<span style="color: #800080;">$_POST</span>['val'<span style="color: #000000;">]));</span><span style="color: #008080;">166</span>     <span style="color: #008000;">/*</span><span style="color: #008000;"> 检查格式 </span><span style="color: #008000;">*/</span><span style="color: #008080;">167</span>     <span style="color: #0000ff;">if</span>(!<span style="color: #008080;">is_numeric</span>(<span style="color: #800080;">$val</span>) || <span style="color: #800080;">$val</span> )<span style="color: #008080;">168</span> <span style="color: #000000;">    {</span><span style="color: #008080;">169</span>         make_json_error(<span style="color: #008080;">sprintf</span>("格式不正确!",  <span style="color: #800080;">$val</span><span style="color: #000000;">));</span><span style="color: #008080;">170</span> <span style="color: #000000;">    }</span><span style="color: #008080;">171</span>     <span style="color: #800080;">$sql</span>="SELECT * FROM ".<span style="color: #800080;">$GLOBALS</span>['ecs']->table('materials')." where id = '".<span style="color: #800080;">$id</span>."'"<span style="color: #000000;">;</span><span style="color: #008080;">172</span>     <span style="color: #800080;">$material</span> = <span style="color: #800080;">$GLOBALS</span>['db']->getRow(<span style="color: #800080;">$sql</span><span style="color: #000000;">); </span><span style="color: #008080;">173</span>     <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$val</span> > <span style="color: #800080;">$material</span>['stock_in'] + <span style="color: #800080;">$material</span>['stock_number'<span style="color: #000000;">])</span><span style="color: #008080;">174</span> <span style="color: #000000;">    {</span><span style="color: #008080;">175</span>         make_json_error(<span style="color: #008080;">sprintf</span>("出库数不能大于现有库存与入库总和!",  <span style="color: #800080;">$val</span><span style="color: #000000;">));</span><span style="color: #008080;">176</span> <span style="color: #000000;">    }</span><span style="color: #008080;">177</span>     <span style="color: #008080;">178</span>     <span style="color: #800080;">$exc</span>->edit("stock_out='<span style="color: #800080;">$val</span>'", <span style="color: #800080;">$id</span><span style="color: #000000;">);</span><span style="color: #008080;">179</span>     make_json_result(<span style="color: #008080;">stripslashes</span>(<span style="color: #800080;">$val</span><span style="color: #000000;">));</span><span style="color: #008080;">180</span> <span style="color: #000000;">}</span><span style="color: #008080;">181</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'operate') <span style="color: #008000;">//</span><span style="color: #008000;">批量入库/出库</span><span style="color: #008080;">182</span> <span style="color: #000000;">{</span><span style="color: #008080;">183</span>     <span style="color: #800080;">$sql</span> = "UPDATE " .<span style="color: #800080;">$ecs</span>->table('materials'). " SET stock_number = stock_number + stock_in - stock_out,stock_out = 0,stock_in = 0,admin_id=<span style="color: #800080;">$_SESSION</span>[admin_id],update_time = ".<span style="color: #000000;">gmtime();</span><span style="color: #008080;">184</span>     <span style="color: #800080;">$db</span>->query(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">185</span>     <span style="color: #800080;">$link</span>= <span style="color: #0000ff;">array</span>(<span style="color: #0000ff;">array</span>('text' => '返回物料库存列表', 'href' => 'materials.php?act=list'<span style="color: #000000;">));</span><span style="color: #008080;">186</span>     sys_msg('成功批量入库/出库', 0, <span style="color: #800080;">$link</span><span style="color: #000000;">);</span><span style="color: #008080;">187</span> <span style="color: #000000;">}</span><span style="color: #008080;">188</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'export') <span style="color: #008000;">//</span><span style="color: #008000;">导出采购单</span><span style="color: #008080;">189</span> <span style="color: #000000;">{</span><span style="color: #008080;">190</span>     <span style="color: #0000ff;">include_once</span>('includes/PHPExcel/PHPExcel.php'<span style="color: #000000;">);</span><span style="color: #008080;">191</span>     <span style="color: #0000ff;">include_once</span>('corlor.php'<span style="color: #000000;">);</span><span style="color: #008080;">192</span>     <span style="color: #800080;">$objPHPExcel</span> = <span style="color: #0000ff;">new</span><span style="color: #000000;"> PHPExcel();</span><span style="color: #008080;">193</span> <span style="color: #008080;">194</span>     <span style="color: #800080;">$filename</span> = '物料采购表_'.<span style="color: #008080;">date</span>("YmdHi",<span style="color: #000000;">gmtime());</span><span style="color: #008080;">195</span>     <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0<span style="color: #000000;">);</span><span style="color: #008080;">196</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->setTitle(<span style="color: #800080;">$filename</span><span style="color: #000000;">);</span><span style="color: #008080;">197</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('A')->setWidth(15<span style="color: #000000;">);</span><span style="color: #008080;">198</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('B')->setWidth(15<span style="color: #000000;">);</span><span style="color: #008080;">199</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('C')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">200</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('D')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">201</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('E')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">202</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('F')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">203</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('G')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">204</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('H')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">205</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('I')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">206</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('J')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">207</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('C1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">208</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('D1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">209</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('F1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">210</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('G1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">211</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('H1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">212</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('I1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">213</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::<span style="color: #000000;">HORIZONTAL_RIGHT);</span><span style="color: #008080;">214</span>     <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getColumnDimension('K')->setWidth(10<span style="color: #000000;">);</span><span style="color: #008080;">215</span>     <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0<span style="color: #000000;">)</span><span style="color: #008080;">216</span>     ->setCellValue('A1', '物料名称'<span style="color: #000000;">)</span><span style="color: #008080;">217</span>     ->setCellValue('B1', '图片'<span style="color: #000000;">)    </span><span style="color: #008080;">218</span>     ->setCellValue('C1', '每天用量'<span style="color: #000000;">)</span><span style="color: #008080;">219</span>     ->setCellValue('D1', '现有库存'<span style="color: #000000;">)</span><span style="color: #008080;">220</span>     ->setCellValue('E1', '周转天数'<span style="color: #000000;">)</span><span style="color: #008080;">221</span>     ->setCellValue('F1', '安全库存'<span style="color: #000000;">)</span><span style="color: #008080;">222</span>     ->setCellValue('G1', '目标库存'<span style="color: #000000;">)</span><span style="color: #008080;">223</span>     ->setCellValue('H1', '建议购买'<span style="color: #000000;">)</span><span style="color: #008080;">224</span>     ->setCellValue('I1', '单价'<span style="color: #000000;">)</span><span style="color: #008080;">225</span>     ->setCellValue('J1', '实际单价'<span style="color: #000000;">)</span><span style="color: #008080;">226</span>     ->setCellValue('K1', '采购链接'<span style="color: #000000;">);</span><span style="color: #008080;">227</span>     <span style="color: #800080;">$i</span>=2<span style="color: #000000;">;</span><span style="color: #008080;">228</span>     <span style="color: #800080;">$stock_list</span> = material_list(<span style="color: #0000ff;">false</span><span style="color: #000000;">);</span><span style="color: #008080;">229</span>     <span style="color: #800080;">$arr</span> = <span style="color: #800080;">$stock_list</span>['stock_list'<span style="color: #000000;">];</span><span style="color: #008080;">230</span>     <span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$arr</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$v</span><span style="color: #000000;">)</span><span style="color: #008080;">231</span> <span style="color: #000000;">    {</span><span style="color: #008080;">232</span>         <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$v</span>['img'<span style="color: #000000;">])</span><span style="color: #008080;">233</span> <span style="color: #000000;">        {</span><span style="color: #008080;">234</span>             <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getRowDimension(<span style="color: #800080;">$i</span>)->setRowHeight(50<span style="color: #000000;">);</span><span style="color: #008080;">235</span>             <span style="color: #800080;">$objDrawing</span> = <span style="color: #0000ff;">new</span><span style="color: #000000;"> PHPExcel_Worksheet_Drawing();</span><span style="color: #008080;">236</span>             <span style="color: #800080;">$objDrawing</span>->setName('goods thumb'<span style="color: #000000;">);</span><span style="color: #008080;">237</span>             <span style="color: #800080;">$objDrawing</span>->setDescription('Pgoods thumb'<span style="color: #000000;">);</span><span style="color: #008080;">238</span>             <span style="color: #800080;">$img_path</span> = <span style="color: #008080;">file_exists</span>('../data/material/'.<span style="color: #800080;">$v</span>['img']) ? '../data/material/'.<span style="color: #800080;">$v</span>['img'] : '../images/no_img.jpg'<span style="color: #000000;">;</span><span style="color: #008080;">239</span>             <span style="color: #800080;">$objDrawing</span>->setPath(<span style="color: #800080;">$img_path</span><span style="color: #000000;">);</span><span style="color: #008080;">240</span>             <span style="color: #800080;">$objDrawing</span>->setWidth(100<span style="color: #000000;">);</span><span style="color: #008080;">241</span>             <span style="color: #800080;">$objDrawing</span>->setCoordinates('B'.<span style="color: #800080;">$i</span><span style="color: #000000;">);</span><span style="color: #008080;">242</span>             <span style="color: #800080;">$objDrawing</span>->setWorksheet(<span style="color: #800080;">$objPHPExcel</span>-><span style="color: #000000;">getActiveSheet());</span><span style="color: #008080;">243</span> <span style="color: #000000;">        }</span><span style="color: #008080;">244</span>         <span style="color: #0000ff;">else</span><span style="color: #008080;">245</span> <span style="color: #000000;">        {</span><span style="color: #008080;">246</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->setCellValue('B'.<span style="color: #800080;">$i</span>, ''<span style="color: #000000;">);    </span><span style="color: #008080;">247</span> <span style="color: #000000;">        }</span><span style="color: #008080;">248</span> <span style="color: #008080;">249</span>         <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0<span style="color: #000000;">)</span><span style="color: #008080;">250</span>             ->setCellValue('A'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['name'<span style="color: #000000;">])</span><span style="color: #008080;">251</span>             ->setCellValue('C'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['day_use'<span style="color: #000000;">])</span><span style="color: #008080;">252</span>             ->setCellValue('D'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['stock_number'<span style="color: #000000;">])</span><span style="color: #008080;">253</span>             ->setCellValue('E'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['stock_day'<span style="color: #000000;">])</span><span style="color: #008080;">254</span>             ->setCellValue('F'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['stock_safe'<span style="color: #000000;">])</span><span style="color: #008080;">255</span>             ->setCellValue('G'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['stock_intent'<span style="color: #000000;">])</span><span style="color: #008080;">256</span>             ->setCellValue('H'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['proposal_buy'<span style="color: #000000;">])</span><span style="color: #008080;">257</span>             ->setCellValue('I'.<span style="color: #800080;">$i</span>, <span style="color: #800080;">$v</span>['price'<span style="color: #000000;">])</span><span style="color: #008080;">258</span>             ->setCellValue('J'.<span style="color: #800080;">$i</span>, ''<span style="color: #000000;">);</span><span style="color: #008080;">259</span>         <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$v</span>['stock_safe'] >= <span style="color: #800080;">$v</span>['stock_number'<span style="color: #000000;">])</span><span style="color: #008080;">260</span> <span style="color: #000000;">        {</span><span style="color: #008080;">261</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->getStyle('D'.<span style="color: #800080;">$i</span>)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::<span style="color: #000000;">COLOR_RED);</span><span style="color: #008080;">262</span> <span style="color: #000000;">        }</span><span style="color: #008080;">263</span>         <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$v</span>['buy_url'] != 'http://'<span style="color: #000000;">)</span><span style="color: #008080;">264</span> <span style="color: #000000;">        {</span><span style="color: #008080;">265</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->setCellValue('K'.<span style="color: #800080;">$i</span>, '采购链接'<span style="color: #000000;">);</span><span style="color: #008080;">266</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->getCell('K'.<span style="color: #800080;">$i</span>)->getHyperlink()->setUrl(<span style="color: #800080;">$v</span>['buy_url'<span style="color: #000000;">]);</span><span style="color: #008080;">267</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->getCell('K'.<span style="color: #800080;">$i</span>)->getHyperlink()->setTooltip('采购链接'<span style="color: #000000;">);</span><span style="color: #008080;">268</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->getStyle('K'.<span style="color: #800080;">$i</span>)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::<span style="color: #000000;">COLOR_BLUE);</span><span style="color: #008080;">269</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->getStyle('K'.<span style="color: #800080;">$i</span>)->getFont()->setUnderline(PHPExcel_Style_Font::<span style="color: #000000;">UNDERLINE_SINGLE);</span><span style="color: #008080;">270</span> <span style="color: #000000;">        }</span><span style="color: #008080;">271</span>         <span style="color: #0000ff;">else</span><span style="color: #008080;">272</span> <span style="color: #000000;">        {</span><span style="color: #008080;">273</span>             <span style="color: #800080;">$objPHPExcel</span>->setActiveSheetIndex(0)->setCellValue('K'.<span style="color: #800080;">$i</span>, ''<span style="color: #000000;">);</span><span style="color: #008080;">274</span> <span style="color: #000000;">        }</span><span style="color: #008080;">275</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('A'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">276</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('B'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">277</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('C'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">278</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('D'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">279</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('E'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">280</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('F'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">281</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('G'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">282</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('H'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">283</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('I'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">284</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('J'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">285</span>         <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('K'.<span style="color: #800080;">$i</span>)->getAlignment()->setVertical(PHPExcel_Style_Alignment::<span style="color: #000000;">VERTICAL_CENTER);</span><span style="color: #008080;">286</span>         <span style="color: #800080;">$i</span>++<span style="color: #000000;">;</span><span style="color: #008080;">287</span> <span style="color: #000000;">    }</span><span style="color: #008080;">288</span>     <span style="color: #800080;">$file_name</span>    =    <span style="color: #800080;">$filename</span>.'.xls'<span style="color: #000000;">;</span><span style="color: #008080;">289</span>     <span style="color: #008080;">header</span>('Content-Type: application/vnd.ms-excel'<span style="color: #000000;">);</span><span style="color: #008080;">290</span>     <span style="color: #008080;">header</span>('Content-Disposition: attachment;filename="'.<span style="color: #800080;">$file_name</span>.'"'<span style="color: #000000;">);</span><span style="color: #008080;">291</span>     <span style="color: #008080;">header</span>('Cache-Control: max-age=0'<span style="color: #000000;">);</span><span style="color: #008080;">292</span>     <span style="color: #800080;">$objWriter</span> = PHPExcel_IOFactory::createWriter(<span style="color: #800080;">$objPHPExcel</span>, 'Excel5'<span style="color: #000000;">);</span><span style="color: #008080;">293</span>     <span style="color: #800080;">$objWriter</span>->save('php://output'<span style="color: #000000;">);</span><span style="color: #008080;">294</span>     <span style="color: #0000ff;">exit</span><span style="color: #000000;">;</span><span style="color: #008080;">295</span> <span style="color: #000000;">}</span><span style="color: #008080;">296</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'query'<span style="color: #000000;">)</span><span style="color: #008080;">297</span> <span style="color: #000000;">{    </span><span style="color: #008080;">298</span>     <span style="color: #800080;">$stock_list</span> =<span style="color: #000000;"> material_list();</span><span style="color: #008080;">299</span>     <span style="color: #800080;">$smarty</span>->assign('stock_list',     <span style="color: #800080;">$stock_list</span>['stock_list'<span style="color: #000000;">]);</span><span style="color: #008080;">300</span>     <span style="color: #800080;">$smarty</span>->assign('filter',       <span style="color: #800080;">$stock_list</span>['filter'<span style="color: #000000;">]);</span><span style="color: #008080;">301</span>     <span style="color: #800080;">$smarty</span>->assign('record_count', <span style="color: #800080;">$stock_list</span>['record_count'<span style="color: #000000;">]);</span><span style="color: #008080;">302</span>     <span style="color: #800080;">$smarty</span>->assign('page_count',   <span style="color: #800080;">$stock_list</span>['page_count'<span style="color: #000000;">]);</span><span style="color: #008080;">303</span>     make_json_result(<span style="color: #800080;">$smarty</span>->fetch('material_list.htm'), '', <span style="color: #0000ff;">array</span>('filter' => <span style="color: #800080;">$stock_list</span>['filter'], 'page_count' => <span style="color: #800080;">$stock_list</span>['page_count'<span style="color: #000000;">]));</span><span style="color: #008080;">304</span> <span style="color: #000000;">}</span><span style="color: #008080;">305</span> <span style="color: #008080;">306</span> <span style="color: #0000ff;">function</span> material_list(<span style="color: #800080;">$is_pagination</span> = <span style="color: #0000ff;">true</span><span style="color: #000000;">)</span><span style="color: #008080;">307</span> <span style="color: #000000;">{</span><span style="color: #008080;">308</span>     <span style="color: #0000ff;">GLOBAL</span> <span style="color: #800080;">$ecs</span>,<span style="color: #800080;">$db</span><span style="color: #000000;">;</span><span style="color: #008080;">309</span>     <span style="color: #800080;">$result</span> =<span style="color: #000000;"> get_filter();</span><span style="color: #008080;">310</span>     <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$result</span> === <span style="color: #0000ff;">false</span><span style="color: #000000;">)</span><span style="color: #008080;">311</span> <span style="color: #000000;">    {</span><span style="color: #008080;">312</span>         <span style="color: #800080;">$filter</span>['sort_by'] = <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_REQUEST</span>['sort_by']) ? 'id' : <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['sort_by'<span style="color: #000000;">]);</span><span style="color: #008080;">313</span>         <span style="color: #800080;">$filter</span>['sort_order'] = <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_REQUEST</span>['sort_order']) ? 'desc' : <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['sort_order'<span style="color: #000000;">]);</span><span style="color: #008080;">314</span>         <span style="color: #800080;">$where</span> = " WHERE 1 = 1 "<span style="color: #000000;">;</span><span style="color: #008080;">315</span> <span style="color: #008080;">316</span>         <span style="color: #800080;">$sql</span> = 'select count(t.id) from '.<span style="color: #800080;">$ecs</span>->table('materials'). ' as t '.<span style="color: #800080;">$where</span><span style="color: #000000;">;</span><span style="color: #008080;">317</span>         <span style="color: #008080;">318</span>         <span style="color: #800080;">$filter</span>['record_count'] = <span style="color: #800080;">$db</span>->getOne(<span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">319</span>         <span style="color: #008080;">320</span>         <span style="color: #008000;">/*</span><span style="color: #008000;"> 分页大小 </span><span style="color: #008000;">*/</span><span style="color: #008080;">321</span>         <span style="color: #800080;">$filter</span> = page_and_size(<span style="color: #800080;">$filter</span><span style="color: #000000;">);</span><span style="color: #008080;">322</span>         <span style="color: #008080;">323</span>         <span style="color: #800080;">$sql</span> = 'select t.*, au.user_name from '.<span style="color: #008080;">324</span>                 <span style="color: #800080;">$ecs</span>->table('materials').' as t left join '.<span style="color: #008080;">325</span>                 <span style="color: #800080;">$ecs</span>->table('admin_user')." as au on t.admin_id=au.user_id ".<span style="color: #800080;">$where</span>.<span style="color: #008080;">326</span>                 ' order by '.<span style="color: #800080;">$filter</span>['sort_by']." ".<span style="color: #800080;">$filter</span>['sort_order'<span style="color: #000000;">];</span><span style="color: #008080;">327</span>         <span style="color: #008080;">328</span>         <span style="color: #0000ff;">if</span> (<span style="color: #800080;">$is_pagination</span><span style="color: #000000;">)</span><span style="color: #008080;">329</span> <span style="color: #000000;">        {</span><span style="color: #008080;">330</span>             <span style="color: #800080;">$sql</span> .= " LIMIT " . <span style="color: #800080;">$filter</span>['start'] . ', ' . <span style="color: #800080;">$filter</span>['page_size'<span style="color: #000000;">];</span><span style="color: #008080;">331</span> <span style="color: #000000;">        }</span><span style="color: #008080;">332</span>         <span style="color: #008080;">333</span>         <span style="color: #800080;">$end_time</span>   = <span style="color: #008080;">strtotime</span>(<span style="color: #008080;">date</span>("Y-m-d",<span style="color: #000000;">gmtime()));</span><span style="color: #008080;">334</span>         <span style="color: #800080;">$start_time</span> = <span style="color: #800080;">$end_time</span> - 7 * 86400<span style="color: #000000;">;</span><span style="color: #008080;">335</span>         <span style="color: #800080;">$query</span> = "SELECT count(order_id) as total FROM ".<span style="color: #800080;">$GLOBALS</span>['ecs']->table('order_info')." WHERE synch_time $end_time."' and synch_time >= '".<span style="color: #800080;">$start_time</span>."'"<span style="color: #000000;">;</span><span style="color: #008080;">336</span>         <span style="color: #800080;">$filter</span>['orders'] = <span style="color: #008080;">round</span>(<span style="color: #800080;">$GLOBALS</span>['db']->getOne(<span style="color: #800080;">$query</span>) / 7);<span style="color: #008000;">//</span><span style="color: #008000;">7天平均订单数    </span><span style="color: #008080;">337</span>         <span style="color: #800080;">$filter</span>['orders'] = <span style="color: #800080;">$filter</span>['orders'] ? <span style="color: #800080;">$filter</span>['orders'] : 1400<span style="color: #000000;">; </span><span style="color: #008080;">338</span>         set_filter(<span style="color: #800080;">$filter</span>, <span style="color: #800080;">$sql</span><span style="color: #000000;">);</span><span style="color: #008080;">339</span> <span style="color: #000000;">    }</span><span style="color: #008080;">340</span>     <span style="color: #0000ff;">else</span><span style="color: #008080;">341</span> <span style="color: #000000;">    {</span><span style="color: #008080;">342</span>         <span style="color: #800080;">$sql</span>    = <span style="color: #800080;">$result</span>['sql'<span style="color: #000000;">];</span><span style="color: #008080;">343</span>         <span style="color: #800080;">$filter</span> = <span style="color: #800080;">$result</span>['filter'<span style="color: #000000;">];</span><span style="color: #008080;">344</span> <span style="color: #000000;">    }</span><span style="color: #008080;">345</span>
Nach dem Login kopieren
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage