ecshop 物材库存管理
1、建築フロー存続表。sql 句:
CREATE TABLE IF NOT EXISTS `emws_materials` (
`id` mediaint(8) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL、
`modulus` varchar(60) NOT NULL、
`stock_number` smallint(5) unsigned NOT NULL デフォルト '0'、
`stock_in` smallint(5) unsigned NOT NULL デフォルト '0',
`stock_out` smallint(5) unsigned NOT NULL デフォルト '0',
`safe_day` smallint(5) unsigned NOT NULL デフォルト '0',
`intent_day` smallint(5) unsigned NOT NULL デフォルト '0',
`is_buy` tinyint(1) unsigned NOT NULL デフォルト '1',
`buy_url` varchar(60) NOT NULL,
`price` 10,2) NOT NULL,
`weight` smallint(5) unsigned NOT NULL デフォルト '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,
主キー (`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;">ディレクトリ名</span>(<span style="color: #ff00ff;">__FILE__</span>) . '/ include/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;">新しい</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;">空</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', $stock_list<span style="color: #800080;">['stock_list'</span>]);<span style="color: #000000;"></span> 14<span style="color: #008080;"> </span>$smarty<span style="color: #800080;">->assign('filter', </span>$stock_list['フィルター'<span style="color: #800080;">]);</span><span style="color: #000000;"> 15</span> <span style="color: #008080;">$smarty</span>->assign('record_count', <span style="color: #800080;">$stock_list</span>['record_count' <span style="color: #800080;">]);</span><span style="color: #000000;"> 16</span> <span style="color: #008080;">$smarty</span>->assign('page_count', <span style="color: #800080;">$stock_list</span>['page_count'<span style="color: #800080;">]) ;</span><span style="color: #000000;"> 17</span> <span style="color: #008080;"> 18</span> <span style="color: #008080;">$smarty</span>->assign('shelf_list', <span style="color: #800080;">$shelf_list</span><span style="color: #800080;">);</span><span style="color: #000000;"> 19</span> <span style="color: #008080;">$smarty</span>->assign('full_page', 1<span style="color: #800080;">);</span><span style="color: #000000;"> 20</span> <span style="color: #008080;">$smarty</span>- >assign('action_link', <span style="color: #800080;">array</span>('href' => 'goods_stock.php?act=list', 'text' => '商品库存列表'<span style="color: #0000ff;">));</span><span style="color: #000000;"> 21</span> <span style="color: #008080;">$smarty</span>->assign('action_link2', <span style="color: #800080;">array</span>('href' => 'materials.php?act=export', 'text' => '导出採用购单'<span style="color: #0000ff;">));</span><span style="color: #000000;"> 22</span> <span style="color: #008080;">$smarty</span>->assign('action_link3', <span style="color: #800080;">array</span>('href' = > 'materials.php?act=add', 'text' => '添加物材料'<span style="color: #0000ff;">));</span><span style="color: #000000;"> 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'] == '挿入'<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;">トリム</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>['モジュラス'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['モジュラス']) ? <span style="color: #008080;">トリム</span>(<span style="color: #800080;">$_REQUEST</span>['モジュラス']) : ''<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>['価格' ] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['価格']) ? <span style="color: #008080;">floatval</span>(<span style="color: #800080;">$_REQUEST</span>['価格']) : '0.00'<span style="color: #000000;">;</span><span style="color: #008080;"> 43</span> <span style="color: #800080;">$material</span>['体重'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['体重']) ? <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;">トリム</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;">トリム</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;">空</span>(<span style="color: #800080;">$material</span>['name']) || <span style="color: #0000ff;">空</span>(<span style="color: #800080;">$material</span>['modulus']) || <span style="color: #0000ff;">空</span>(<span style="color: #800080;">$material</span>['safe_day']) || >空<span style="color: #0000ff;">(</span>$material<span style="color: #800080;">['intent_day'</span>]))<span style="color: #000000;"></span> 50<span style="color: #008080;"> </span> {<span style="color: #000000;"></span> 51<span style="color: #008080;"> sys_msg( '名前、系統番号、安全天数、目标天数、空または者格式不正确であることはできません', 1</span>);<span style="color: #000000;"></span> 52<span style="color: #008080;"> </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>]);<span style="color: #000000;"></span> 55<span style="color: #008080;"> </span>if<span style="color: #0000ff;"> (!</span>$is_only<span style="color: #800080;"></span>)<span style="color: #000000;"></span> 56<span style="color: #008080;"> </span> {<span style="color: #000000;"></span> 57<span style="color: #008080;"> sys_msg(</span>$material<span style="color: #800080;">['name'].'、すでに存在します', 1</span>);<span style="color: #000000;"></span> 58<span style="color: #008080;"> </span> }<span style="color: #000000;"></span> 59<span style="color: #008080;"> </span> 60<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>写真を処理中<span style="color: #008000;"></span>*/<span style="color: #008000;"></span> 61<span style="color: #008080;"> </span>$material<span style="color: #800080;">['img'] = </span>ベース名<span style="color: #008080;">(</span>$image<span style="color: #800080;">->upload_image(</span>$_FILES<span style="color: #800080;">[ 'img'],'素材'</span>));<span style="color: #000000;"></span> 62<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>処理 URL<span style="color: #008000;"></span>*/<span style="color: #008000;"></span> 63<span style="color: #008080;"> </span>$material<span style="color: #800080;">['buy_url'] = sanitize_url(</span>$_POST<span style="color: #800080;">['buy_url'</span>]);<span style="color: #000000;"></span> 64<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>データの挿入<span style="color: #008000;"></span>*/<span style="color: #008000;"></span> 65<span style="color: #008080;"> </span>$db<span style="color: #800080;">->autoExecute(</span>$ecs->table('materials'), <span style="color: #800080;">$material</span>, 'INSERT', '', 'SILENT'<span style="color: #800080;">);</span><span style="color: #000000;"> 66</span> <span style="color: #008080;"> 67</span> <span style="color: #008080;">$link</span>[0]['text'] = '追加を続ける'<span style="color: #800080;">;</span><span style="color: #000000;"> 68</span> <span style="color: #008080;">$link</span>[0][ ' href'] = 'materials.php?act=add'<span style="color: #800080;">;</span><span style="color: #000000;"> 69</span> <span style="color: #008080;">$link</span>[1]['text'] = '戻りリスト'<span style="color: #800080;">;</span><span style="color: #000000;"> 70</span> <span style="color: #008080;">$link</span>[1]['href'] = 'materials.php?act=list'<span style="color: #800080;">;</span><span style="color: #000000;"> 71 </span> sys_msg('正常に追加されました', 0, <span style="color: #008080;">$link</span><span style="color: #800080;">);</span><span style="color: #000000;"> 72</span> <span style="color: #008080;">}</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;">トリム</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>['モジュラス'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['モジュラス']) ? <span style="color: #008080;">トリム</span>(<span style="color: #800080;">$_REQUEST</span>['モジュラス']) : ''<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>['価格' ] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['価格']) ? <span style="color: #008080;">floatval</span>(<span style="color: #800080;">$_REQUEST</span>['価格']) : '0.00'<span style="color: #000000;">;</span><span style="color: #008080;"> 82</span> <span style="color: #800080;">$material</span>['体重'] = <span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_REQUEST</span>['体重']) ? <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;">トリム</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;">トリム</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;">空</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;">空</span>(<span style="color: #800080;">$material</span>['name']) || <span style="color: #0000ff;">空</span>(<span style="color: #800080;">$material</span>['modulus']) || <span style="color: #0000ff;">空</span>(<span style="color: #800080;">$material</span>['safe_day']) || empty<span style="color: #0000ff;">(</span>$material<span style="color: #800080;">['intent_day'</span>]))<span style="color: #000000;"></span> 94<span style="color: #008080;"> </span> {<span style="color: #000000;"></span> 95<span style="color: #008080;"> sys_msg('名前、係数、安全な日数、目標日数、空にすることはできません、または形式が正しくありません', 1</span>);<span style="color: #000000;"></span> 96<span style="color: #008080;"> </span> }<span style="color: #000000;"></span> 97<span style="color: #008080;"> </span> 98<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>画像処理中<span style="color: #008000;"></span>*/<span style="color: #008000;"></span> 99<span style="color: #008080;"> </span>if<span style="color: #0000ff;">( !</span>空の <span style="color: #0000ff;">(</span>$_FILES<span style="color: #800080;">['img']['name'</span>]))<span style="color: #000000;"></span>100<span style="color: #008080;"> </span> {<span style="color: #000000;"></span>101<span style="color: #008080;"> </span>$material<span style="color: #800080;">['img'] = </span>ベース名<span style="color: #008080;">(</span>$image<span style="color: #800080;">->upload_image(</span>$_FILES<span style="color: #800080;">[ 'img'], 'マテリアル'</span>));<span style="color: #000000;"></span>102<span style="color: #008080;"> </span> }<span style="color: #000000;"></span>103<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>処理URL<span style="color: #008000;"></span>*/<span style="color: #008000;"></span>104<span style="color: #008080;"> </span>$material<span style="color: #800080;">['buy_url'] = sanitize_url(</span>$_POST<span style="color: #800080;">['buy_url'</span> ]);<span style="color: #000000;"></span>105<span style="color: #008080;"> </span>/*<span style="color: #008000;"></span>データの挿入<span style="color: #008000;"></span>*/<span style="color: #008000;"></span>106<span style="color: #008080;"> </span>$db<span style="color: #800080;">->autoExecute(</span>$ecs<span style="color: #800080;">->table('materials'), </span>$material<span style="color: #800080;">, 'UPDATE', "id = '</span>$id<span style="color: #800080;"> '"</span> );<span style="color: #000000;"></span>107<span style="color: #008080;"> </span>108<span style="color: #008080;"> </span>$link<span style="color: #800080;">[0]['text'] = '編集を続ける'</span>;<span style="color: #000000;"></span> 109<span style="color: #008080;"> </span>$link<span style="color: #800080;">[0]['href'] = 'materials.php?act=edit&id='.</span>$id<span style="color: #800080;"></span>;<span style="color: #000000;"></span> 110<span style="color: #008080;"> </span>$link<span style="color: #800080;">[1]['text'] = '戻りリスト'</span>;<span style="color: #000000;"></span>111<span style="color: #008080;"> </span>$link<span style="color: #800080;">[1] ['href'] = 'materials.php?act=list'</span>;<span style="color: #000000;"></span>112<span style="color: #008080;"> sys_msg('正常に編集されました', 0, </span>$link<span style="color: #800080;"></span>) ;<span style="color: #000000;"></span>113<span style="color: #008080;"> </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'] == '削除'<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("場所: <span style="color: #800080;">$url</span>n"<span style="color: #000000;">);</span><span style="color: #008080;">131</span> <span style="color: #0000ff;">終了</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;">空</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;">リンク解除</span>(ROOT_PATH . DATA_DIR . '/マテリアル/' .<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>-> ;テーブル('材料')。 " 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;">配列</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>$val<span style="color: #800080;">) || </span>$val<span style="color: #800080;"> < 🎜></span>155<span style="color: #000000;"> </span> {<span style="color: #008080;"></span>156<span style="color: #000000;"> make_json_error(</span>sprintf<span style="color: #008080;">("格式不确!", <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;">ストリップスラッシュ</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: #000000;">)</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;">$ マテリアル</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;">ストリップスラッシュ</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_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')->gt; 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()->set水平(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> = 材料リスト(<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('商品サム'<span style="color: #000000;">);</span><span style="color: #008080;">237</span> <span style="color: #800080;">$objDrawing</span>- > ;setDescription('Pgoods サム'<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>->setCoowned('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>['株価番号'<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>$v<span style="color: #800080;">['stock_intent'</span>])<span style="color: #000000;"></span>256<span style="color: #008080;"> ->setCellValue('H'.</span>$i<span style="color: #800080;">, </span> $v<span style="color: #800080;">['proposal_buy'</span>])<span style="color: #000000;"></span>257<span style="color: #008080;"> ->setCellValue('I'.</span>$i<span style="color: #800080;">, </span>$v<span style="color: #800080;"> ['価格'</span>])<span style="color: #000000;"></span>258<span style="color: #008080;"> ->setCellValue('J'.</span>$i<span style="color: #800080;">, ''</span>);<span style="color: #000000;"></span> 259<span style="color: #008080;"> </span>if<span style="color: #0000ff;">(</span>$v<span style="color: #800080;">['stock_safe'] >= </span>$v<span style="color: #800080;">['stock_number'</span>])<span style="color: #000000;"></span>260<span style="color: #008080;"> </span> {<span style="color: #000000;"></span>261<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->setActiveSheetIndex(0)->getStyle('D'.</span>$i<span style="color: #800080;">)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::</span>COLOR_RED);<span style="color: #000000;"></span>262<span style="color: #008080;"> </span> }</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)->getHyperlink()->setUrl(</span>$v<span style="color: #800080;">['buy_url'</span>]);<span style="color: #000000;"></span>267<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">- >setActiveSheetIndex(0)->getCell('K'.</span>$i<span style="color: #800080;">)->getHyperlink()->setTooltip('采购链接'</span>);<span style="color: #000000;"></span> 268<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->setActiveSheetIndex(0)->getStyle('K'.</span>$i<span style="color: #800080;">)->getFont()->getColor()- >setARGB(PHPExcel_Style_Color::</span>COLOR_BLUE);<span style="color: #000000;"></span>269<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->setActiveSheetIndex(0)->getStyle('K'.</span> $i<span style="color: #800080;">)->getFont()->setUnderline(PHPExcel_Style_Font::</span>UNDERLINE_SINGLE);<span style="color: #000000;"></span>270<span style="color: #008080;"> </span> }<span style="color: #000000;"></span>271<span style="color: #008080;"> </span>else<span style="color: #0000ff;"></span>272<span style="color: #008080;"> </span> {<span style="color: #000000;"></span>273<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->setActiveSheetIndex(0)->setCellValue('K '.</span>$i<span style="color: #800080;">, ''</span>);<span style="color: #000000;"></span>274<span style="color: #008080;"> </span> }<span style="color: #008080;">275</span> <span style="color: #800080;">$objPHPExcel</span>->getActiveSheet()->getStyle('A'.<span style="color: #800080;">$i</span>)->getAlignment()->gt ;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)->getAlignment()->setVertical(PHPExcel_Style_Alignment::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>281<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->getActiveSheet()->getStyle ('G'.</span>$i<span style="color: #800080;">)->getAlignment()->setVertical(PHPExcel_Style_Alignment::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>282<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->getActiveSheet()->getStyle('H'.</span>$i<span style="color: #800080;">)->getAlignment()->setVertical(PHPExcel_Style_Alignment::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>283<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->getActiveSheet()->getStyle('I'.</span>$i<span style="color: #800080;">)->getAlignment()->setVertical(PHPExcel_Style_Alignment ::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>284<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->getActiveSheet()->getStyle('J'.</span>$i<span style="color: #800080;">) ->getAlignment()->setVertical(PHPExcel_Style_Alignment::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>285<span style="color: #008080;"> </span>$objPHPExcel<span style="color: #800080;">->getActiveSheet()->getStyle(' K'.</span>$i<span style="color: #800080;">)->getAlignment()->setVertical(PHPExcel_Style_Alignment::</span>VERTICAL_CENTER);<span style="color: #000000;"></span>286<span style="color: #008080;"> </span>$i<span style="color: #800080;"> </span>;<span style="color: #000000;"></span>287<span style="color: #008080;"> </span> }<span style="color: #000000;"></span>288<span style="color: #008080;"> </span>$file_name<span style="color: #800080;"> = </span>$file_name<span style="color: #800080;">.'.xls' </span>;<span style="color: #000000;"></span>289<span style="color: #008080;"> </span>ヘッダー<span style="color: #008080;">('Content-Type: application/vnd.ms-excel'</span>);<span style="color: #000000;"></span>290<span style="color: #008080;"> </span>ヘッダ<span style="color: #008080;">('Content-Disposition:attachment;filename="'.</span>$file_name<span style="color: #800080;">.'"'</span>);<span style="color: #000000;"></span>291<span style="color: #008080;"> </span> header<span style="color: #008080;">('Cache-Control: max-age=0'</span>);<span style="color: #000000;"></span>292<span style="color: #008080;"> </span>$objWriter<span style="color: #800080;"> = PHPExcel_IOFactory::createWriter(</span>$objPHPExcel) <span style="color: #800080;">, 'Excel5'</span>);<span style="color: #000000;"></span>293<span style="color: #008080;"> </span>$objWriter<span style="color: #800080;">->save('php://output'</span>);<span style="color: #000000;"> </span>294<span style="color: #008080;"> </span>終了<span style="color: #0000ff;"></span>;<span style="color: #000000;"></span>295<span style="color: #008080;"> </span>}<span style="color: #008080;">296</span> <span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'クエリ'<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;">グローバル</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;">空</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;">空</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('マテリアル')。 ' as '.<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('材料')。'そのまま 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 < '" .<span style="color: #800080;">$end_time</span>."' および 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>['注文'] : 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>