ECSHOPの資材在庫管理

WBOY
リリース: 2016-08-08 09:30:15
オリジナル
966 人が閲覧しました

1、建物のストリーム保存表。SQL句:

存在しない場合はテーブルを作成 `emws_materials` (
`id`mediumint(8) unsigned NOT NULL auto_increment,
`name` varchar(60) NOT NULL,
`modulus` varchar(60) NOT NULL,
`stock_number` smallint (5) unsigned NOT NULL デフォルト '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,
PRIMARY KEY (`id`)
) ENGINE= MyISAM デフォルト CHARSET=utf8;

2、php程序、materials.php:

リーリー

コードを表示

define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
include_once(ROOT_PATH . 'includes/cls_image.php');
$image = 新しい cls_image($_CFG['bgcolor']);
$exc = 新しい Exchange($ecs->table("materials"), $db, 'id', 'name');
$_REQUEST['act ']=!empty($_REQUEST['act']) ? $_REQUEST['act']:'list';
admin_priv('stock_alert');//权制限:库存数量修改
if($_REQUEST['act'] == 'list')
{
$stock_list=material_list ();
$smarty->assign('ur_here', '物資库存列表');
$smarty->assign('stock_list', $stock_list['stock_list']);
$smarty->assign ('filter', $stock_list['filter']);
$smarty->assign('record_count', $stock_list['record_count']);
$smarty->assign('page_count', $stock_list[ 'page_count']);

$smarty->assign('shelf_list', $shelf_list);
$smarty->assign('full_page', 1);
$smarty->assign('action_link', array('href' => 'goods_stock.php?act=list', 'text' => '商品库存列表'));
$smarty->assign('action_link2', array('href' = > 'materials.php?act=export', 'text' => '导出采购单'));
$smarty->assign('action_link3', array('href' => 'materials.php) ?act=add', 'text' => '添加物料'));

$smarty->display('material_list.htm');
}
elseif($_REQUEST['act'] == ' add')
{
$smarty->assign('ur_here', "添加物料");
$smarty->assign('action_link', array('href' => 'materials.php?act=list', 'text' => '返物材库存列表'));
$smarty->assign('form_action', "insert");
assign_query_info();
$smarty->display('material_info.htm');
}
elseif ($_REQUEST['act'] == '挿入')
{
$material['is_buy'] = isset($_REQUEST['is_buy']) ? intval($_REQUEST['is_buy']) : 1;
$material['name'] = isset($_REQUEST['name']) ?トリム($_REQUEST['名前']) : '';
$material['モジュラス'] = isset($_REQUEST['モジュラス']) ?トリム($_REQUEST['modulus']) : '';
$material['safe_day'] = isset($_REQUEST['safe_day']) ? intval($_REQUEST['safe_day']) : 0;
$material['intent_day']= isset($_REQUEST['intent_day']) ? intval($_REQUEST['intent_day']) : 0;
$material['price'] = isset($_REQUEST['price']) ? floatval($_REQUEST['price']) : '0.00';
$material['weight'] = isset($_REQUEST['weight']) ? intval($_REQUEST['weight']) : 0;
$material['desc_info'] = isset($_REQUEST['desc_info']) ?トリム($_REQUEST['desc_info']) : '';
$material['remark'] = isset($_REQUEST['remark']) ? rim($_REQUEST['remark']) : '';
$material['update_time']= gmtime();
$material['admin_id'] = $_SESSION['admin_id'];

if(empty( $material['name']) || 空($material['safe_day']) 空($material['intent_day']) ||
sys_msg( '名前、系数、安全天数、目标天数、空または者格式不正确であることはできません', 1);
}

$is_only = $exc->is_only('name', $material['name']);
if (!$is_only)
{
sys_msg($material['name'].',已存在', 1);
}
/*处理图片*/
$material['img'] = Basename($ image->upload_image($_FILES['img'],'material'));
/*处理URL*/
$material['buy_url'] = sanitize_url($_POST['buy_url']);
/*插入据*/
$db->autoExecute($ecs->table('materials'), $material, 'INSERT', '', 'SILENT');
$link[0]['text'] = '继续追加';
$link[0]['href'] = 'materials.php?act=add';
$link[1]['text'] = '返列表';
    $link[1]['href'] = 'materials.php?act=list';
sys_msg('追加成功', 0, $link);
}
elseif($_REQUEST['act'] == ' updata')
{
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$material['is_buy'] = isset($_REQUEST['is_buy']) ? intval($_REQUEST['is_buy']) : 1;
$material['name'] = isset($_REQUEST['name']) ?トリム($_REQUEST['名前']) : '';
$material['モジュラス'] = isset($_REQUEST['モジュラス']) ?トリム($_REQUEST['modulus']) : '';
$material['safe_day'] = isset($_REQUEST['safe_day']) ? intval($_REQUEST['safe_day']) : 0;
$material['intent_day']= isset($_REQUEST['intent_day']) ? intval($_REQUEST['intent_day']) : 0;
$material['price'] = isset($_REQUEST['price']) ? floatval($_REQUEST['price']) : '0.00';
$material['weight'] = isset($_REQUEST['weight']) ? intval($_REQUEST['weight']) : 0;
$material['desc_info'] = isset($_REQUEST['desc_info']) ?トリム($_REQUEST['desc_info']) : '';
$material['remark'] = isset($_REQUEST['remark']) ? rim($_REQUEST['remark']) : '';
$material['update_time']= gmtime();
$material['admin_id'] = $_SESSION['admin_id'];

if(empty( $id)))
{
sys_msg('ID は空', 1);
}

