lvhao 2 kuukautta sitten
vanhempi
commit
dba380f32c

+ 162 - 2
core/CoreApp/controllers/Amazonbarcode.php

@@ -5,6 +5,8 @@ class Amazonbarcode extends Start_Controller {
 		parent::__construct();
 		$this->load->_model('Model_amazonbarcode','amazonbarcode');
 		$this->load->_model('Model_excel','excel');
+		$this->load->_model('Model_amazonbarcodeitems','amazonbarcodeitems');
+		
 	}
 	//定义方法的调用规则 获取URI第二段值
     public function _remap($arg,$arg_array)
@@ -32,7 +34,12 @@ class Amazonbarcode extends Start_Controller {
 		else if($arg == 'del')
         {
              $this->_del();
-        }
+			 
+        }else if($arg == 'outpage'){
+			$this->_outPage();
+		}else if($arg == 'outcount'){
+			$this->_outCount($arg_array);
+		}
 		else
 		{
 			 $this->_index();
@@ -125,9 +132,14 @@ class Amazonbarcode extends Start_Controller {
 			$label = $this->input->post('label',true);
 			$print = $this->input->post('print',true);
 			$xztime = $this->input->post('xztime',true);
+			$batch_no = $this->input->post('batch_no',true);
 			$timetk = strtotime($timetk);
 			$timetj = strtotime($timetj);
 			$where = "1=1";
+			if($batch_no)
+            {
+                $where  .= " and batch_no = '$batch_no'";
+            }
 			if($number)
             {
                 $where  .= " and number = '$number'";
@@ -155,7 +167,7 @@ class Amazonbarcode extends Start_Controller {
 		    {
                 $start = ($page - 1)*$perpage;
             }
-			$info_list = $this->amazonbarcode->find_all($where,'id,number,label,label2,num,time,addtime',$order_str,$start,$perpage);
+			$info_list = $this->amazonbarcode->find_all($where,'id,batch_no,number,label,label2,num,out_num,time,addtime',$order_str,$start,$perpage);
             foreach ($info_list as $key=>$value) 
 		    {
 				if($value['time'] != 0)
@@ -174,6 +186,7 @@ class Amazonbarcode extends Start_Controller {
 				{
 					$info_list[$key]['addtime'] = '';
 				}
+				$info_list[$key]['out_num'] = $value['out_num']*1;
             }
 			$total = $this->amazonbarcode->find_count($where);
 		    $pagenum = ceil($total/$perpage);
@@ -321,6 +334,26 @@ class Amazonbarcode extends Start_Controller {
                 }
 			}
 			$i = 0;$j = 0;$ed = array();$time = time();
+			$laster_info = $this->amazonbarcode->find("","","id desc");
+
+			$batch_no = date('Ymd',time());
+			if(empty($laster_info['batch_no'])){
+				$batch_no = date('Ymd',time()).'-001';
+			}else{
+				$tmp_arr = explode('-',$laster_info['batch_no']);
+				if($tmp_arr[0] == $batch_no){
+					$tmp_num = ($tmp_arr[1]*1)+1;
+					if($tmp_num < 10){
+						$batch_no = date('Ymd',time()).'-00'.$tmp_num;
+					}elseif($tmp_num < 100){
+						$batch_no = date('Ymd',time()).'-0'.$tmp_num;
+					}else{	
+						$batch_no = date('Ymd',time()).'-'.$tmp_num;
+					}
+				}else{
+					$batch_no = date('Ymd',time()).'-001';
+				}
+			}
 		    foreach ($list as $key=>$value)
 		    {
 				$time = time();
@@ -328,6 +361,7 @@ class Amazonbarcode extends Start_Controller {
 				{
 					continue;
 				}
+				$post['batch_no'] = $batch_no;
 				$post['number'] =  $value['0'];
 				$post['label'] =  ($value['1'])?$value['1']:'';
 				$post['label2'] =  ($value['2'])?$value['2']:'';
@@ -345,6 +379,7 @@ class Amazonbarcode extends Start_Controller {
 					$j++;
 					continue;
 				}
+				
 				$this->amazonbarcode->insert($post);
 			}
 			if($j > 0)
@@ -370,4 +405,129 @@ class Amazonbarcode extends Start_Controller {
 			}
 		}
 	}
+	//出库计数
+	public function _outPage(){
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['page']))  
+		{
+		    $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+			$timetk = $this->input->post('timetk',true);
+			$timetj = $this->input->post('timetj',true);
+			$number = $this->input->post('number',true);
+			$label = $this->input->post('label',true);
+			$print = $this->input->post('print',true);
+			$xztime = $this->input->post('xztime',true);
+			$batch_no = $this->input->post('batch_no',true);
+			$timetk = strtotime($timetk);
+			$timetj = strtotime($timetj);
+			$where = "1=1";
+			if($batch_no)
+            {
+                $where  .= " and batch_no = '$batch_no'";
+            }
+			if($number)
+            {
+                $where  .= " and number = '$number'";
+            }
+			if($label)
+            {
+				$where  .= " and label = '$label'";
+            }
+			if($print != '')
+            {
+                $where  .= " and print = '$print'";
+            }
+			if($timetk && $timetj)
+            {
+                $where  .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
+            }
+            //数据排序
+            $order_str = $xztime." desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+			$info_list = $this->amazonbarcode->find_all($where,'id,batch_no,number,num,out_num,time,addtime',$order_str,$start,$perpage);
+            foreach ($info_list as $key=>$value) 
+		    {
+				if($value['time'] != 0)
+				{
+				    $info_list[$key]['time'] = date('Y-m-d H:i',$value['time']);
+				}
+				else
+				{
+					$info_list[$key]['time'] = '';
+				}
+				if($value['addtime'] != 0)
+				{
+				    $info_list[$key]['addtime'] = date('Y-m-d H:i',$value['addtime']);
+				}
+				else
+				{
+					$info_list[$key]['addtime'] = '';
+				}
+				$info_list[$key]['out_num'] = $value['out_num']*1;
+            }
+			$total = $this->amazonbarcode->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    echo json_encode($rows);exit;
+		}
+		$this->_Template('amazonbarcode_count',$this->data);
+	}
+
+	public function _outCount($arg_array){
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['id']))
+		{
+			if(!empty($post['id'])){
+				$info = $this->amazonbarcode->read($post['id']);
+				if(empty($info)){
+				 	echo	json_encode([
+						"code"=>0,
+						"msg"=>"请求数据不存在",
+						"data"=>['num'=>0],
+					]);
+					exit;
+				}
+				$info['out_num'] = $info['out_num']*1 +1;
+				$this->amazonbarcode->save(array('out_num'=>$info['out_num']),$post['id']);
+				$this->amazonbarcodeitems->insert([
+					'aid'=>(int)$post['id'],
+					'number'=>$info['number'],
+					'addtime'=>time()
+				]);
+				echo	json_encode([
+					"code"=>1,
+					"msg"=>"ok",
+					"data"=>['num'=>$info['out_num']],
+				]);
+				exit;
+			}else{
+				
+					echo json_encode([
+						"code"=>0,
+						"msg"=>"请求参数有无",
+						"data"=>['num'=>0],
+					]);
+					exit;
+				
+			}
+			
+			
+		}
+		$arg_array = $arg_array[0];
+		$amazonbarcode = $this->amazonbarcode->read($arg_array);
+		$this->data['info'] = $amazonbarcode;
+
+		$this->_Template('amazonbarcode_check',$this->data);
+	}
+	
 }

+ 15 - 0
core/CoreApp/models/Model_amazonbarcodeitems.php

@@ -0,0 +1,15 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
+class Model_amazonbarcodeitems extends Lin_Model 
+{
+	function __construct(){
+	parent::__construct();
+	$this->load->database();
+	$this->table = 'amazonbarcode_items';
+    $this->load_table('amazonbarcode_items');
+}
+	/** 通过名称查找 */
+	public function get_label($label)
+	{
+		return  $this->find("label = '$label'");	
+	}
+}  //end class

+ 4 - 1
template/erp/amazonbarcode.html

@@ -3,6 +3,7 @@
 <div class="warp">
 <div class="fixed">
 <ul class="search">
+<li>批次号:<input value="" name="batch_no" type="text"></li>
 <li>条码:<input value="" name="number" type="text"></li>
 <li>标签:<input value="" name="label" type="text" style="width:250px;"></li>
 <li>打印状态:<select name="print" class="select">
@@ -28,10 +29,12 @@
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
 <td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
+<td>批次号</td>
 <td>条码</td>
 <td>标签</td>
 <td>标签2</td>
 <td>数量</td>
+<td>出库数量</td>
 <td>打印时间</td>
 <td>导入时间</td>
 </tr>
@@ -47,7 +50,7 @@
 <script>
 var dataurl = "/amazonbarcode";
 var editurl = "/amazonbarcode/edit/";
-var editdj = 1;
+var editdj = 2;
 var editt = "亚马逊导表管理 - 修改";
 var customon = 1;
 function custom(){

+ 99 - 0
template/erp/amazonbarcode_check.html

@@ -0,0 +1,99 @@
+{Template header}
+<body>
+<div class="warp">
+<ul class="setting">
+
+<li class="length">
+<em>批次号:</em>
+<input  class="must" value="{$info['batch_no']}" readonly type="text">
+</li>
+
+<li class="length">
+<em>条码:</em>
+<input class="must" value="{$info['number']}" readonly type="text">
+</li>
+<li class="length">
+<em>出库数量:</em>
+<input class="must" id="out_num" value="{$info['out_num']}" readonly type="text">
+</li>
+    
+
+<li class="length">
+    <em>扫码窗口:</em>
+    <input class="must" name="sace_val"  value=""  type="text">
+</li>
+<input type="hidden" name="id" value="{$info['id']}" />
+<div style="clear:both;"></div>
+</ul>
+<div class="button"> <font class="gb">关 闭</font></div>
+</div>
+
+<audio id="music_d">
+<source src="{$theme}music/d.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_c">
+<source src="{$theme}music/c.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print">
+<source src="{$theme}music/print.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_error">
+<source src="{$theme}music/print_error.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_ok">
+<source src="{$theme}music/print_ok.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_jiaji">
+    <source src="{$theme}music/jiaji.mp3" type="audio/mpeg">
+</audio>
+<script>
+$('input[name="sace_val"]').focus();
+$(document).keyup(function(event) {
+    if(event.keyCode == 13){
+        $('input[name="sace_val"]').blur();
+        var sace_val = $('input[name="sace_val"]').val();
+        if(sace_val.length == 0){
+            return false;
+        }
+        var id = $('input[name="id"]').val();
+        layx.load('loadId','数据加载中,请勿扫码...');
+        $('input[name="sace_val"]').val("");
+        $.ajax({
+            type: "POST",
+            url: "/amazonbarcode/outcount",    
+            data: {number:sace_val,id:id},
+            dataType: "json",
+            success: function(data){
+                layx.destroy('loadId');
+                $('input[name="sace_val"]').focus();
+                if(data.code == 1){
+                    $("#music_d")[0].play();
+                    $('input[name="sace_val"]').val("");
+                    $('input[name="sace_val"]').focus();
+                    $("#out_num").val(data.data.num)
+                }else{
+
+                    layx.alert('提示',data.msg);
+                    $("#music_c")[0].play();
+                    $('input[name="sace_val"]').val("");
+                    $('input[name="sace_val"]').focus();
+                }
+            }
+        });
+    }
+})
+$(".gb").click(function() {
+    
+    window.parent.outter();      
+    var id;
+    if (self != top && self.frameElement && self.frameElement.tagName == "IFRAME") {
+        var layxWindow = $(self.frameElement).parents(".layx-window");
+        id = layxWindow.attr("id").substr(5);
+    }
+    window.parent.djsearch();
+    parent.layx.destroy(id);
+   
+});
+</script>
+<script type="text/javascript" src="{$theme}js/ajaxupload.3.5.js"></script>
+{Template footer}

+ 97 - 0
template/erp/amazonbarcode_count.html

@@ -0,0 +1,97 @@
+{Template header}
+<body>
+<div class="warp">
+<div class="fixed">
+<ul class="search">
+<li>批次号:<input value="" name="batch_no" type="text"></li>
+<li>条码:<input value="" name="number" type="text"></li>
+时间筛选:<select name="xztime" class="select">
+<option value="addtime">导入时间</option>
+<option value="time">打印时间</option>
+</select>
+</li>
+<li><input id="timetk" value="{date('Y-m-d',time()-30*24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly>
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="timetj" value="{date('Y-m-d',time()+24*3600)} 0:00" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})" readonly></li>
+<li><span>确 定</span></li>
+</ul>
+
+<table class="datatitle data" border="0" style="border-collapse:collapse;">
+<tr>
+<td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
+<td>批次号</td>
+<td>点击条码扫码出库</td>
+<td>数量</td>
+<td>出库数量</td>
+<td>打印时间</td>
+<td>导入时间</td>
+</tr>
+</table>
+</div>
+<table class="datatext data" border="0" style="border-collapse:collapse;">
+</table>
+<div class="bomf"></div>
+</div>
+<span class="none">
+<input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file">
+</span>
+<script>
+var dataurl = "/amazonbarcode/outpage/";
+var editurl = "/amazonbarcode/outcount/";
+var editdj = 2;
+var editt = "亚马逊出库核对";
+var customon = 1;
+function custom(){
+$(".data tr").each(function() {
+$(this).find('td:eq(0)').css("width","1%");
+$(this).find('td:eq(2)').css("width","8%");
+$(this).find('td:eq(4)').css("width","4%");
+$(this).find('td:eq(5)').css("width","8%");
+$(this).find('td:eq(6)').css("width","8%");
+$(this).find('td:eq(7)').css("width","8%");
+});}
+
+$(".amazondrexcel").click(function() {
+var dr = $(this);
+$("#upload-file").click();
+$("#upload-file").unbind("change");
+$("#upload-file").bind("change",function(){
+amazondrexcel(dr);
+	layx.load('loadId','导入中,请稍后',{shadable:0.6});
+});
+});
+
+function amazondrexcel(dr){
+var file = document.getElementById("upload-file").files[0];
+var data = new FormData();
+data.append("userfile",file);
+$.ajax({
+data : data,
+type : "POST",
+url : "/amazonbarcode/addexcel/",
+cache : false,
+contentType : false,
+processData : false,
+dataType:"json",
+success: function(a) {
+	 layx.destroy('loadId');
+            if (a && a.success) {
+				 if(a.error == 1)
+				 {
+					 errora(a);
+				 }
+				 else
+				 {
+					  errorb(a);
+				 }
+            } else {
+				errorc(a);
+            }
+        }
+});
+}
+function djsearch(){
+	searchspan(1);
+}
+</script>
+<script type="text/javascript" src="{$theme}js/laydate.js"></script>
+{Template footer}

+ 8 - 6
template/erp/systembound.html

@@ -39,12 +39,7 @@
 <font class="cona dowot">下载Excel</font>
 </li>
 
-<li>
-<font class="cona dchc" data-type="hc">导出惠程计数</font>
-</li>
-<li>
-<font class="cona dchc" data-type="ozyt">导出云途(欧洲)计数</font>
-</li>
+
 <li>
 <font class="cona obadd">添加信息</font>
 </li>
@@ -53,6 +48,13 @@
 <font class="cona obdel">删除</font>
 </li>
 {/if}
+
+<li>
+<font class="cona dchc" style="background-color: #FD5 !important;" data-type="hc">导出惠程计数</font>
+</li>
+<li>
+<font class="cona dchc" style="background-color: #FD5 !important;"  data-type="ozyt">导出云途(欧洲)计数</font>
+</li>
 </ul>
 <ul class="exdata"></ul>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">