{"id":199379,"date":"2025-05-03T11:39:06","date_gmt":"2025-05-03T03:39:06","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199379\/"},"modified":"2025-05-03T11:39:06","modified_gmt":"2025-05-03T03:39:06","slug":"ecshop%e6%b7%bb%e5%8a%a0%e7%89%a9%e6%96%99%e5%ba%93%e5%ad%98%e7%ae%a1%e7%90%86%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199379\/","title":{"rendered":"ecshop\u6dfb\u52a0\u7269\u6599\u5e93\u5b58\u7ba1\u7406\u529f\u80fd"},"content":{"rendered":"<p> 1\u3001\u521b\u5efa\u7269\u6d41\u5e93\u5b58\u8868\u3002sql\u8bed\u53e5\uff1a<\/p>\n<p> CREATE TABLE IF NOT EXISTS `emws_materials` (<br \/> `id` mediumint(8) unsigned NOT NULL auto_increment,<br \/> `name` varchar(60) NOT NULL,<br \/> `modulus` varchar(60) NOT NULL,<br \/> `stock_number` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `stock_in` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `stock_out` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `safe_day` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `intent_day` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `is_buy` tinyint(1) unsigned NOT NULL default &#8216;1&#8217;,<br \/> `buy_url` varchar(60) NOT NULL,<br \/> `price` decimal(10,2) NOT NULL,<br \/> `weight` smallint(5) unsigned NOT NULL default &#8216;0&#8217;,<br \/> `img` varchar(60) NOT NULL,<br \/> `desc_info` varchar(60) NOT NULL,<br \/> `remark` varchar(60) NOT NULL,<br \/> `admin_id` smallint(5) unsigned NOT NULL,<br \/> `update_time` int(10) unsigned NOT NULL,<br \/> PRIMARY KEY (`id`)<br \/> ) ENGINE=MyISAM DEFAULT CHARSET=utf8<\/p>\n<p> 2\u3001php\u7a0b\u5e8f\uff0cmaterials.php\uff1a<\/p>\n<p>  &lt;?php   define(&#8216;IN_ECS&#8217;, true);   require(dirname(__FILE__) . &#8216;\/includes\/init.php&#8217;);   include_once(ROOT_PATH . &#8216;includes\/cls_image.php&#8217;);   $image = new cls_image($_CFG[&#8216;bgcolor&#8217;]);   $exc = new exchange($ecs-&gt;table(&#8220;materials&#8221;), $db, &#8216;id&#8217;, &#8216;name&#8217;);   $_REQUEST[&#8216;act&#8217;]=!empty($_REQUEST[&#8216;act&#8217;]) ? $_REQUEST[&#8216;act&#8217;]:&#8217;list&#8217;;   admin_priv(&#8216;stock_alert&#8217;);\/\/\u6743\u9650\uff1a\u5e93\u5b58\u6570\u91cf\u4fee\u6539   if($_REQUEST[&#8216;act&#8217;] == &#8216;list&#8217;)   {   &nbsp; &nbsp; $stock_list=material_list();   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;ur_here&#8217;, &nbsp; &nbsp; &nbsp;&#8216;\u7269\u6599\u5e93\u5b58\u5217\u8868&#8217;);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;stock_list&#8217;, &nbsp; &nbsp; $stock_list[&#8216;stock_list&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;filter&#8217;, &nbsp; &nbsp; &nbsp; $stock_list[&#8216;filter&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;record_count&#8217;, $stock_list[&#8216;record_count&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;page_count&#8217;, &nbsp; $stock_list[&#8216;page_count&#8217;]);   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;shelf_list&#8217;, &nbsp; &nbsp; $shelf_list);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;full_page&#8217;, &nbsp; &nbsp;1);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;action_link&#8217;, &nbsp;array(&#8216;href&#8217; =&gt; &#8216;goods_stock.php?act=list&#8217;, &#8216;text&#8217; =&gt; &#8216;\u5546\u54c1\u5e93\u5b58\u5217\u8868&#8217;));   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;action_link2&#8217;, &nbsp;array(&#8216;href&#8217; =&gt; &#8216;materials.php?act=export&#8217;, &#8216;text&#8217; =&gt; &#8216;\u5bfc\u51fa\u91c7\u8d2d\u5355&#8217;));   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;action_link3&#8217;, &nbsp;array(&#8216;href&#8217; =&gt; &#8216;materials.php?act=add&#8217;, &#8216;text&#8217; =&gt; &#8216;\u6dfb\u52a0\u7269\u6599&#8217;));   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $smarty-&gt;display(&#8216;material_list.htm&#8217;);   }   elseif($_REQUEST[&#8216;act&#8217;] == &#8216;add&#8217;)   { &nbsp; &nbsp;   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;ur_here&#8217;, &nbsp; &nbsp; &nbsp;&#8220;\u6dfb\u52a0\u7269\u6599&#8221;);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;action_link&#8217;, array(&#8216;href&#8217; =&gt; &#8216;materials.php?act=list&#8217;, &#8216;text&#8217; =&gt; &#8216;\u8fd4\u56de\u7269\u6599\u5e93\u5b58\u5217\u8868&#8217;));   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;form_action&#8217;, &#8220;insert&#8221;);   &nbsp;   &nbsp; &nbsp; assign_query_info();   &nbsp; &nbsp; $smarty-&gt;display(&#8216;material_info.htm&#8217;);   }   elseif($_REQUEST[&#8216;act&#8217;] == &#8216;insert&#8217;)   {   &nbsp; &nbsp; $material[&#8216;is_buy&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;is_buy&#8217;]) ? intval($_REQUEST[&#8216;is_buy&#8217;]) : 1;   &nbsp; &nbsp; $material[&#8216;name&#8217;] &nbsp; &nbsp; &nbsp;= isset($_REQUEST[&#8216;name&#8217;]) ? trim($_REQUEST[&#8216;name&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;modulus&#8217;] &nbsp; = isset($_REQUEST[&#8216;modulus&#8217;]) ? trim($_REQUEST[&#8216;modulus&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;safe_day&#8217;] &nbsp;= isset($_REQUEST[&#8216;safe_day&#8217;]) ? intval($_REQUEST[&#8216;safe_day&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;intent_day&#8217;]= isset($_REQUEST[&#8216;intent_day&#8217;]) ? intval($_REQUEST[&#8216;intent_day&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;price&#8217;] &nbsp; &nbsp; = isset($_REQUEST[&#8216;price&#8217;]) ? floatval($_REQUEST[&#8216;price&#8217;]) : &#8216;0.00&#8217;;   &nbsp; &nbsp; $material[&#8216;weight&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;weight&#8217;]) ? intval($_REQUEST[&#8216;weight&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;desc_info&#8217;] = isset($_REQUEST[&#8216;desc_info&#8217;]) ? trim($_REQUEST[&#8216;desc_info&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;remark&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;remark&#8217;]) ? trim($_REQUEST[&#8216;remark&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;update_time&#8217;]= gmtime();   &nbsp; &nbsp; $material[&#8216;admin_id&#8217;] &nbsp; = $_SESSION[&#8216;admin_id&#8217;];   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; if(empty($material[&#8216;name&#8217;]) || empty($material[&#8216;modulus&#8217;]) || empty($material[&#8216;safe_day&#8217;]) || empty($material[&#8216;intent_day&#8217;]))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; sys_msg(&#8216;\u540d\u79f0\u3001\u7cfb\u6570\u3001\u5b89\u5168\u5929\u6570\u3001\u76ee\u6807\u5929\u6570\uff0c\u4e0d\u80fd\u4e3a\u7a7a\u6216\u8005\u683c\u5f0f\u4e0d\u6b63\u786e&#8217;, 1);   &nbsp; &nbsp; }   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $is_only = $exc-&gt;is_only(&#8216;name&#8217;, $material[&#8216;name&#8217;]);   &nbsp; &nbsp; if (!$is_only)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; sys_msg($material[&#8216;name&#8217;].&#8217;\uff0c\u5df2\u5b58\u5728&#8217;, 1);   &nbsp; &nbsp; }   &nbsp;   &nbsp; &nbsp; &nbsp;\/*\u5904\u7406\u56fe\u7247*\/   &nbsp; &nbsp; $material[&#8216;img&#8217;] = basename($image-&gt;upload_image($_FILES[&#8216;img&#8217;],&#8217;material&#8217;));   &nbsp; &nbsp; &nbsp;\/*\u5904\u7406URL*\/   &nbsp; &nbsp; $material[&#8216;buy_url&#8217;] = sanitize_url($_POST[&#8216;buy_url&#8217;]);   &nbsp; &nbsp; \/*\u63d2\u5165\u6570\u636e*\/   &nbsp; &nbsp; $db-&gt;autoExecute($ecs-&gt;table(&#8216;materials&#8217;), $material, &#8216;INSERT&#8217;, &#8221;, &#8216;SILENT&#8217;);   &nbsp;   &nbsp; &nbsp; $link[0][&#8216;text&#8217;] = &#8216;\u7ee7\u7eed\u6dfb\u52a0&#8217;;   &nbsp; &nbsp; $link[0][&#8216;href&#8217;] = &#8216;materials.php?act=add&#8217;;   &nbsp; &nbsp; $link[1][&#8216;text&#8217;] = &#8216;\u8fd4\u56de\u5217\u8868&#8217;;   &nbsp; &nbsp; $link[1][&#8216;href&#8217;] = &#8216;materials.php?act=list&#8217;;   &nbsp; &nbsp; sys_msg(&#8216;\u6dfb\u52a0\u6210\u529f&#8217;, 0, $link);   }   elseif($_REQUEST[&#8216;act&#8217;] == &#8216;updata&#8217;)   {   &nbsp; &nbsp; $id &nbsp; &nbsp;= isset($_REQUEST[&#8216;id&#8217;]) ? intval($_REQUEST[&#8216;id&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;is_buy&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;is_buy&#8217;]) ? intval($_REQUEST[&#8216;is_buy&#8217;]) : 1;   &nbsp; &nbsp; $material[&#8216;name&#8217;] &nbsp; &nbsp; &nbsp;= isset($_REQUEST[&#8216;name&#8217;]) ? trim($_REQUEST[&#8216;name&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;modulus&#8217;] &nbsp; = isset($_REQUEST[&#8216;modulus&#8217;]) ? trim($_REQUEST[&#8216;modulus&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;safe_day&#8217;] &nbsp;= isset($_REQUEST[&#8216;safe_day&#8217;]) ? intval($_REQUEST[&#8216;safe_day&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;intent_day&#8217;]= isset($_REQUEST[&#8216;intent_day&#8217;]) ? intval($_REQUEST[&#8216;intent_day&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;price&#8217;] &nbsp; &nbsp; = isset($_REQUEST[&#8216;price&#8217;]) ? floatval($_REQUEST[&#8216;price&#8217;]) : &#8216;0.00&#8217;;   &nbsp; &nbsp; $material[&#8216;weight&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;weight&#8217;]) ? intval($_REQUEST[&#8216;weight&#8217;]) : 0;   &nbsp; &nbsp; $material[&#8216;desc_info&#8217;] = isset($_REQUEST[&#8216;desc_info&#8217;]) ? trim($_REQUEST[&#8216;desc_info&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;remark&#8217;] &nbsp; &nbsp;= isset($_REQUEST[&#8216;remark&#8217;]) ? trim($_REQUEST[&#8216;remark&#8217;]) : &#8221;;   &nbsp; &nbsp; $material[&#8216;update_time&#8217;]= gmtime();   &nbsp; &nbsp; $material[&#8216;admin_id&#8217;] &nbsp; = $_SESSION[&#8216;admin_id&#8217;];   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; if(empty($id))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; sys_msg(&#8216;ID\u4e0d\u80fd\u4e3a\u7a7a&#8217;, 1);   &nbsp; &nbsp; }   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; if(empty($material[&#8216;name&#8217;]) || empty($material[&#8216;modulus&#8217;]) || empty($material[&#8216;safe_day&#8217;]) || empty($material[&#8216;intent_day&#8217;]))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; sys_msg(&#8216;\u540d\u79f0\u3001\u7cfb\u6570\u3001\u5b89\u5168\u5929\u6570\u3001\u76ee\u6807\u5929\u6570\uff0c\u4e0d\u80fd\u4e3a\u7a7a\u6216\u8005\u683c\u5f0f\u4e0d\u6b63\u786e&#8217;, 1);   &nbsp; &nbsp; }   &nbsp;   &nbsp; &nbsp; &nbsp;\/*\u5904\u7406\u56fe\u7247*\/   &nbsp; &nbsp; &nbsp;if(!empty($_FILES[&#8216;img&#8217;][&#8216;name&#8217;]))   &nbsp; &nbsp; &nbsp;{   &nbsp; &nbsp; &nbsp; &nbsp; $material[&#8216;img&#8217;] = basename($image-&gt;upload_image($_FILES[&#8216;img&#8217;],&#8217;material&#8217;));   &nbsp; &nbsp; &nbsp;}   &nbsp; &nbsp; &nbsp;\/*\u5904\u7406URL*\/   &nbsp; &nbsp; $material[&#8216;buy_url&#8217;] = sanitize_url($_POST[&#8216;buy_url&#8217;]);   &nbsp; &nbsp; \/*\u63d2\u5165\u6570\u636e*\/   &nbsp; &nbsp; $db-&gt;autoExecute($ecs-&gt;table(&#8216;materials&#8217;), $material, &#8216;UPDATE&#8217;, &#8220;id = &#8216;$id'&#8221;);   &nbsp;   &nbsp; &nbsp; $link[0][&#8216;text&#8217;] = &#8216;\u7ee7\u7eed\u7f16\u8f91&#8217;;   &nbsp; &nbsp; $link[0][&#8216;href&#8217;] = &#8216;materials.php?act=edit&amp;id=&#8217;.$id;   &nbsp; &nbsp; $link[1][&#8216;text&#8217;] = &#8216;\u8fd4\u56de\u5217\u8868&#8217;;   &nbsp; &nbsp; $link[1][&#8216;href&#8217;] = &#8216;materials.php?act=list&#8217;;   &nbsp; &nbsp; sys_msg(&#8216;\u7f16\u8f91\u6210\u529f&#8217;, 0, $link);   }   elseif ($_REQUEST[&#8216;act&#8217;] ==&#8217;edit&#8217;)   {   &nbsp; &nbsp; $sql = &#8220;SELECT * FROM &#8221; .$ecs-&gt;table(&#8216;materials&#8217;). &#8221; WHERE id=&#8217;$_REQUEST[id]'&#8221;;   &nbsp; &nbsp; $material = $db-&gt;GetRow($sql);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;ur_here&#8217;, &nbsp; &nbsp; &#8220;\u7f16\u8f91\u7269\u6599&#8221;);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;action_link&#8217;, array(&#8216;href&#8217; =&gt; &#8216;materials.php?act=list&#8217;, &#8216;text&#8217; =&gt; &#8216;\u8fd4\u56de\u7269\u6599\u5e93\u5b58\u5217\u8868&#8217;));   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;material&#8217;, &nbsp; &nbsp;$material);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;form_action&#8217;, &#8216;updata&#8217;);   &nbsp; &nbsp; assign_query_info();   &nbsp; &nbsp; $smarty-&gt;display(&#8216;material_info.htm&#8217;);   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;remove&#8217;)   {   &nbsp; &nbsp; $id = intval($_GET[&#8216;id&#8217;]);   &nbsp; &nbsp; $exc-&gt;drop($id);   &nbsp; &nbsp; $url = &#8216;materials.php?act=query&amp;&#8217; . str_replace(&#8216;act=remove&#8217;, &#8221;, $_SERVER[&#8216;QUERY_STRING&#8217;]);   &nbsp; &nbsp; ecs_header(&#8220;Location: $url\\n&#8221;);   &nbsp; &nbsp; exit;   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;drop_img&#8217;)   {   &nbsp; &nbsp; $id = isset($_GET[&#8216;id&#8217;]) ? intval($_GET[&#8216;id&#8217;]) : 0;   &nbsp;   &nbsp; &nbsp; $sql = &#8220;SELECT img FROM &#8221; .$ecs-&gt;table(&#8216;materials&#8217;). &#8221; WHERE id = &#8216;$id'&#8221;;   &nbsp; &nbsp; $img_name = $db-&gt;getOne($sql);   &nbsp;   &nbsp; &nbsp; if (!empty($img_name))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; @unlink(ROOT_PATH . DATA_DIR . &#8216;\/material\/&#8217; .$img_name);   &nbsp; &nbsp; &nbsp; &nbsp; $sql = &#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;materials&#8217;). &#8221; SET img = &#8221; WHERE id = &#8216;$id'&#8221;;   &nbsp; &nbsp; &nbsp; &nbsp; $db-&gt;query($sql);   &nbsp; &nbsp; }   &nbsp; &nbsp; $link= array(array(&#8216;text&#8217; =&gt; &#8216;\u7ee7\u7eed\u7f16\u8f91&#8217;, &#8216;href&#8217; =&gt; &#8216;materials.php?act=edit&amp;id=&#8217; . $id), array(&#8216;text&#8217; =&gt; &#8216;\u8fd4\u56de\u7269\u6599\u5e93\u5b58\u5217\u8868&#8217;, &#8216;href&#8217; =&gt; &#8216;materials.php?act=list&#8217;));   &nbsp; &nbsp; sys_msg(&#8216;\u56fe\u7247\u5220\u9664\u6210\u529f&#8217;, 0, $link);   } &nbsp; &nbsp;   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;edit_stock_in&#8217;) \/\/\u66f4\u6539\u5165\u5e93   {   &nbsp; &nbsp; $id = intval($_POST[&#8216;id&#8217;]);   &nbsp; &nbsp; $val = json_str_iconv(trim($_POST[&#8216;val&#8217;]));   &nbsp; &nbsp; \/* \u68c0\u67e5\u683c\u5f0f *\/   &nbsp; &nbsp; if(!is_numeric($val) || $val &lt; 0)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; make_json_error(sprintf(&#8220;\u683c\u5f0f\u4e0d\u6b63\u786e\uff01&#8221;, &nbsp;$val));   &nbsp; &nbsp; }   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $exc-&gt;edit(&#8220;stock_in=&#8217;$val'&#8221;, $id);   &nbsp; &nbsp; make_json_result(stripslashes($val));   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;edit_stock_out&#8217;) \/\/\u66f4\u6539\u51fa\u5e93   {   &nbsp; &nbsp; $id = intval($_POST[&#8216;id&#8217;]);   &nbsp; &nbsp; $val = json_str_iconv(trim($_POST[&#8216;val&#8217;]));   &nbsp; &nbsp; \/* \u68c0\u67e5\u683c\u5f0f *\/   &nbsp; &nbsp; if(!is_numeric($val) || $val &lt; 0)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; make_json_error(sprintf(&#8220;\u683c\u5f0f\u4e0d\u6b63\u786e\uff01&#8221;, &nbsp;$val));   &nbsp; &nbsp; }   &nbsp; &nbsp; $sql=&#8221;SELECT * FROM &#8220;.$GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;materials&#8217;).&#8221; where id = &#8216;&#8221;.$id.&#8221;&#8216;&#8221;;   &nbsp; &nbsp; $material = $GLOBALS[&#8216;db&#8217;]-&gt;getRow($sql);&nbsp;   &nbsp; &nbsp; if($val &gt; $material[&#8216;stock_in&#8217;] + $material[&#8216;stock_number&#8217;])   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; make_json_error(sprintf(&#8220;\u51fa\u5e93\u6570\u4e0d\u80fd\u5927\u4e8e\u73b0\u6709\u5e93\u5b58\u4e0e\u5165\u5e93\u603b\u548c\uff01&#8221;, &nbsp;$val));   &nbsp; &nbsp; }   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $exc-&gt;edit(&#8220;stock_out=&#8217;$val'&#8221;, $id);   &nbsp; &nbsp; make_json_result(stripslashes($val));   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;operate&#8217;) \/\/\u6279\u91cf\u5165\u5e93\/\u51fa\u5e93   {   &nbsp; &nbsp; $sql = &#8220;UPDATE &#8221; .$ecs-&gt;table(&#8216;materials&#8217;). &#8221; SET stock_number = stock_number + stock_in &#8211; stock_out,stock_out = 0,stock_in = 0,admin_id=$_SESSION[admin_id],update_time = &#8220;.gmtime();   &nbsp; &nbsp; $db-&gt;query($sql);   &nbsp; &nbsp; $link= array(array(&#8216;text&#8217; =&gt; &#8216;\u8fd4\u56de\u7269\u6599\u5e93\u5b58\u5217\u8868&#8217;, &#8216;href&#8217; =&gt; &#8216;materials.php?act=list&#8217;));   &nbsp; &nbsp; sys_msg(&#8216;\u6210\u529f\u6279\u91cf\u5165\u5e93\/\u51fa\u5e93&#8217;, 0, $link);   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;export&#8217;) \/\/\u5bfc\u51fa\u91c7\u8d2d\u5355   {   &nbsp; &nbsp; include_once(&#8216;includes\/PHPExcel\/PHPExcel.php&#8217;);   &nbsp; &nbsp; include_once(&#8216;corlor.php&#8217;);   &nbsp; &nbsp; $objPHPExcel = new PHPExcel();   &nbsp;   &nbsp; &nbsp; $filename = &#8216;\u7269\u6599\u91c7\u8d2d\u8868_&#8217;.date(&#8220;YmdHi&#8221;,gmtime());   &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;setTitle($filename);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;A&#8217;)-&gt;setWidth(15);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;B&#8217;)-&gt;setWidth(15);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;C&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;D&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;E&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;F&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;G&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;H&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;I&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;J&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;C1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;D1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;F1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;G1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;H1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;I1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;J1&#8217;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);   &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension(&#8216;K&#8217;)-&gt;setWidth(10);   &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;A1&#8217;, &#8216;\u7269\u6599\u540d\u79f0&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;B1&#8217;, &#8216;\u56fe\u7247&#8217;) &nbsp; &nbsp;   &nbsp; &nbsp; -&gt;setCellValue(&#8216;C1&#8217;, &#8216;\u6bcf\u5929\u7528\u91cf&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;D1&#8217;, &#8216;\u73b0\u6709\u5e93\u5b58&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;E1&#8217;, &#8216;\u5468\u8f6c\u5929\u6570&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;F1&#8217;, &#8216;\u5b89\u5168\u5e93\u5b58&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;G1&#8217;, &#8216;\u76ee\u6807\u5e93\u5b58&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;H1&#8217;, &#8216;\u5efa\u8bae\u8d2d\u4e70&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;I1&#8217;, &#8216;\u5355\u4ef7&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;J1&#8217;, &#8216;\u5b9e\u9645\u5355\u4ef7&#8217;)   &nbsp; &nbsp; -&gt;setCellValue(&#8216;K1&#8217;, &#8216;\u91c7\u8d2d\u94fe\u63a5&#8217;);   &nbsp; &nbsp; $i=2;   &nbsp; &nbsp; $stock_list = material_list(false);   &nbsp; &nbsp; $arr = $stock_list[&#8216;stock_list&#8217;];   &nbsp; &nbsp; foreach($arr as $v)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; if($v[&#8216;img&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getRowDimension($i)-&gt;setRowHeight(50);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing = new PHPExcel_Worksheet_Drawing();   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setName(&#8216;goods thumb&#8217;);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setDescription(&#8216;Pgoods thumb&#8217;);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $img_path = file_exists(&#8216;..\/data\/material\/&#8217;.$v[&#8216;img&#8217;]) ? &#8216;..\/data\/material\/&#8217;.$v[&#8216;img&#8217;] : &#8216;..\/images\/no_img.jpg&#8217;;   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setPath($img_path);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setWidth(100);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setCoordinates(&#8216;B&#8217;.$i);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objDrawing-&gt;setWorksheet($objPHPExcel-&gt;getActiveSheet());   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; else   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue(&#8216;B&#8217;.$i, &#8221;); &nbsp; &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;A&#8217;.$i, $v[&#8216;name&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;C&#8217;.$i, $v[&#8216;day_use&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;D&#8217;.$i, $v[&#8216;stock_number&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;E&#8217;.$i, $v[&#8216;stock_day&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;F&#8217;.$i, $v[&#8216;stock_safe&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;G&#8217;.$i, $v[&#8216;stock_intent&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;H&#8217;.$i, $v[&#8216;proposal_buy&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;I&#8217;.$i, $v[&#8216;price&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;setCellValue(&#8216;J&#8217;.$i, &#8221;);   &nbsp; &nbsp; &nbsp; &nbsp; if($v[&#8216;stock_safe&#8217;] &gt;= $v[&#8216;stock_number&#8217;])   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;getStyle(&#8216;D&#8217;.$i)-&gt;getFont()-&gt;getColor()-&gt;setARGB(PHPExcel_Style_Color::COLOR_RED);   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; if($v[&#8216;buy_url&#8217;] != &#8216;http:\/\/&#8217;)   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue(&#8216;K&#8217;.$i, &#8216;\u91c7\u8d2d\u94fe\u63a5&#8217;);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;getCell(&#8216;K&#8217;.$i)-&gt;getHyperlink()-&gt;setUrl($v[&#8216;buy_url&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;getCell(&#8216;K&#8217;.$i)-&gt;getHyperlink()-&gt;setTooltip(&#8216;\u91c7\u8d2d\u94fe\u63a5&#8217;);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;getStyle(&#8216;K&#8217;.$i)-&gt;getFont()-&gt;getColor()-&gt;setARGB(PHPExcel_Style_Color::COLOR_BLUE);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;getStyle(&#8216;K&#8217;.$i)-&gt;getFont()-&gt;setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; else   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;setActiveSheetIndex(0)-&gt;setCellValue(&#8216;K&#8217;.$i, &#8221;);   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;A&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;B&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;C&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;D&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;E&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;F&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;G&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;H&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;I&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;J&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle(&#8216;K&#8217;.$i)-&gt;getAlignment()-&gt;setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);   &nbsp; &nbsp; &nbsp; &nbsp; $i++;   &nbsp; &nbsp; }   &nbsp; &nbsp; $file_name &nbsp; &nbsp;= &nbsp; &nbsp;$filename.&#8217;.xls&#8217;;   &nbsp; &nbsp; header(&#8216;Content-Type: application\/vnd.ms-excel&#8217;);   &nbsp; &nbsp; header(&#8216;Content-Disposition: attachment;filename=&#8221;&#8216;.$file_name.'&#8221;&#8216;);   &nbsp; &nbsp; header(&#8216;Cache-Control: max-age=0&#8217;);   &nbsp; &nbsp; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, &#8216;Excel5&#8217;);   &nbsp; &nbsp; $objWriter-&gt;save(&#8216;php:\/\/output&#8217;);   &nbsp; &nbsp; exit;   }   elseif ($_REQUEST[&#8216;act&#8217;] == &#8216;query&#8217;)   { &nbsp; &nbsp;   &nbsp; &nbsp; $stock_list = material_list();   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;stock_list&#8217;, &nbsp; &nbsp; $stock_list[&#8216;stock_list&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;filter&#8217;, &nbsp; &nbsp; &nbsp; $stock_list[&#8216;filter&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;record_count&#8217;, $stock_list[&#8216;record_count&#8217;]);   &nbsp; &nbsp; $smarty-&gt;assign(&#8216;page_count&#8217;, &nbsp; $stock_list[&#8216;page_count&#8217;]);   &nbsp; &nbsp; make_json_result($smarty-&gt;fetch(&#8216;material_list.htm&#8217;), &#8221;, array(&#8216;filter&#8217; =&gt; $stock_list[&#8216;filter&#8217;], &#8216;page_count&#8217; =&gt; $stock_list[&#8216;page_count&#8217;]));   }   &nbsp;   function material_list($is_pagination = true)   {   &nbsp; &nbsp; GLOBAL $ecs,$db;   &nbsp; &nbsp; $result = get_filter();   &nbsp; &nbsp; if ($result === false)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $filter[&#8216;sort_by&#8217;] = empty($_REQUEST[&#8216;sort_by&#8217;]) ? &#8216;id&#8217; : trim($_REQUEST[&#8216;sort_by&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; $filter[&#8216;sort_order&#8217;] = empty($_REQUEST[&#8216;sort_order&#8217;]) ? &#8216;desc&#8217; : trim($_REQUEST[&#8216;sort_order&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; $where = &#8221; WHERE 1 = 1 &#8220;;   &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $sql = &#8216;select count(t.id) from &#8216;.$ecs-&gt;table(&#8216;materials&#8217;). &#8216; as t &#8216;.$where;   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $filter[&#8216;record_count&#8217;] = $db-&gt;getOne($sql);   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; \/* \u5206\u9875\u5927\u5c0f *\/   &nbsp; &nbsp; &nbsp; &nbsp; $filter = page_and_size($filter);   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $sql = &#8216;select t.*, au.user_name from &#8216;.   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ecs-&gt;table(&#8216;materials&#8217;).&#8217; as t left join &#8216;.   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ecs-&gt;table(&#8216;admin_user&#8217;).&#8221; as au on t.admin_id=au.user_id &#8220;.$where.   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216; order by &#8216;.$filter[&#8216;sort_by&#8217;].&#8221; &#8220;.$filter[&#8216;sort_order&#8217;];   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; if ($is_pagination)<br \/>\n<span style=\"color:#ffffff\">\/\/www.ldhost.cn<\/span>   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql .= &#8221; LIMIT &#8221; . $filter[&#8216;start&#8217;] . &#8216;, &#8216; . $filter[&#8216;page_size&#8217;];   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $end_time &nbsp; = strtotime(date(&#8220;Y-m-d&#8221;,gmtime()));   &nbsp; &nbsp; &nbsp; &nbsp; $start_time = $end_time &#8211; 7 * 86400;   &nbsp; &nbsp; &nbsp; &nbsp; $query = &#8220;SELECT count(order_id) as total FROM &#8220;.$GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;order_info&#8217;).&#8221; WHERE synch_time &lt; &#8216;&#8221;.$end_time.&#8221;&#8216; and synch_time &gt;= &#8216;&#8221;.$start_time.&#8221;&#8216;&#8221;;   &nbsp; &nbsp; &nbsp; &nbsp; $filter[&#8216;orders&#8217;] = round($GLOBALS[&#8216;db&#8217;]-&gt;getOne($query) \/ 7);\/\/7\u5929\u5e73\u5747\u8ba2\u5355\u6570 &nbsp; &nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; $filter[&#8216;orders&#8217;] = $filter[&#8216;orders&#8217;] ? $filter[&#8216;orders&#8217;] : 1400;&nbsp;   &nbsp; &nbsp; &nbsp; &nbsp; set_filter($filter, $sql);   &nbsp; &nbsp; }   &nbsp; &nbsp; else   &nbsp; &nbsp; {&nbsp;<br \/>\n<span>\/\/www.ldhost.cn<\/span>   &nbsp; &nbsp; &nbsp; &nbsp; $sql &nbsp; &nbsp;= $result[&#8216;sql&#8217;];   &nbsp; &nbsp; &nbsp; &nbsp; $filter = $result[&#8216;filter&#8217;];   &nbsp; &nbsp; }   &nbsp; &nbsp; $row = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($sql);   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $orders = $filter[&#8216;orders&#8217;];   &nbsp; &nbsp; foreach($row as $k=&gt;$val)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; if ($is_pagination == false &amp;&amp; $val[&#8216;is_buy&#8217;] == 0) \/\/\u4e0d\u8d2d\u4e70\uff0c\u4e0d\u5bfc\u51fa   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; unset($row[$k]);   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; continue;   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;update_time&#8217;] = local_date(&#8216;Y-m-d H:i&#8217;,$val[&#8216;update_time&#8217;]);   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;day_use&#8217;] &nbsp; &nbsp; = $day_use = round($orders * $val[&#8216;modulus&#8217;],1);\/\/\u6bcf\u65e5\u7528\u91cf   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;stock_day&#8217;] &nbsp; = $day_use ? round($val[&#8216;stock_number&#8217;] \/ $day_use,1) : 0;\/\/\u5468\u8f6c\u5929\u6570   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;stock_safe&#8217;] &nbsp;= round($val[&#8216;safe_day&#8217;] * $day_use,1);\/\/\u5b89\u5168\u5e93\u5b58   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;stock_intent&#8217;]= $stock_intent = round($val[&#8216;intent_day&#8217;] * $day_use,1);\/\/\u76ee\u6807\u5e93\u5b58   &nbsp; &nbsp; &nbsp; &nbsp; $row[$k][&#8216;proposal_buy&#8217;]= round($stock_intent &#8211; $val[&#8216;stock_number&#8217;],1);\/\/\u5efa\u8bae\u8d2d\u4e70   &nbsp; &nbsp; }   &nbsp; &nbsp;&nbsp;   &nbsp; &nbsp; $stock_list = array(&#8216;stock_list&#8217; =&gt; $row, &#8216;filter&#8217; =&gt; $filter, &#8216;page_count&#8217; =&gt; $filter[&#8216;page_count&#8217;], &#8216;record_count&#8217; =&gt; $filter[&#8216;record_count&#8217;]);   &nbsp; &nbsp; return $stock_list;   }   ?&gt; <\/p>\n<p> <img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/150313\/1313511D7-0.jpg\" style=\"width: 700px;height: 239px\" class=\"aligncenter\"> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u521b\u5efa\u7269\u6d41\u5e93\u5b58\u8868\u3002sql\u8bed\u53e5\uff1a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199379","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199379"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199379\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}