if(empty($material['name']) || empty($material['modulus']) || empty ($material['safe_day']) || empty($material['intent_day']))
{
sys_msg('名前、系数、安全天数、目标天数、空または者格式不确', 1);
}
/*处理图片*/
if(!empty($_FILES['img']['name']))
{
$material['img'] = Basename($image->upload_image($ _FILES['img'],'material'));
}
/*处理URL*/
$material['buy_url'] = sanitize_url($_POST['buy_url']);
/*插入稿*/
$db->autoExecute($ecs->table('materials'), $material, 'UPDATE', "id = '$id'");
$link[0]['text'] = '继续编辑';
$link[0]['href'] = 'materials.php?act=edit&id='.$id;
$link[1]['text'] = '返列表';
$link[ 1]['href'] = 'materials.php?act=list';
sys_msg('编辑成功', 0, $link);
}
elseif ($_REQUEST['act'] =='edit')
{
$sql = "SELECT * FROM " .$ecs->table('materials'). " WHERE";
$material = $db->GetRow($sql);
$smarty->assign('ur_here', "编辑物材");
$smarty->assign('action_link', array ('href' => 'materials.php?act=list', 'text' => '返物料库存列表'));
$smarty->assign('material', $material);
$ Smarty->assign('form_action', 'updata');
assign_query_info();
$smarty->display('material_info.htm');
}
elseif ($_REQUEST['act'] == '削除')
{
$id = intval($_GET['id']);
$exc->drop($id);
$url = 'materials.php?act=query&' 。 str_replace('act=remove', '', $_SERVER['QUERY_STRING']);
ecs_header("Location: $urln");
exit;
}
elseif ($_REQUEST['act'] == 'drop_img】 ')
{
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$sql = "SELECT img FROM " .$ecs->table('materials'). " WHERE id = '$id'";
$img_name = $db->getOne($sql);
if (!empty($img_name))
{
{
@unlink(ROOT_PATH . DATA_DIR . '/material/' .$img_name);
$sql = "UPDATE " .$ecs->table('materials'). " SET img = '' WHERE id = '$id'";
$db->query($sql);
}🎜$link= array(array('text' => '編集を続ける', 'href' => 'materials.php?act=edit&id=' . $id), array('text' => '戻るマテリアルの在庫リスト', 'href' => 'materials.php?act=list'));
sys_msg('画像は正常に削除されました', 0, $link);
}
elseif ($_REQUEST['act'] = = 'edit_stock_in') //データベースに変更します
{
$id = intval($_POST['id']);
$val = json_str_iconv(trim($_POST['val']));
/*フォーマット */
if(!is_numeric($ val)|| $ val< 0)
、$ id); $_REQUEST['act'] == 'edit_stock_out') //在庫切れに変更
{
$id = intval($_POST['id']);
$val = json_str_iconv(trim($_POST['val' ]));
/* 形式を確認します*/
if(!is_numeric($val) || $val & lt; 0) {{
Make_json_error (sprintf ("" 形式が間違っています! ", $ Val); ). " where id = '".$id."'";
$material = $GLOBALS['db']->getRow($sql);
if($val > $material['stock_in'] + $ Material ['Stock_number'])
{
Make_json_Error (Sprintf ("アウトレットの数は、既存の在庫の合計とライブラリの合計を超えることはできません。 ", $val));
}

$exc->edit("stock_out='$val'", $id);
make_json_result(stripslashes($val));
}
elseif ($_REQUEST[' act'] == 'operate') //バッチイン/アウト
{
$sql = "UPDATE " .$ecs->table('materials') " SET 在庫番号 = 在庫番号 + 在庫イン - 在庫アウト,在庫アウト = 0 ,stock_in = 0,admin_id=$_SESSION[admin_id],update_time = ".gmtime();
$db->query($sql);
$link= array(array('text' => ' 資料を返す在庫リスト', 'href' => 'materials.php?act=list'));
sys_msg('成功したバッチエントリ/終了', 0, $link);
}
elseif ($_REQUEST ['act' ] == 'export') //発注書をエクスポートします
{
include_once('includes/PHPExcel/PHPExcel.php');
include_once('corlor.php');
$objPHPExcel = new PHPExcel() ;
$filename = '資材調達シート_'.date("YmdHi",gmtime());
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle($filename );
$objPHPExcel ->getActiveSheet()->getColumnDimension('A')->setWidth(15);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth (15);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')-> ;setWidth(10) ;
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('F') ->setWidth( 10);
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('H ')-> setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(10);
$objPHPExcel->getActiveSheet()->getColumnDimension( 'J')- >setWidth(10);
$objPHPExcel->getActiveSheet()->getStyle('C1')->getAlignment()->sethorizo​​ntal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel ->getActiveSheet( )->getStyle('D1')->getAlignment()->set水平(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('F1') ->getAlignment( )->set水平(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('G1')->getAlignment()->set水平(PHPExcel_Style_Alignment::HORI ZONTAL_RIGHT );
$objPHPExcel->getActiveSheet()->getStyle('H1')->getAlignment()->sethorizo​​ntal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('I1 ')->getAlignment()->sethorizo​​ntal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('J1')->getAlignment()->sethorizo​​ntal(PHPExcel_Style_Alignment: : 水平_右);
$ Objphpexcel-& GT; getColumndimension ('K')-& GT;
'マテリアル名') ->setCellValue( 'B1', '写真')
->setCellValue('C1', '毎日の使用量')
->setCellValue('D1', '既存の在庫')
->setCellValue('E1', '売上高日')
->setCellValue('F1', '安全在庫')
->setCellValue('G1', '目標在庫')
->setCellValue('H1', '推奨購入')
- >setCellValue('I1', '単価')
->setCellValue('J1', '実際の単価')
->setCellValue('K1', '購入リンク');
$i=2 ;
$ stock_list = material_list(false);
$ arr = $ stock_list ['stock_list']; getActiveSheet() - > getRowDimension($ i) - > setRowheight; >setDescription('Pgoods サム'); /'.$v['img'] : '../images/no_img.jpg';
$objDrawing->setPath($img_path);描画-> ;set座標( 'b'。$ i); objphpexcel-> )
- > setCellValue( 'd'。$ i、$ v ['stock_number'])
- > setCellValue( 'e'。$ i、$ v ['stock_day'])
- - > setCellValue('H'.$i, $v['proposal_buy'])
.$i, '')->getFont()->getColor()->setARGB(PHPExcel_Style_色:: COLOR_RED);
}
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('K'.$i, '購入リンク');
            $objPHPExcel->setActiveSheetIndex(0)->getCell('K'.$i)->getHyperlink()->setUrl($v['buy_url']);
$objPHPExcel->setActiveSheetIndex(0 )->getCell('K'.$i)->getHyperlink()->setTooltip('采购链接');
$objPHPExcel->setActiveSheetIndex(0)->getStyle('K'.$ i)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_BLUE);
$objPHPExcel->setActiveSheetIndex(0)->getStyle('K'.$i)-> getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
}
else
{
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('K '.$i, '');
}
$ objPHPExcel->getActiveSheet()->getStyle('A'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle( 'B'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$i)->getAlignment( )->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()-> getStyle('F'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$i)-> getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('H'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER );
$objPHPExcel->getActiveSheet()->getStyle('I'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()- >getStyle('J'.$i)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('K'.$i)- >getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$i++;
}
$file_name = $filename.'.xls';
header('Content-Type: application/vnd.ms-excel' );
header('Content-Disposition:attachment;filename="'.$file_name.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter( $objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
elseif ($_REQUEST['act'] == 'query')
{
$ Stock_list =material_list();
$smarty->assign('stock_list', $stock_list['stock_list']);
$smarty->assign('filter', $stock_list['filter']);
$ Smarty->assign('record_count', $stock_list['record_count']);
$smarty->assign('page_count', $stock_list['page_count']);
make_json_result($smarty->fetch( 'material_list.htm'), '', array('filter' => $stock_list['filter'], 'page_count' => $stock_list['page_count']));
}
functionmaterial_list($is_pagination = true)
{
GLOBAL $ecs,$db;
$result = get_filter();
if ($result === false)
{
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'id' : トリム($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'desc' : trim($_REQUEST['sort_order']);
$where = " WHERE 1 = 1 ";
$sql = 'select count(t.id) from '.$ecs->table('materials ')。 ' as t '.$where;

$filter['record_count'] = $db->getOne($sql);

/* 分页大小 */
$filter = page_and_size($filter );

$ sql = '.
$ecs->table('materials') から t.*, au.user_name を選択します。'左のように join '.
$ecs->table('admin_user')." as au on t.admin_id=au.user_id ".$where.
' order by '.$filter['sort_by']" ".$filter['sort_order'];

if ($is_pagination)
{
$sql .= " LIMIT " . $filter['start'] 。 「、」。 $filter['page_size'];
}

$end_time = strtotime(date("Y-m-d",gmtime()));
$start_time = $end_time - 7 * 86400;
$クエリ = "SELECT カウント (order_id)合計として FROM ".$GLOBALS['ecs']->table('order_info')." WHERE synch_time = '".$start_time."'";
$filter['orders'] =round($GLOBALS['db']->getOne($query) / 7);//7天平均订单数
$filter['orders'] = $filter['命令』]? $filter['注文'] : 1400;
set_filter($filter, $sql);
}
else
{
$sql = $result['sql'];
$filter = $result['filter'];
}
$row = $GLOBALS[' db']->getAll($sql);

$orders = $filter['orders'];
foreach($row as $k=>$val)
{
if ($is_pagination == false && $val['is_buy'] == 0) //不购买,不导出
{
unset($row[$k]);
Continue;
}

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート