getPmList();
$result['itemList'] = $pmNameList;
$res = $this->getHttp('storage-allocate/coach/list/' . $page, 'POST', $params);
$result['schoolName']=$this->schoolInfo['school_name'];
$result['list'] = array();
if ($res['status'] == 1) {
$result['list'] = $res['data']['list'];
$result['page'] = $res['data'];
} else {
$result['list'] = array();
$result['page'] = array();
}
$this->render('allocation', $result);
}
/**
* 耗材调拨申请
*/
public function actionApplyAllocation(){
$atId = Req::get('atId');
if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
$param['coach_name']=Yii::app()->session['coachInfo']['real_name'];
}else{
$param['coach_name']=Yii::app()->session['coachInfo']['coach_name'];
}
//发货仓库
$warehouse = $this->getHttp('storage/type/item/0/3','GET');
$data['warehouse'] = isset($warehouse['data']) && $warehouse['data'] ? $warehouse['data'] : '';
//查询所有零件
$partRs=$this->getHttp('fixed/part/list/all','GET');
$data['part_list']='';
if($partRs['status']==1){
if($partRs['data']){
$partHtml='";
$data['part_list']=$partHtml;
}
}
//读取品目类型
$res = $this->getHttp('storage-inventory/coach/low/list/3','GET');
if ($res['status'] == 1) {
$data['pm_type']=$res['data'];
}else{
$this->errorMsg('品目类型读取失败');
}
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$data['uploadUrl'] = $url;
$data['basic'] = $this->setToken();
if($atId){
$res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
$warehouseKeyVal = $data['warehouse'] ? _array_column($data['warehouse'],'storageName','storageId') : array();
if($res1['status']==1){
$data['title']=$res1['data']['atTitle'];
$data['deliverName']=$res1['data']['deliverName']; //总仓
$data['consignorName']=$res1['data']['consignorName']; //管理员
$data['school_name']=$this->schoolInfo['school_name'];
$data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
$data['receiveUser']=$res1['data']['receiver'];
$data['telephone']=$res1['data']['receiveMobile'];
$data['address']=$res1['data']['receivePlace'];
$data['remark']=$res1['data']['remark'];
$data['atCode']=$res1['data']['atCode'];
$data['atId']=$res1['data']['atId'];
$data['images']=$res1['data']['images'];
$data['deliverStorage']=$res1['data']['deliverStorage'];
$data['deliverStorageName']=isset($warehouseKeyVal[$res1['data']['deliverStorage']]) ? $warehouseKeyVal[$res1['data']['deliverStorage']] : '';
$data['receiveStorage']=$res1['data']['receiveStorage'];
$data['operateType']='edit';
if($res1['data']['details']){
foreach ($res1['data']['details'] as $val){
$data['allocateDetail'][]=array(
'itemId'=>$val['itemId'],
'itemName'=>$val['itemName'],
'applyNo'=>$val['applyNo'],
'invNo'=>$val['invNo'],
'unitName'=>$val['unitName'],
'typeName'=>$val['typeName']
);
}
}
//零件
if($res1['data']['partDetailList']){
foreach ($res1['data']['partDetailList'] as $val){
//加载设备列表
$device = $this->getHttp('storage-inventory/query-fixed/list/'.$val['fpTypeId'].'/'.$data['receiveStorage'], 'get');
$deviceHtml='';
$deviceHtml='';
$val['device_list']=$deviceHtml;
$partHtml='";
$val['part_list']=$partHtml;
$data['partDetailList'][]=$val;
}
}
$this->render('allocationEdit',$data);
exit;
}else{
$this->errorMsg('ID不正确');
}
}else{
// debug($this->schoolInfo);
$data['title']=$this->schoolInfo['school_name'].'-'.$param['coach_name'].'的耗材调拨申请'.date('Ymd');
$data['school_name']=$this->schoolInfo['school_name'];
$data['coach_name']=$param['coach_name'];
$data['coach_phone']=$this->coachInfo['telephone'];
$data['address']=$this->schoolInfo['address'];
$data['operateType']='add';
}
$this->render('allocationCreate',$data);
}
/**
* 品目列表
*/
public function actionInventory(){
$type=Req::post('type');
$name=Req::post('name');
$page=Req::post('page');
$warehouse=Req::post('warehouse');
$params=array();
if($type){
$params['typeId']=$type;
}
if(!$page) $page=1;
if($name){
$params['itemName']=$name;
}
$params['storageId'] = $warehouse;
// debug($params);
$res = $this->getHttp("storage-inventory/coach/not-in-part-type/{$page}", 'POST', $params);
//debug($res);
$result['list'] = array();
$result['now_page'] = $page;
if ($res['status'] == 1) {
$result['list'] = $res['data']['list'];
//$result['total_page'] = $res['data']['lastPage'];
$result['total_page'] = $res['data']['pages'];
} else {
$result['list'] = array();
$result['total_page'] = array();
}
exit(json_encode(array('status'=>1,'data'=>$result)));
}
/**
* 调拨申请
*/
public function actionApplySubmit(){
$result['status']=0;
$warehouse=Req::post('warehouse');
$allocateDetail=Req::post('allocateDetail');
$receiveDate=Req::post('receiveDate');
$receiveUser=Req::post('receiveUser');
$telephone=Req::post('telephone');
$address=Req::post('address');
$remark=Req::post('remark');
$img = Req::post('img');
$receiveStorage=Req::post('receiveStorage');
$partDetail=Req::post('partDetail');
if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
exit(json_encode($result));
}
if(strtotime($receiveDate)session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
$coach_name=Yii::app()->session['coachInfo']['real_name'];
}else{
$coach_name=Yii::app()->session['coachInfo']['coach_name'];
}
$params['alType']=3;
$params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
$params['deliverStorage']=$warehouse;
$params['receivePlace']=$address;
$params['receiver']=$receiveUser;
$params['receiveMobile']=$telephone;
$params['arriveDate']=$receiveDate;
$params['remark']=$remark;
$params['consigneeName']=$receiveUser;
$params['doorDoor']=0;
$params['images']=$img;
$params['transportType']=1;
$params['receiveStorage']=$receiveStorage;
if($allocateDetail){
foreach ($allocateDetail as $val){
@$idNum=explode('///',$val);
if(isset($idNum[0]) && isset($idNum[1])){
$params['requestAllocateDetail'][]=array(
'itemId'=>$idNum[0],
'applyNo'=>round($idNum[1],6),
);
}
}
}
if($partDetail){
foreach ($partDetail as $val){
$partArr=explode('///',$val);
if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
$params['partReqDTOList'][]=array(
'applyNo'=>round($partArr[0],6),
'fpTypeId'=>$partArr[1],
'fcId'=>$partArr[2]
);
}
}
}
$res = $this->getHttp("storage-allocate/coach/add", 'POST', $params);
if($res['status']==1){
$result['status']=1;
}else{
$result['msg']=$res['msg'];
}
exit(json_encode($result));
}
/**
* 编辑调拨申请
*/
public function actionApplyEdit(){
$result['status']=0;
$allocateDetail=Req::post('allocateDetail');
$receiveDate=Req::post('receiveDate');
$receiveUser=Req::post('receiveUser');
$telephone=Req::post('telephone');
$address=Req::post('address');
$remark=Req::post('remark');
$atCode=Req::post('atCode');
$atId=Req::post('atId');
$img = Req::post('img');
$warehouse=Req::post('warehouse');
$receiveStorage=Req::post('receiveStorage');
$partDetail=Req::post('partDetail');
if(!$warehouse || !$receiveDate || !$receiveUser || !$telephone || !$address || !$receiveStorage || !$img || (!$allocateDetail && !$partDetail)){
exit(json_encode($result));
}
if(strtotime($receiveDate)session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
$coach_name=Yii::app()->session['coachInfo']['real_name'];
}else{
$coach_name=Yii::app()->session['coachInfo']['coach_name'];
}
$params['alType']=3;
$params['atTitle']=$this->schoolInfo['school_name'].'-'.$coach_name.'的耗材调拨申请'.date('Ymd');
$params['deliverStorage']=$warehouse;
$params['receivePlace']=$address;
$params['receiver']=$receiveUser;
$params['receiveMobile']=$telephone;
$params['arriveDate']=$receiveDate;
$params['remark']=$remark;
$params['consigneeName']=$receiveUser;
$params['doorDoor']=0;
$params['transportType']=1;
$params['atCode']=$atCode;
$params['atId']=$atId;
$params['images']=$img;
$params['receiveStorage']=$receiveStorage;
if($allocateDetail){
foreach ($allocateDetail as $val){
@$idNum=explode('///',$val);
if(isset($idNum[0]) && isset($idNum[1])){
$params['requestAllocateDetail'][]=array(
'itemId'=>$idNum[0],
'applyNo'=>round($idNum[1],6),
);
}
}
}
if($partDetail){
foreach ($partDetail as $val){
$partArr=explode('///',$val);
if(isset($partArr[0]) && isset($partArr[1]) && isset($partArr[2])){
$params['partReqDTOList'][]=array(
'applyNo'=>round($partArr[0],6),
'fpTypeId'=>$partArr[1],
'fcId'=>$partArr[2]
);
}
}
}
$res = $this->getHttp("storage-allocate/coach/edit", 'POST', $params);
if($res['status']==1){
$result['status']=1;
}else{
$result['msg']=$res['msg'];
}
exit(json_encode($result));
}
/**
* 调拨查看物流/确认收货
*/
public function actionAllocationView()
{
$result = array();
$atId = trim(Req::get('atId'));
$result['atId'] = $atId;
$result['sendData'] = array();
$result['receiveData'] = array();
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
if ($atId) {
//发货记录
$sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
if ($sendRes['status'] == 1) {
$result['sendData'] = $sendRes['data'];
$logisticsTime = array();
foreach ($sendRes['data'] as $v){
$logisticsTime[] = $v['logisticsTime'];
}
$_logisticsTime = time() - strtotime(min($logisticsTime));
if($_logisticsTime){
$result['logisticsTime'] = floor($_logisticsTime/(24*3600));
}else{
$result['logisticsTime'] = 0;
}
} else {
$this->errorMsg($sendRes['msg']);
}
//收货记录
$receiveRes = $this->getHttp('storage-allocate/coach/receive-record/' . $atId, 'get');
if ($receiveRes['status'] == 1) {
foreach ($receiveRes['data'] as $value) {
$result['receiveData'][$value['atoId']] = $value;
}
} else {
$this->errorMsg($receiveRes['msg']);
}
$res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
if($res1['status']==1){
if(isset($res1['data']['resDTOList'])){
$result['logList']=$res1['data']['resDTOList'];
}else{
$result['logList']=array();
}
}
} else {
$this->errorMsg('调拨ID不正确');
}
//debug($result);
$this->render('allocationView', $result);
}
/**
* 确认收货
*/
public function actionAjaxReceipt()
{
$result = array();
$error = array();
$atId = Req::post('atId');
$atoId = Req::post('atoId');
$qualifiedNo = round(Req::post('qualifiedNo'),6);
$scrapNo = round(Req::post('scrapNo'),6);
$tallyNo = round(Req::post('tallyNo'),6);
$picUrl = (array)Req::post('imgArr');
$fixedCodes = (array)Req::post('fixedCodes');
$params = array(
'atId' => $atId,
'atoId' => $atoId,
'images' => $picUrl,
'qualifiedNo' => $qualifiedNo, //合格
'tallyNo'=>$qualifiedNo, //记账
'scrapNo' => $scrapNo, //不合格
'arriveNo'=> $tallyNo, //到账
'itemId' => Req::post('itemId'),
'fixedCodes' => $fixedCodes
);
$res = $this->getHttp('storage-allocate/coach/receipt', 'post', $params);
$this->imsLog("仓库调拨-确认收货",'storage-allocate/coach/receipt',$params,$res);
if ($res['status'] == 1) {
$result = $res['data'];
} else {
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
', $error)));
} else {
echo json_encode(array('status' => 1, 'data' => $result));
}
}
/**
* 调拨查看物流/确认收货
*/
public function actionAllocationViewDetail()
{
$atId = Req::get('atId');
$data = array();
if($atId){
$res1 = $this->getHttp('storage-allocate/coach/details/'.$atId,'GET');
if($res1['status']==1){
$data['title']=$res1['data']['atTitle'];
$data['deliverName']=$res1['data']['deliverName']; //总仓
$data['consignorName']=$res1['data']['consignorName']; //管理员
$data['school_name']=$this->schoolInfo['school_name'];
$data['receiveDate']=date('Y-m-d',strtotime($res1['data']['arriveDate']));
$data['receiveUser']=$res1['data']['receiver'];
$data['telephone']=$res1['data']['receiveMobile'];
$data['address']=$res1['data']['receivePlace'];
$data['remark']=$res1['data']['remark'];
$data['atCode']=$res1['data']['atCode'];
$data['atId']=$res1['data']['atId'];
$data['images']=$res1['data']['images'];
$data['receiveName']=$res1['data']['receiveName'];
if(isset($res1['data']['resDTOList'])){
$data['logList']=$res1['data']['resDTOList'];
}else{
$data['logList']=array();
}
if($res1['data']['details']){
foreach ($res1['data']['details'] as $val){
$data['allocateDetail'][]=array(
'itemId'=>$val['itemId'],
'itemName'=>$val['itemName'],
'applyNo'=>$val['applyNo'],
'invNo'=>$val['invNo'],
'unitName'=>$val['unitName'],
'typeName'=>$val['typeName']
);
}
}
if($res1['data']['partDetailList']){
$data['partDetail']=$res1['data']['partDetailList'];
}
//读取问调表
$res = $this->getHttp('storage-allocate/coach/experience-info/'.$atId,'GET');
if($res['status']==1){
$data['survey']=$res['data'];
}
$this->render('allocationViewDetail',$data);
exit;
}else{
$this->errorMsg('ID不正确');
}
}
}
/***************** 销售出库 *****************/
/**
* 销售出库列表
*/
public function actionDelivery()
{
$result = array();
$params = array();
$page = Req::get('page') ? Req::get('page') : 1;
if (Req::get('isUse')) {
$params['isUse'] = Req::get('isUse')-1;
}
if (Req::get('itemId')) {
$params['itemId'] = Req::get('itemId');
}
if (Req::get('startDate')) {
$params['startOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
}
if(Req::get('endDate')){
$params['endOutDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
}
//品目名称
$pmNameList = $this->getPmList();
$result['itemList'] = $pmNameList;
$res = $this->getHttp('storage-output/coach/list/' . $page, 'POST',$params);
$result['pmDataList'] = array();
if ($res['status'] == 1) {
$result['pmDataList'] = $res['data'];
}
$result['useOutType']='use';
$this->render('delivery', $result);
}
/*销售退库*/
public function actionDeliveryOut(){
$result = array();
$params = array();
$page = Req::get('page') ? Req::get('page') : 1;
if (Req::get('isUse')) {
$params['inputStatus'] = Req::get('isUse')-1;
}
if (Req::get('itemId')) {
$params['itemId'] = Req::get('itemId');
}
if (Req::get('startDate')) {
$params['startTime'] = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
}
if(Req::get('endDate')){
$params['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
}
//品目名称
$pmNameList = $this->getPmList();
$result['itemList'] = $pmNameList;
$params['pageNo'] = $page;
$res = $this->getHttp('storage-input/coach/sale/list/' , 'POST',$params);
$result['pmDataList'] = array();
if ($res['status'] == 1) {
$result['pmDataList'] = $res['data'];
}
$result['useOutType']='out';
$this->render('deliveryOut', $result);
}
/*确认退库*/
public function actionSubmitSale(){
$inId = Req::post('inId');
$res = $this->getHttp('storage-input/coach/sale/'.$inId, 'put');
if ($res['status']){
returnMsg(1,$res['msg']);
}else{
returnMsg(0,$res['msg']);
}
}
/*退库学生列表*/
public function actionAjaxSaleStudentList(){
$inId = Req::post('inId');
$page=Req::post('page');
if(!$page) $page=1;
$res = $this->getHttp("storage-input/coach/students/{$inId}/{$page}", 'get');
if ($res['status']){
returnMsg(1,'',$res['data']);
}else{
returnMsg(0,$res['msg']);
}
}
/**
* 销售出库编辑
*/
public function actionDeliveryEdit()
{
$result = array();
$outId = Req::get('outId');
//品目名称
$pmNameList = $this->getSalePmList();
if (empty($pmNameList)){
$this->errorMsg('暂无出库品目,无法新增出库单!');
}
$result['pmNameList'] = $pmNameList;
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
if (is_numeric($outId) && $outId > 0) {
$res = $this->getHttp('storage-output/coach/' . $outId, 'get');
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
$result['total'] = $res['data']['outputDetails'][0]['no'];
//出库学生列表
$outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
$result['pmStudent'] = $outStudent['data'];
$result['reStudentCount'] = count($outStudent['data']);
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('出库单ID不正确!');
}
$this->render('deliveryEdit', $result);
}
/**
* 查看销售出库
*/
public function actionDeliveryView()
{
$result = array();
$outId = Req::get('outId');
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
if (is_numeric($outId) && $outId > 0) {
$res = $this->getHttp('storage-output/coach/' . $outId, 'get');
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['itemName'] = $res['data']['outputDetails'][0]['itemName'];
$result['itemId'] = $res['data']['outputDetails'][0]['itemId'];
$result['total'] = $res['data']['outputDetails'][0]['no'];
//出库学生列表
$outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
$result['pmStudent'] = $outStudent['data'];
// dd($outStudent);
$result['reStudentCount'] = count($outStudent['data']);
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('出库单ID不正确!');
}
$this->render('deliveryView', $result);
}
/**
* 销售出库增加
*/
public function actionDeliveryAdd()
{
$result = array();
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
//品目名称
$pmNameList = $this->getSalePmList();
if (empty($pmNameList)){
$this->errorMsg('暂无出库品目,无法新增出库单!');
}
$result['pmNameList'] = $pmNameList;
$result['pmData'] = array();
$this->render('deliveryAdd', $result);
}
/**
* 删除出库
*/
public function actionAjaxDelOut()
{
$outId = Req::post('outId');
$http = http('storage-output/coach/'.$outId, 'delete', $this->authUsername);
$response = formatResponse($http);
$this->imsLog("销售出库-删除出库",'storage-output/coach/'.$outId,array(),$response);
if ($response['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $response['data']);
}
}
/**
* 确认出库
*/
public function actionAjaxUseOut()
{
$outId = Req::post('outId');
$res = $this->getHttp('storage-output/coach/use/'.$outId, 'put');
if ($res['status']){
returnMsg(1,$res['msg']);
}else{
returnMsg(0,$res['msg']);
}
}
/**
* 销售出库编辑学生
* @throws CException
*/
public function actionAjaxEditStu(){
$result = array();
$error = array();
$hasSelected = array();
$orderId = trim(Req::post('orderId'));
$outId = Req::post('outId')?Req::post('outId'):0;
//正式订单列表的学生
$res = $this->getHttp('order/coach/official/sale-out/students/'.$orderId, 'get');
//出库学生列表
if($outId){
$outStudent = $this->getHttp('storage-output/coach/students/'.$outId,'get');
if ($outStudent['data']){
foreach ($outStudent['data'] as $k=>$v){
$hasSelected[$v['osId']] = $v;
}
}
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $this->renderPartial('_selectStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'outId'=>$outId), true)));
}
}
/**
* ajax销售出库增加
*/
public function actionAjaxDeliveryAdd(){
$result = array();
$error = array();
$orderId = Req::post('orderId');
$itemId = Req::post('itemId');
$outDate = Req::post('outDate');
$outTitle = Req::post('outTitle');
$stuGetNum = (int)Req::post('stuGetNum');
$stuIds= (array)Req::post('stuSeledArr');
$imgArr= (array)Req::post('imgArr');
//品目名称
$pmNameList = $this->getSalePmList();
$pmNameArr = array();
foreach($pmNameList as $value){
if($value['itemId'] == $itemId){
$pmNameArr = $value;
}
}
if(!$pmNameArr){
$error[] = '品目信息不正确!';
}
if(!$error){
$params = array(
'deliverStorage' => 0,
'itemType' => 2,
'orderId' => $orderId,
'osIds' => $stuIds,
'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
'outTitle' => $outTitle,
'outType' => 1,
'images' => $imgArr,
'outputDetails' => array(
array(
'itemCode' => $pmNameArr['itemCode'],
'itemId' => $pmNameArr['itemId'],
'itemName' => $pmNameArr['itemName'],
'itemSpec' => $pmNameArr['itemSpec'],
'no' => $stuGetNum*count($stuIds),
)
),
'useType' => 0,
'userId' => 0,
'userName' => '',
);
//编辑
if(Req::post('outId')){
$params['outId'] = Req::post('outId');
$res = $this->getHttp('storage-output/coach/edit', 'put',$params);
$this->imsLog("销售出库-编辑出库单",'storage-output/coach/edit',$params,$res);
}else{
//新增
$res = $this->getHttp('storage-output/coach/add', 'post',$params);
$this->imsLog("销售出库-新增出库单",'storage-output/coach/add',$params,$res);
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
}
/**
* 关联正式订单
*/
public function actionAjaxRelOrder(){
$error = array();
$result = array();
$page = (int)Req::post('page');
$orderId = Req::post('orderId');
$doType = Req::post('doType');
$page = $page ? $page : 1;
if($doType=='edit'){
//编辑单独调取
$res = $this->getHttp('order/coach/official/not-take/details/'.$page.'/except/'.$orderId, 'get');
}else{
$res = $this->getHttp('order/coach/official/not-take/details/'.$page, 'get');
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
}
/***************** 仓库盘点 *****************/
/**
* 盘点页面
*/
public function actionStock(){
$result = array();
$params = array();
$page = Req::get('page')?Req::get('page'):1;
if(Req::get('status')){
$params['status'] = Req::get('status')-1;
}
if(Req::get('lossType')){
$params['lossType'] = Req::get('lossType')-1;
}
if(Req::get('itemId')){
$params['itemId'] = Req::get('itemId');
}
if(Req::get('startStockDate')){
$params['startStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('startStockDate')));
}
if(Req::get('endStockDate')){
$params['endStockDate'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate')));
}
$res = $this->getHttp('storage-stock/coach/list/'.$page, 'post', $params);
if($res['status']){
$result['list'] = $res['data']['list'];
$result['page'] = $res['data'];
}else{
$result['list'] = array();
$result['page'] = array();
}
// debug($result['list']);
//所有品目
$item = $this->getHttp('item/all', 'get');
$result['itemList'] = $item['data'];
//审批状态
$dict = $this->getDict('process_apply_status');
$result['applyStatus'] = $dict;
$this->render('stock',$result);
}
/**
* 新增盘点
*/
public function actionStockAdd(){
$result = array();
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
$this->render('stockAdd',$result);
}
//保存更新数据
public function actionAjaxStockAdd(){
$params = array();
$params['stockTitle'] = Req::post('stockTitle');
$params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
$params['itemId'] = Req::post('itemId');
$params['itemCode'] = Req::post('itemCode');
$params['itemName'] = Req::post('itemName');
$params['itemSpec'] = Req::post('itemSpec');
$params['unit'] = Req::post('unitId');
$params['itemType'] = Req::post('itemType');
$params['theoreticalNo'] = Req::post('theoreticalNo');
$params['stockNo'] = Req::post('stockNo')?Req::post('stockNo'):0;
$params['images'] = (array)Req::post('imgArr');
$params['lossNo'] = Req::post('stockNo') - Req::post('theoreticalNo');
$params['fixedCodes'] = (array)Req::post('fixedCodes');
$params['invFixedCodes'] = (array)Req::post('invFixedCodes');
$params['remark'] = Req::post('remark');
if(Req::post('stockId')){
//编辑
$params['stockId'] = Req::post('stockId');
//详情
$detail = $this->getHttp('storage-stock/coach/'.$params['stockId'], 'get');
$params['processInfo'] = $detail['data']['processInfo'];
$response = $this->getHttp('storage-stock/coach/edit','put',$params);
$this->imsLog("销售盘点-重盘",'storage-stock/coach/edit',$params,$response);
}else{
$response = $this->getHttp('storage-stock/coach/add','post',$params);
$this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
}
if ($response['status']){
returnMsg(1,$response['msg']);
}else{
returnMsg(0,$response['msg']);
}
}
/**
* 重盘
*/
public function actionStockEdit(){
$result = array();
//品目
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
$stockId = Req::get('stockId');
//详情
$detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
if($detail['status']){
$result['detail'] = $detail['data'];
if(isset($detail['data']['remark'])){
$result['detail']['remark'] = $detail['data']['remark'];
}else{
$result['detail']['remark'] = '';
}
//品目
$itemType = $detail['data']['itemType'];
$http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
$result['itemList'] = $http['data'];
$this->render('stockEdit',$result);
}else{
Yii::app()->jump->error($detail['msg']);
}
}
//取消盘点
public function actionAjaxStopStock()
{
$businessKey = Req::post('businessKey');
$http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
$response = formatResponse($http);
$this->imsLog("销售盘点-取消",'activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
if ($response['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $response['data']);
}
}
//删除盘点
public function actionAjaxDeleteStock()
{
$businessKey = Req::post('businessKey');
$http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
$response = formatResponse($http);
$this->imsLog("销售盘点-删除",'activiti/coach/process-instances/'.$businessKey,array(),$response);
if ($response['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $response['data']);
}
}
/**
* 查看
*/
public function actionStockView()
{
$stockId = Req::get('stockId');
$processInstanceId = Req::get('processInstanceId');
//详情
$detail = $this->getHttp('storage-stock/coach/'.$stockId, 'get');
//审核人员
$process = $this->getHttp('activiti/coach/process-instances/'.$processInstanceId.'/trace','get');
if($detail['status']){
$result['detail'] = $detail['data'];
$result['process'] = $process['data']['tasks'];
$result['startUserName'] = $process['data']['startUserName'];
$result['createTime'] = $process['data']['createTime'];
$result['endTime'] = $process['data']['endTime'];
$result['itemTypeName'] = itemType($detail['data']['itemType']);
if(isset($detail['data']['remark'])){
$result['detail']['remark'] = $detail['data']['remark'];
}else{
$result['detail']['remark'] = '';
}
$this->render('stockView',$result);
}else{
Yii::app()->jump->error($detail['msg']);
}
}
//根据品类获取品目
public function actionGetItem()
{
$itemType = Req::post('itemType');
$http = $this->getHttp('storage-inventory/coach-item/'.$itemType, 'get');
if($http['status']){
if($http['data']){
returnMsg(1,'success',$http['data']);
}else{
returnMsg(0,'暂无数据');
}
}else{
returnMsg(0,$http['msg']);
}
}
//获取固定资产编号
public function actionGetFixCode()
{
$itemId = Req::post('itemId');
$http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
if($http['status']){
if($http['data']){
returnMsg(1,'success',$http['data']);
}else{
returnMsg(0,'暂无数据');
}
}else{
returnMsg(0,$http['msg']);
}
}
/**
* 获取审核内容
*/
public function actionGetTask()
{
$taskId = Req::post('taskId');
$task = $this->getHttp('activiti/coach/tasks/'.$taskId.'/form' ,'get');
if($task['status']){
returnMsg(1,'success',$task['data']);
}else{
returnMsg(0,$task['msg']);
}
}
/***************** 库存报表 *****************/
public function actionReport()
{
$params = array();
$result = array();
$page = Req::get('page')?Req::get('page'):1;
$itemId = trim(Req::get('itemId'));
$itemType = trim(Req::get('itemsType'));
if($itemId){
$params['itemId'] = Req::get('itemId');
}
if($itemType){
$params['itemIdType'] = $itemType;
}
//获取品目名称
$itemList = $this->getPmList();
$result['itemList'] = $itemList;
$res = $this->getHttp('storage-inventory/coach/report/'.$page, 'post',$params);
$result['list'] = array();
if ($res['status'] == 1) {
$result['list'] = $res['data']['list'];
$result['page'] = $res['data'];
} else {
$result['list'] = array();
$result['page'] = array();
}
$this->render('report', $result);
// $params = array();
// $result = array();
//
// $page = Req::get('page')?Req::get('page'):1;
// $itemId = trim(Req::get('itemId'));
//
// if($itemId){
// $params['itemId'] = Req::get('itemId');
// }
//
// //获取品目名称
// $itemList = $this->getPmList();
// $result['itemList'] = $itemList;
//
// $res = $this->getHttp('storage-inventory/report-coach/'.$page, 'post',$params);
// $result['reportList'] = array();
// if ($res['status'] == 1) {
// $result['reportList'] = $res['data'];
// } else {
// $result['reportList'] = array();
// }
//
// $this->render('report', $result);
}
/***************** 出入库账薄 *****************/
public function actionAccount(){
$params = array();
$result = array();
$itemId = trim(Req::get('itemId'));
$page = Req::get('page') ? Req::get('page') : 1;
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
if($itemId){
$params['itemId'] = $itemId;
}
$params['pageNum'] = $page;
$params['storageId'] = $schoolId;
$res = $this->getHttp('storage-inventory/coach/records', 'post',$params);
$result['list'] = array();
if ($res['status'] == 1) {
$result['list'] = $res['data']['list'];
$result['page'] = $res['data'];
} else {
$result['list'] = array();
$result['page'] = array();
}
$this->render('account', $result);
// $params = array();
// $result = array();
//
// $itemId = trim(Req::get('itemId'));
// $startTime = trim(Req::get('startDate'));
// $endTime = trim(Req::get('endDate'));
//
// //获取品目名称
// $itemList = $this->getPmList(true);
// $result['itemList'] = $itemList;
//
// if($itemId ){
// $params['itemId'] = Req::get('itemId');
// if($startTime){
// if(!getCheckDate($startTime)){
// $this->errorMsg('开始日期不正确!');
// }
// $params['startTime'] = $startTime;
// }
//
// if($endTime){
// if(!getCheckDate($endTime)){
// $this->errorMsg('结束日期不正确!');
// }
// $params['endTime'] = $endTime;
// }
// $result['startTime'] = $startTime;
// $result['endTime'] = $endTime;
//
// if(!isset($itemList[$itemId])){
// $this->errorMsg('品目不存在!');
// }else{
// $result['currItem'] = $itemList[$itemId];
// }
// $res = $this->getHttp('storage-inventory/ledger-coach/', 'post',$params);
//
// $result['reportList'] = array();
// if ($res['status'] == 1) {
// $result['reportList'] = $res['data'];
// } else {
// $this->errorMsg($res['msg']);
// }
// }else{
// $result['reportList'] = array();
// }
// $result['dateStrArr'] = $this->getDateStr();
//
//
// $this->render('account', $result);
}
/***************** 所需方法 *****************/
/**
* 处理接口返回的数据
* @param $res
* @return array
*/
public function handleRes($res){
$result = array(
'status' => 0,
'data' => array(),
'msg' => '暂无数据',
);
if($res){
$res = json_decode($res,true);
if(isset($res['errCode']) && $res['errCode'] == '00'){
$result['status'] = 1;
$result['data'] = isset($res['data'])?$res['data']:array();
$result['msg'] = $res['errMsg'];
}else{
if(isset($res['errMsg'])){
$result['msg'] = $res['errMsg'];
}
}
}
unset($res);
return $result;
}
/**
* 获取调拨所有品目列表
* @return array|mixed
*/
private function getPmList($isRel = false){
$pmList = array();
$res = http('item/all', 'get', $this->authUsername);
if($res){
$result = $this->handleRes($res);
if($result['status'] == 1){
if($isRel){
foreach($result['data'] as $value){
$pmList[$value['itemId']] = $value;
}
}else{
$pmList = $result['data'];
}
}
}
unset($res);
return $pmList;
}
/**
* 获取销售品目列表
* @return array|mixed
*/
private function getSalePmList($itemType=2){
$pmList = array();
$res = http('storage-inventory/coach-item/'.$itemType, 'get',$this->authUsername);
if($res){
$result = $this->handleRes($res);
if($result['status'] == 1){
$pmList = $result['data'];
}
}
unset($res);
return $pmList;
}
/**
* 获取接口数据
* @param $url
* @param $method
* @param array $params
* @return array
*/
private function getHttp($url,$method,$params = array()){
$res = http($url, $method, $this->authUsername, $params);
$res = $this->handleRes($res);
return $res;
}
/**
* 错误信息
* @param $msg
*/
private function errorMsg($msg){
Yii::app()->jump->error($msg);
}
/**
* 获取日期段
* @return array
*/
private function getDateStr(){
$result = array();
$time = time();
$dayTime = 24*3600;
$week = date('w');
$result['curr_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime );
$result['curr_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime);
$result['pre_week_start'] = date('Y-m-d',$time - ($week - 1) * $dayTime - 7*$dayTime);
$result['pre_week_end'] = date('Y-m-d',$time - ($week - 1) * $dayTime + 6*$dayTime - 7*$dayTime);
$result['curr_month_start'] = date("Y-m-01",$time);
$result['curr_month_end'] = date("Y-m-d",strtotime($result['curr_month_start']." +1 month -1 day"));
$result['pre_month_start'] = date("Y-m-d",strtotime($result['curr_month_start']." -1 month"));
$result['pre_month_end'] = date("Y-m-d",strtotime($result['pre_month_start']." +1 month -1 day"));
$result['curr_year_start'] = date("Y-01-01",$time);
$result['curr_year_end'] = date("Y-m-d",strtotime($result['curr_year_start']." +1 year -1 day"));
$result['pre_year_start'] = date('Y-m-d',strtotime($result['curr_year_start']." -1 year"));
$result['pre_year_end'] = date("Y-m-d",strtotime($result['pre_year_start']." +1 year -1 day"));
return $result;
}
public function setToken(){
$sign = $this->authUsername.Yii::app()->params['ims']['sign_url'].Yii::app()->params['ims']['sign'];
$authPassword = md5($sign);
$basic = "Basic ". base64_encode($this->authUsername.":".$authPassword);
return $basic;
}
/**
* @param $codeType
* @return array
* 获取字典
*/
public function getDict($codeType)
{
$result = array();
$http = http('dictionary/list/type-code/'.$codeType, 'get', $this->authUsername);
$response = formatResponse($http);
if ($response['status']){
$result = $response['data'];
}
return $result;
}
public function actionSign(){
$result = array();
$result['data'] = array();
$outId = Req::get('outId');
$http = http('storage-output/coach/' . $outId, 'get',$this->authUsername);
if($http){
$http = json_decode($http,true);
}
if(isset($http['data']) && $http['data']){
$result['data'] = $http['data'];
$classSign = $singInfo = array();
$className = array();
$_data = array();
$result['data']['currClassId'] = 0;
if(isset($http['data']['signDetails']) && $http['data']['signDetails']){
$signDetails = $http['data']['signDetails'];
foreach ($signDetails as $value){
$classSign[$value['clazzId']] = $value['classSign'];
//签字图片,签字人
$_signInfo = array();
if(isset($value['signUrl']) && $value['signUrl']){
$_signInfo = array(
'signUrl' => $value['signUrl'],
'signRole' => $value['signRole'],
'signPhone' => $value['signPhone']
);
}
$singInfo[$value['clazzId']] = $_signInfo;
//班级名称数组
$className[$value['clazzId']] = $value['clazzName'];
if(isset($value['studentNames']) && $value['studentNames']){
foreach ($value['studentNames'] as $v){
if(!$result['data']['currClassId']){
$result['data']['currClassId'] = $value['clazzId'];
}
$item = array();
$item['orderNo'] = isset($http['data']['orderNo'])?$http['data']['orderNo']:0;
$item['className'] = $value['clazzName'];
$item['classId'] = $value['clazzId'];
$item['studentName'] = $v;
$_data[] = $item;
}
}
}
}
$result['data']['_signDetails'] = $_data;
$result['data']['classSign'] = $classSign;
$result['data']['singInfo'] = $singInfo;
$result['data']['className'] = $className;
}else{
$this->errorMsg(isset($http['errMsg'])?$http['errMsg']:'接口获取数据失败');
}
$this->render('sign', $result);
}
/**********************************************************************************/
//领用出库
public function actionUseOut(){
$result = array();
$params = array();
$page = Req::get('page') ? Req::get('page') : 1;
if (Req::get('isUse')) { //状态
$params['status'] = Req::get('isUse')-1;
}
if (Req::get('itemId')) {
$params['itemId'] = Req::get('itemId');
}
if (Req::get('itemType')) {
$params['itemType'] = Req::get('itemType');
}
if (Req::get('inCode')) {
$params['inCode'] = Req::get('inCode');
}
if (Req::get('inputStatus')) {
$params['inputStatus'] = Req::get('inputStatus')-1;
}
$useOutType = Req::get('useOutType');
if(!$useOutType){
$useOutType = 'use';
}
if (Req::get('startDate')) {
$startDate = date('Y-m-d H:i:s',strtotime(Req::get('startDate')));
if($useOutType == 'use'){
$params['outDateBegin'] = $startDate;
}elseif($useOutType == 'useOut'){
$params['inDateBegin'] = $startDate;
}else{
$params['startTime'] = $startDate;
}
}
if(Req::get('endDate')){
$endDate = date('Y-m-d H:i:s',strtotime(Req::get('endDate')));
if($useOutType == 'use'){
$params['outDateEnd'] = $endDate;
}elseif($useOutType == 'useOut'){
$params['inDateEnd'] = $endDate;
}else{
$params['endTime'] = $endDate;
}
}
$params['pageNo'] = $page;
//品目名称
$pmNameList = $this->getPmList();
$result['itemList'] = $pmNameList;
if($useOutType == 'use'){
$res = $this->getHttp('storage/coach/client/take/list', 'POST',$params);
}elseif($useOutType == 'out'){
//退库
$res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
}else{
$res = $this->getHttp('storage-input/coach/cancel/list' , 'POST',$params);
// $res = $this->getHttp('storage/coach/client/refound/list', 'POST',$params);
}
$result['pmDataList'] = array();
if ($res['status'] == 1) {
$result['pmDataList'] = $res['data'];
}
$result['useOutType'] = $useOutType;
//debug($result);
$this->render('useOut', $result);
}
/**
* 出库单出库
*/
public function actionUseView()
{
$result = array();
$outId = Req::get('outId');
$scrapNo = 0;
if (is_numeric($outId) && $outId > 0) {
$res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['coachName']=$res['data']['userName'];
$result['pmData'] = $res['data'];
$result['coachName'] = isset($result['pmData']['userName'])?$result['pmData']['userName']:'';
if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
$result['itemName'] = $res['data']['itemList'][0]['itemName'];
$result['itemId'] = $res['data']['itemList'][0]['itemId'];
$result['stockNum'] = $res['data']['itemList'][0]['num'];
$result['itemTotal'] = $res['data']['itemList'][0]['invNo'];
$result['unitName'] = isset($res['data']['itemList'][0]['unitName'])?$res['data']['itemList'][0]['unitName']:'';
$result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
if(isset($res['data']['itemList'][0]['scrapNo'])){
$scrapNo = $res['data']['itemList'][0]['scrapNo'];
}
$result['fcCode'] = isset($res['data']['itemList'][0]['fcCode'])?$res['data']['itemList'][0]['fcCode']:'';
$result['fcName'] = isset($res['data']['itemList'][0]['fcName'])?$res['data']['itemList'][0]['fcName']:'';
$result['print'] = isset($res['data']['itemList'][0]['print'])?$res['data']['itemList'][0]['print']:'';
//$result['itemType'] = $res['data']['itemType'];
$result['fcId'] =isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
// $result['orderNo'] = $res['data']['orderNo'];
// $result['packageNo'] = $res['data']['packageNo'];
// $result['quantity'] = $res['data']['quantity'];
// $result['waitCheckNo'] = $res['data']['waitCheckNo'];
// $result['saleNo'] = $res['data']['saleNo'];
}else{
$this->errorMsg('数据为空');
}
if(isset($res['data']['processLogs'])){
$result['logList']=$res['data']['processLogs'];
}else{
$result['logList']=array();
}
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('出库单ID不正确!');
}
//$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$http = http('storage/coach/take/print/all', 'get', $this->authUsername);
$response = formatResponse($http);
$result['printList'] = $response['data'];
$result['schoolName'] = $this->getSchoolName($schoolId);
$result['scrapNo'] = $scrapNo;
$this->render('useView', $result);
}
/**
* 出库单增加
*/
public function actionUseAddEdit()
{
$result = array();
$outId = Req::get('outId');
$itemType = Req::get('itemType')?Req::get('itemType'):0;
$result['pmData'] = array();
if($outId){
$res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['itemName'] = $res['data']['itemList'][0]['itemName'];
$result['itemId'] = $res['data']['itemList'][0]['itemId'];
$result['stockNum'] = $res['data']['itemList'][0]['num'];
if(!$itemType){
$itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
$result['fcId'] = isset($res['data']['itemList'][0]['fcId'])?$res['data']['itemList'][0]['fcId']:0;
}
} else {
$this->errorMsg($res['msg']);
}
}
//品目名称
$itemType = $itemType?$itemType:2;
$pmNameList = $this->getSalePmList($itemType);
// if (empty($pmNameList)){
// $this->errorMsg('暂无出库品目,无法新增出库单!');
// }
$result['pmNameList'] = $pmNameList;
$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$result['schoolName'] = $this->getSchoolName($schoolId);
$result['itemType'] = $itemType;
//获取学年
$http = http('sys/school/year/period/list', 'get', $this->authUsername);
$response = formatResponse($http);
$result['schoolYear'] = $response['data'];
//获取产品
$goodArr = $this->getGood();
$result['goodList'] = $goodArr;
//获取打印设备
$http = http('storage/coach/take/print/all', 'get', $this->authUsername);
$response = formatResponse($http);
$result['printList'] = $response['data'];
$this->render('useAddEdit', $result);
}
/**
* ajax出库增加
*/
public function actionAjaxUseAdd(){
$result = array();
$error = array();
$itemId = Req::post('itemId');
$outDate = Req::post('outDate');
$outTitle = Req::post('outTitle');
$outStockNum = Req::post('outStockNum');
$useExplain= trim(Req::post('useExplain'));
$outId = Req::post('outId');
$itemType = Req::post('itemType');
$orderId = Req::post('orderId');
$fcId = Req::post('fcId');
//品目名称
$pmNameList = $this->getSalePmList($itemType);
$pmNameArr = array();
foreach($pmNameList as $value){
if($value['itemId'] == $itemId){
$pmNameArr = $value;
}
}
if(!$pmNameArr){
$error[] = '品目信息不正确!';
}
if(!$error){
$params = array(
'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
'title' => $outTitle,
'outItemDetail' => array(
'itemId' => $itemId,
'num' => round($outStockNum,6),
'fcId'=>$fcId
),
'remark' => $useExplain,
'orderId'=>$orderId,
);
//编辑
if($outId){
$params['outId'] = $outId;
$res = $this->getHttp('storage/coach/client/take/edit', 'post',$params);
$this->imsLog("编辑领用出库单",'storage/coach/client/take/edit',$params,$res);
}else{
//新增
$res = $this->getHttp('storage/coach/client/take/add', 'post',$params);
$this->imsLog("新增领用出库单",'storage/coach/client/take/add',$params,$res);
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1,'data' => $result));exit();
}
}
/**
* 关联正式订单
*/
public function actionUseRelOrder(){
$error = array();
$result = array();
$page = (int)Req::get('page');
$doType = Req::get('doType');
$outId = Req::get('outId');
$allotNo = Req::get('allotNo');
$page = $page ? $page : 1;
if($doType=='relOrder'){
$res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
if(isset($res['status']) && $res['status'] == 1){
$result['validNum'] = isset($res['data']['validNum'])?$res['data']['validNum']:0;
$result['confirmNum'] = isset($res['data']['confirmNum'])?$res['data']['confirmNum']:0;
}else{
$this->errorMsg($res['msg']);
}
$res = $this->getHttp('storage/coach/client/take/not-allot/orders/'.$page, 'get');
if ($res['status'] == 1) {
$result['pmDataList'] = $res['data'];
} else {
$this->errorMsg($res['msg']);
}
}else{
$res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
if(isset($res['status']) && $res['status'] == 1){
$result['validList'] = $res['data'];
}else{
$this->errorMsg($res['msg']);
}
$res = $this->getHttp('storage/coach/client/take/orders/students/'.$outId.'/'.$page, 'get');
if ($res['status'] == 1) {
$result['pmDataList'] = $res['data'];
} else {
$this->errorMsg($res['msg']);
}
}
$result['outId'] = $outId;
$result['allotNo'] = $allotNo;
if($doType=='relOrder'){
$this->render('useRelOrder', $result);
}else{
$this->render('useViewRelOrder', $result);
}
}
/**
* 获取可发放数量
*/
public function actionAjaxValidNum(){
$error = array();
$result = array();
$doType = Req::post('doType');
$outId = Req::post('outId');
if($doType == 'relOrder'){
$res = $this->getHttp('storage/coach/client/take/valid-num/'.$outId, 'get');
}else{
$res = $this->getHttp('storage/coach/client/take/orders/'.$outId, 'get');
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1,'data' => $result));exit();
}
}
/**
* 明细订单
* @throws CException
*/
public function actionAjaxAppointDetail(){
$result = array();
$error = array();
$hasSelected = array();
$orderId = trim(Req::post('orderId'));
$outId = Req::post('outId')?Req::post('outId'):0;
//可选学生
$res = $this->getHttp('storage/coach/client/take/not-allot/students/'.$orderId, 'get');
if($res['status'] == 1){
$className = array();
foreach ($res['data'] as $v){
if(!isset($result[$v['clazzId']])){
$result[$v['clazzId']] = array();
}
$result[$v['clazzId']][] = $v;
$className[$v['clazzId']] = $v['clazzName'];
}
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1,'data' => $this->renderPartial('_orderSelectStu',array('relStuList'=>$result,'className'=>$className,'outId'=>$outId), true)));exit();
}
}
/**
* 保存关联订单
*/
public function actionAjaxSaveRelOrder(){
$error = array();
$result = array();
$page = (int)Req::post('page');
$studentIds = (array)Req::post('studentIds');
$outId = Req::post('outId');
if(!$studentIds){
$error[] = '没有学生ID';
}
$params = array(
'osIdList' => $studentIds,
'outId' => $outId,
);
$res = $this->getHttp('storage/coach/client/take/allot/students', 'post',$params);
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1,'data' => $result));exit();
}
}
/************** 退库 *****************/
/**
* 退库单增加
*/
public function actionOutAddEdit()
{
$result = array();
$outId = Req::get('outId');
$itemType = Req::get('itemType')?Req::get('itemType'):0;
$result['pmData'] = array();
if($outId){
$res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
if(!$itemType){
$itemType = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:$itemType;
}
} else {
$this->errorMsg($res['msg']);
}
}
$itemType = $itemType?$itemType:2;
$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$result['schoolName'] = $this->getSchoolName($schoolId);
$result['itemType'] = $itemType;
//品目名称
$pmNameList = $this->getPmList();
$result['itemList'] = $pmNameList;
//debug($result);
$this->render('outAdd', $result);
}
/**
* 退库选择品目
*/
public function actionStockChioceItme(){
$error = array();
$result = array();
$params = array();
$page = Req::post('page');
$itemOutIds = Req::post('itemOutIds');
$itemType = Req::post('itemType');
$outCode = Req::post('outCode');
$itemId = Req::post('itemId');
// $res = $this->getHttp('storage/coach/client/take/items', 'get');
//筛选改成post
if($itemType){
$params['itemType'] = $itemType;
}else{
$params['itemType'] = 2;
}
if($outCode){
$params['outCode'] = $outCode;
}
if($itemId){
$params['itemId'] = $itemId;
}
// debug($params);exit;
$res = $this->getHttp('storage/coach/client/take/items', 'post',$params);
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
exit();
}
/**
* ajax退库增加
*/
public function actionAjaxOutAdd(){
$result = array();
$error = array();
$itemOutArr = (array)Req::post('itemOutArr');
$outDate = Req::post('outDate');
$outTitle = Req::post('outTitle');
$useExplain= trim(Req::post('useExplain'));
$outId = Req::post('outId');
$itemOutInfo = array();
if($itemOutArr){
foreach ($itemOutArr as $v){
$_arr = explode('_',$v);
if(count($_arr) != 3){
$error[] = '品目信息不正确!';
break;
}else{
$_temp = array();
$_temp['itemId'] = $_arr[0];
$_temp['outId'] = $_arr[1];
$_temp['num'] = round($_arr[2],6);
$itemOutInfo[] = $_temp;
}
}
}else{
$error[] = '品目信息不正确!';
}
if(!$error){
$params = array(
'outDate' => date('Y-m-d H:i:s',strtotime($outDate)),
'title' => $outTitle,
'outItemDetailList' => $itemOutInfo,
'remark' => $useExplain,
'title' => $outTitle,
);
//编辑
if($outId){
$params['outId'] = $outId;
$res = $this->getHttp('storage/coach/client/refound/edit', 'post',$params);
$this->imsLog("编辑退库单",'storage/coach/client/refound/edit',$params,$res);
}else{
//新增
$res = $this->getHttp('storage/coach/client/refound/add', 'post',$params);
$this->imsLog("新增退库单",'storage/coach/client/refound/add',$params,$res);
}
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1,'data' => $result));exit();
}
}
/**
* 出库单出库
*/
public function actionOutView()
{
$result = array();
$outId = Req::get('outId');
if (is_numeric($outId) && $outId > 0) {
$res = $this->getHttp('storage/coach/client/refound/detail/' . $outId, 'get');
// debug($res);
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
if(isset($res['data']['processLogs'])){
$result['logList']=$res['data']['processLogs'];
}else{
$result['logList']=array();
}
$result['itemType'] = isset($res['data']['itemList'][0]['itemType'])?$res['data']['itemList'][0]['itemType']:0;
// $result['itemType'] = $res['data']['itemType'];
// $result['orderNo'] = $res['data']['orderNo'];
// $result['packageNo'] = $res['data']['packageNo'];
// $result['quantity'] = $res['data']['quantity'];
// $result['waitCheckNo'] = $res['data']['waitCheckNo'];
// $result['saleNo'] = $res['data']['saleNo'];
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('退库单ID不正确!');
}
$result['coachName'] = isset(Yii::app()->session['coachInfo']['real_name'])?Yii::app()->session['coachInfo']['real_name']:'';
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$result['schoolName'] = $this->getSchoolName($schoolId);
$this->render('outView', $result);
}
/**
* 确认退库
*/
public function actionAjaxConfirmOut()
{
$result = array();
$error = array();
$outId = Req::get('outId');
if (is_numeric($outId) && $outId > 0) {
$params = array();
$res = $this->getHttp('storage/coach/client/refound/confirm/' . $outId, 'post',$params);
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
} else {
$error[] = $res['msg'];
}
} else {
$error[] = '退库单ID不正确!';
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1, 'data' => $result));
exit();
}
}
/**
* 退库删除和中止
*/
public function actionAjaxOutDelStop(){
$result = array();
$error = array();
$businessKey = Req::get('businessKey');
$doType = Req::get('doType');
if ($businessKey) {
if($doType == 'del'){
$http = http('activiti/coach/process-instances/'.$businessKey, 'delete', $this->authUsername);
$response = formatResponse($http);
$this->imsLog('出库或退库删除','activiti/coach/process-instances/'.$businessKey,array(),$response);
}else{
$http = http('activiti/coach/process-instances/'.$businessKey.'/suspended', 'put', $this->authUsername);
$response = formatResponse($http);
$this->imsLog('出库或退库中止','activiti/coach/process-instances/'.$businessKey.'/suspended',array(),$response);
}
if (!$response['status']){
$error[] = $response['data'];
}
} else {
$error[] = 'businessKey不正确!';
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));exit();
} else {
echo json_encode(array('status' => 1, 'data' => $result,'msg' => '提交成功!'));
exit();
}
}
/**
* 获取学校名称
*/
public function getSchoolName($schoolId){
$schoolName = '';
if($schoolId){
$schoolInfo = BusinessSchool::model()->find('school_id=:school_id',array(':school_id'=>$schoolId));
if(isset($schoolInfo->school_name)){
$schoolName = $schoolInfo->school_name;
}
}
return $schoolName;
}
/********新盘点计划*************/
public function actionNewStock(){
$result = array();
$condition = array();
$page = Req::get('page')?Req::get('page'):1;
if(Req::get('planName')){
$condition['title'] = Req::get('planName');
}
if(Req::get('startStockDate')){
$condition['beginTime'] = date("Y-m-d H:i:s",strtotime(Req::get('startStockDate')));
}
if(Req::get('endStockDate')){
$condition['endTime'] = date('Y-m-d H:i:s',strtotime(Req::get('endStockDate').' + 23 hours'));
}
$condition['pageNum'] = $page;
$res = $this->getHttp('plan/coach/page', 'post', $condition);
// debug($res);
if(!$res || $res['status'] != 1){
$this->errorMsg($res['msg']);
}else{
if(isset($res['data']) && isset($res['data']['list'])){
$result['list'] = $res['data']['list'];
}
$result['page'] = $res['data'];
}
$this->render('newstock',$result);
}
public function actionCreatePlanList(){
$result = array();
$planId = Req::get('planId');
if(isset($this->schoolInfo->school_name) && isset($this->coachInfo['coach_name'])){
$result['title'] = $this->schoolInfo->school_name.'-'.$this->coachInfo['coach_name'].'的盘点单'.date("Ymd",time());
}else{
$result['title'] = '';
}
$res = $this->getHttp('plan/coach/item/'.$planId, 'get');
// debug($res);
if(!$res || $res['status'] != 1){
$this->errorMsg($res['msg']);
}else{
if($res['data'] && isset($res['data']['fixedList'])){
// debug($res['data']['fixedList']);
if($res['data']['fixedList']){
foreach($res['data']['fixedList'] as $k=>$v){
$itemId = $v['itemId'];
$http = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
if($http['status']){
if($http['data']){
$res['data']['fixedList'][$k]['originIds'] = implode(",", $http['data']);
}else{
$res['data']['fixedList'][$k]['originIds'] = '';
}
}else{
$res['data']['fixedList'][$k]['originIds'] = '';
}
}
}
}
}
$result['list'] = $res['data'];
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
$result['planId'] = $planId;
//示例图片
$result['result'] = array();
$data = $this->getHttp('storage-stock/coach/example', 'get');
if($data && isset($data['status']) && $data['status'] == 1){
if(isset($data['data']) && $data['data']){
// $list = $data['data'];
$result['result'] = $data['data'];
}
}
// debug($result);
$this->render('createPlanList',$result);
}
//获取编号
public function actionAjaxGetIdentifier() {
$planId = Req::post('planId');
$http = $this->getHttp('storage-inventory/coach/fixed/'.$planId, 'get');
if($http['status']){
if($http['data']){
returnMsg(1,'success',$http['data']);
}else{
returnMsg(0,'暂无数据');
}
}else{
returnMsg(0,$http['msg']);
}
}
//提交盘点单
public function actionAjaxNewStockAdd(){
$params = array();
$params['pId'] = Req::post('pId');
$params['stockTitle'] = Req::post('stockTitle');
$params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
$params['images'] = (array)Req::post('imgArr');
$params['remark'] = Req::post('remark');
$params['details'] = Req::post('details');
$response = $this->getHttp('storage-stock/coach/add','post',$params);
$this->imsLog("销售盘点-新增",'storage-stock/coach/add',$params,$response);
if ($response['status']){
returnMsg(1,$response['msg']);
}else{
returnMsg(0,$response['msg']);
}
}
//查看盘点单
public function actionViewPlanList(){
// echo 11;exit;
$result = array();
$planId = Req::get('planId');
$statusId = Req::get('statusId');
$res = $this->getHttp('storage-stock/coach/edit/'.$planId, 'get');
// debug($res);
if($res['status']){
if($res['data']['stocktakingDate']){
$res['data']['stocktakingDate'] = date("Y-m-d",strtotime($res['data']['stocktakingDate']));
}
$result['list'] = $res['data'];
if(isset($res['data']['resDTOList'])){
$result['logList']=$res['data']['resDTOList'];
}else{
$result['logList']=array();
}
}else{
$this->errorMsg($res['msg']);
}
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
$result['statusId'] = $statusId;
// debug($result['list']);
$this->render('viewPlanList',$result);
}
//编辑盘点单
public function actionAjaxNewStockEdit(){
$params = array();
$params['pId'] = Req::post('pId');
$params['stockTitle'] = Req::post('stockTitle');
$params['stocktakingDate'] = date('Y-m-d H:i:s',strtotime(Req::post('stocktakingDate')));
$params['images'] = (array)Req::post('imgArr');
$params['remark'] = Req::post('remark');
$params['details'] = Req::post('details');
$params['stockId'] = Req::post('stockId');
$params['processInfo'] = Req::post('processInfo');
// debug($params);
$response = $this->getHttp('storage-stock/coach/edit','put',$params);
$this->imsLog("销售盘点-新增",'storage-stock/coach/edit',$params,$response);
if ($response['status']){
returnMsg(1,$response['msg']);
}else{
returnMsg(0,$response['msg']);
}
}
public function actionTransferList(){
$result = array();
$params = array();
$page = Req::get('page') ? Req::get('page') : 1;
if (Req::get('itemsType') && Req::get('itemsType')>0) {
$params['itemType'] = intval(Req::get('itemsType'));
}
if (Req::get('itemId')) {
$params['itemId'] = Req::get('itemId');
}
if(Req::get('transferType')){
if(Req::get('transferType') == 2){
$params['changeType'] = 0;
}else{
$params['changeType'] = intval(Req::get('transferType'));
}
}
if(Req::get('endDate')){
$params['endTime'] = Req::get('endDate');
}
//品目名称
$pmNameList = $this->getPmList();
$result['itemList'] = $pmNameList;
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$params['pageNo'] = $page;
$params['storageId'] = $schoolId;
$res = $this->getHttp('storage/change/coach/list', 'POST', $params);
$result['list'] = array();
if ($res['status'] == 1) {
$result['list'] = $res['data']['list'];
$result['page'] = $res['data'];
} else {
$result['list'] = array();
$result['page'] = array();
}
$this->render('transferList', $result);
}
public function actionCreateTransfer(){
$result = array();
$outId = Req::get('outId');
//品目名称
$result['pmData'] = array();
if($outId){
$res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post');
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['itemName'] = $res['data']['itemList'][0]['itemName'];
$result['itemId'] = $res['data']['itemList'][0]['itemId'];
$result['stockNum'] = $res['data']['itemList'][0]['num'];
} else {
$this->errorMsg($res['msg']);
}
}
// $pmNameList = $this->getSalePmList();
// if (empty($pmNameList)){
// $this->errorMsg('暂无品目,无法新建转移!');
// }
$http = $this->getHttp('storage-inventory/coach-item/2', 'get');
$result['pmNameList'] = $http['data'];
$result['coachName'] = isset(Yii::app()->session['coachInfo']['coach_name'])?Yii::app()->session['coachInfo']['coach_name']:'';
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$result['schoolName'] = $this->getSchoolName($schoolId);
$this->render('createTransfer', $result);
}
public function actionAjaxGetItem(){
$type = Req::post('type');
$res = $this->getHttp('storage-inventory/coach-item/'.$type, 'get');
$error = array();
if ($res['status'] == 1) {
$result = $res['data'];
} else {
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
', $error)));
} else {
echo json_encode(array('status' => 1, 'data' => $result));
}
exit;
}
public function actionAjaxAddTransfer(){
$itemId = Req::post('itemId');
$title = Req::post('title');
$transferType = intval(Req::post('transferType'));
$outDate = Req::post('outDate');
$outStockNum = Req::post('outStockNum');
$itemsType = intval(Req::post('itemsType'));
if(isset(Yii::app()->session['coachInfo']['school_id'])){
$schoolId = Yii::app()->session['coachInfo']['school_id'];
}else{
$schoolId = 0;
}
$params = array(
'changeDate' => $outDate.' 00:00:00',
'changeType' => $transferType,
'icTitle' => $title,
'itemType' => $itemsType,
'storageId'=>intval($schoolId),
'details' => array(
array(
'changeNo'=>round($outStockNum,6),
'itemId'=>$itemId
)
),
);
$response = $this->getHttp('storage/change/coach/add','POST',$params);
if ($response['status']){
returnMsg(1,$response['msg']);
}else{
returnMsg(0,$response['msg']);
}
}
/*****************新建退库单*********************/
//新建退库单
public function actionDeliveryOutAdd()
{
$result = array();
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
//品目名称
$pmNameList = $this->getSalePmList();
if (empty($pmNameList)){
$this->errorMsg('暂无出库品目,无法新增出库单!');
}
$result['pmNameList'] = $pmNameList;
$result['pmData'] = array();
$this->render('deliveryOutAdd', $result);
}
/**
* 关联正式订单
*/
public function actionAjaxOutputOrder(){
$error = array();
$result = array();
$page = (int)Req::post('page');
$orderId = Req::post('orderId');
$doType = Req::post('doType');
$page = $page ? $page : 1;
$res = $this->getHttp('storage-output/coach/order/list/'.$page, 'get');
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
die;
}
/**
* 销售出库编辑学生
* @throws CException
*/
public function actionAjaxAddOutputStu(){
$result = array();
$error = array();
$hasSelected = array();
$params = array();
$orderId = trim(Req::post('orderId'));
$inId = Req::post('inId')?Req::post('inId'):0;
if(empty($orderId)){
echo json_encode(array('status' => 0, 'error' => '请选择订单'));
}
$params['orderId'] = $orderId;
$res = $this->getHttp('storage-output/coach/order/students/'.$orderId, 'get');
$gradeInfo = '';
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'notice'=>$gradeInfo,'data' => $this->renderPartial('_selectOutStu',array('relStuList'=>$result,'hasSelected'=>$hasSelected,'inId'=>$inId), true)));
}
exit;
}
/**
* ajax销售出库增加
*/
public function actionAjaxDeliveryOutAdd(){
$result = array();
$error = array();
$orderId = Req::post('orderId');
$outDate = Req::post('outDate');
$stuIds= (array)Req::post('stuSeledArr');
if(empty($stuIds)){
$error[] = '请选择学生!';
}
// //品目名称
// $pmNameList = $this->getSalePmList();
// $pmNameArr = array();
// foreach($pmNameList as $value){
// if($value['itemId'] == $itemId){
// $pmNameArr = $value;
// }
// }
//
// if(!$pmNameArr){
// $error[] = '品目信息不正确!';
// }
if(!$error){
$params = array(
'osIdList' => $stuIds
);
//编辑
// if(Req::post('inId')){
// $res = $this->getHttp('storage-input/coach/sale/edit/'.Req::post('inId'), 'post',$params);
// $this->imsLog("销售退库-编辑出库单",'storage-output/coach/edit',$params,$res);
// }else{
// //新增
// }
$res = $this->getHttp('storage-input/coach/sale/insert', 'post',$params);
$this->imsLog("取消分配",'storage-input/coach/sale/insert',$params,$res);
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = $res['msg'];
}
}
if ($error) {
echo json_encode(array('status' => 0, 'error' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
exit;
}
/**
* 查看销售退库
*/
public function actionDeliveryOutView()
{
$result = array();
$inId = Req::get('inId');
$result['basic'] = $this->setToken();
if (is_numeric($inId) && $inId > 0) {
$res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['pmStudent'] = $res['data']['students'];
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('取消分配单ID不正确!');
}
$this->render('deliveryOutView', $result);
}
/**
* 删除退库
*/
public function actionAjaxDelIn()
{
$inId = Req::post('inId');
if(empty($inId)){
returnMsg(0, '参数错误');
}
$http = http('storage-input/coach/sale/'.$inId, 'delete', $this->authUsername);
print_r($http);die;
$response = formatResponse($http);
$this->imsLog("销售退库-删除退库",'storage-input/coach/sale/'.$inId,array(),$response);
if ($response['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $response['data']);
}
}
/**
* 销售出库编辑
*/
public function actionDeliveryOutEdit()
{
$result = array();
$inId = Req::get('inId');
//品目名称
$pmNameList = $this->getSalePmList();
if (empty($pmNameList)){
$this->errorMsg('暂无出库品目,无法新增出库单!');
}
$result['pmNameList'] = $pmNameList;
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
if (is_numeric($inId) && $inId > 0) {
$res = $this->getHttp('storage-input/coach/sale/' . $inId, 'get');
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
$result['itemId'] = $res['data']['inputDetails'][0]['itemId'];
$result['pmStudent'] = $res['data']['students'];
$result['pmData']['outDate'] = $res['data']['inDate'];
} else {
$this->errorMsg($res['msg']);
}
} else {
$this->errorMsg('退库单ID不正确!');
}
$this->render('deliveryOutEdit', $result);
}
/**
* 查看盘点示例
*/
public function actionPlanExamples(){
// $this->errorMsg('暂无出库品目,无法新增出库单!');
$list = array();
$planId = Req::get('planId');
$data = $this->getHttp('storage-stock/coach/example', 'get');
if($data && isset($data['status']) && $data['status'] == 1){
if(isset($data['data']) && $data['data']){
$list = $data['data'];
}else{
$this->errorMsg('暂无示例图片!');
}
}else{
$this->errorMsg('暂无示例!');
}
// debug($data);
$this->render('planExamples', array('result'=>$list,'planId'=>$planId));
}
//取消凭据
public function actionSuspended(){
$businessKey= Req::post('businessKey');
if(empty($businessKey)){
returnMsg(0, '参数错误');
}
$http = http("activiti/coach/process-instances/{$businessKey}/suspended", 'put', $this->authUsername);
$response = formatResponse($http);
if ($response['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $response['data']);
}
}
//重新确认收货
public function actionRepeatReceipt(){
$imgArr= Req::post('imgArr');
$atoId= Req::post('atoId');
if(empty($imgArr) || empty($atoId)){
returnMsg(0, '参数错误');
}
$params = array(
'atoId' => $atoId,
'images' => $imgArr,
);
$res = $this->getHttp('storage-allocate/coach/fixed-receipt/'.$atoId, 'put', $params);
if ($res['status']){
returnMsg(1, '提交成功!');
}else{
returnMsg(0, $res['data']);
}
}
//领用,发放订单
public function actionGrant(){
$outId = Req::get('outId');
$num = 0;
$dataList=array();
if (is_numeric($outId) && $outId > 0) {
//搜索销售订单
$orderNo=Req::get('orderNo');
$grade=Req::get('grade');
$semester=Req::get('semester');
$schoolYearId=Req::get('schoolYearId');
$page=Req::get('page');
if(!$page) $page=1;
$params=array();
$params['pageNum']=$page;
$params['outId']=$outId;
if($orderNo){
$params['orderNo']=$orderNo;
}
if($grade){
$params['grade']=$grade;
}
if($semester){
$params['semester']=$semester-1;
}
if($schoolYearId){
$params['schoolYearId']=$schoolYearId;
}
$res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['pmData'] = $res['data'];
if(isset($res['data']['itemList']) && $res['data']['itemList'][0]){
$result['num']= $res['data']['itemList'][0]['num'];
$result['typeId']= $res['data']['itemList'][0]['typeId'];
}else{
$this->errorMsg('数据为空');
}
if(isset($res['data']['sendNo'])){
$result['sendNo']=$res['data']['sendNo'];
}else{
$result['sendNo']=0;
}
if(isset($res['data']['refoundNo'])){
$result['refoundNo']=$res['data']['refoundNo'];
}else{
$result['refoundNo']=0;
}
} else {
$this->errorMsg($res['msg']);
}
}
$params = array();
//获取学年
$http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
$response = formatResponse($http);
$result['schoolYear'] = $response['data'];
$result['outId']=$outId;
//debug($result);
$this->render('grant',$result);
}
//查看发放记录
public function actionViewGrant(){
$outId = Req::get('outId');
$num = 0;
$dataList=array();
if (is_numeric($outId) && $outId > 0) {
//搜索销售订单
$orderNo=Req::get('orderNo');
$grade=Req::get('grade');
$semester=Req::get('semester');
$schoolYearId=Req::get('schoolYearId');
$page=Req::get('page');
if(!$page) $page=1;
$params=array();
$params['pageNum']=$page;
$params['outId']=$outId;
if($orderNo){
$params['orderNo']=$orderNo;
}
if($grade){
$params['grade']=$grade;
}
if($semester){
$params['semester']=$semester-1;
}
if($schoolYearId){
$params['schoolYearId']=$schoolYearId;
}
$res = $this->getHttp('storage/coach/client/take/detail/'.$outId, 'post',$params);
$result['pmData'] = array();
if ($res['status'] == 1) {
$result['itemType']=$res['data']['itemType'];
$result['pmData'] = $res['data']['coachSaleOrders'];
} else {
$this->errorMsg($res['msg']);
}
}
//获取学年
$http = http('sys/school/year/period/list', 'get', $this->authUsername, $params);
$response = formatResponse($http);
$result['schoolYear'] = $response['data'];
//学期
$http = http('sys/school/year/semester/list', 'get', $this->authUsername);
$response = formatResponse($http);
$result['seasonList'] = $response['data'];
$result['outId']=$outId;
$result['orderNo']=$orderNo;
$result['grade']=$grade;
$result['semester']=$semester;
$result['schoolYearId']=$schoolYearId;
$this->render('view_grant',$result);
}
//选择销售订单
public function actionAjaxGetOrderList(){
$orderNo=Req::post('orderNo');
$grade=Req::post('grade');
$semester=Req::post('semester');
$schoolYear=Req::post('schoolYearId');
$page=Req::post('page');
$typeId=Req::post('typeId');
$error=array();
if(!$page) $page=1;
$params=array();
$params['pageNum']=$page;
if($grade){
$params['grade']=$grade;
}
if($orderNo){
$params['orderNo']=$orderNo;
}
if($semester){
$params['semester']=$semester;
}
if($schoolYear){
$params['schoolYearId']=$schoolYear;
}
if($typeId){
$params['itemType']=$typeId;
}
$res = $this->getHttp('storage/coach/client/take/order/list', 'post', $params);
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
exit();
}
/**
* @return array
* 获取商品
*/
public function getGood()
{
$result = array();
$http = http('goods/up/list', 'get', $this->authUsername);
$response = formatResponse($http);
if($response['status']){
$result = $response['data'];
}
return $result;
}
//保存发放订单
public function actionSaveGrant(){
$outId=Req::post('outId');
$orders=Req::post('orders');
if(!$outId || !$orders){
returnMsg(0, '参数错误');
}
$error=array();
$param['outId']=$outId;
$param['orders']=$orders;
$res = $this->getHttp('storage/coach/client/take/allot/order', 'post', $param);
if($res['status'] == 1){
$result = $res['data'];
}else{
$error[] = isset($res['msg'])?$res['msg']:'接口获取数据失败';
}
if ($error) {
echo json_encode(array('status' => 0, 'msg' => implode('
',$error)));
} else {
echo json_encode(array('status' => 1,'data' => $result));
}
exit();
}
//发货
public function actionDeliverGoods(){
$result = array();
$atId = trim(Req::get('atId'));
$result['sendData'] = array();
if ($atId) {
//发货记录
$sendRes = $this->getHttp('storage-allocate/coach/deliver-record/' . $atId, 'get');
if ($sendRes['status'] == 1) {
$result['sendData'] = $sendRes['data'];
}
$res1 = $this->getHttp('storage-allocate/coach/details/' . $atId, 'GET');
if ($res1['status'] == 1) {
$result['atType']=$res1['data']['atType'];
$result['images']=$res1['data']['images'];
if($res1['data']['details']){
foreach ($res1['data']['details'] as $val){
$result['allocateDetail'][]=array(
'atDetailId'=>$val['atDetailId'],
'itemId'=>$val['itemId'],
'itemName'=>$val['itemName'],
'applyNo'=>$val['applyNo'],
'invNo'=>$val['invNo'],
'unitName'=>$val['unitName'],
'typeName'=>$val['typeName'],
'itemSpec'=>$val['itemSpec'],
'deliveryStatusName'=>$val['deliveryStatusName'],
);
}
}
}
//快递
$express = $this->getHttp('dictionary/list/type-code/express', 'get');
if ($express['status'] == 1) {
$result['express'] = $express['data'];
}
$url = Yii::app()->params['ims']['url'].'api/upload/image';
$result['uploadUrl'] = $url;
$result['basic'] = $this->setToken();
}
$this->render('deliverGoods',$result);
}
//读取固定资产编号
public function actionGetFixedAssetsNo(){
$itemId = trim(Req::post('itemId'));
$result['status']=1;
$Fixed = $this->getHttp('storage-inventory/coach/fixed/'.$itemId, 'get');
if ($Fixed['status'] == 1) {
$result['data'] = $Fixed['data'];
}
exit(json_encode($result));
}
//确认发货
public function actionConfirmDeliver(){
$atDetailId= Req::post('atDetailId');
$logisticsCode= Req::post('logisticsCode');
$logisticsName= Req::post('logisticsName');
$fixedCodes= Req::post('fixedCodes');
$no= Req::post('no');
$imgUrls= Req::post('imgUrls');
$result['status']=0;
$params=array(
'atDetailId'=>$atDetailId,
'logisticsCode'=>$logisticsCode,
'logisticsName'=>$logisticsName,
'fixedCodes'=>$fixedCodes,
'no'=>$no,
'imgUrls'=>$imgUrls
);
$rs = $this->getHttp('storage-allocate/coach/deliver', 'post',$params);
if($rs['status']==1){
$result['status']=1;
}else{
if($rs['data']){
$result['msg']=$rs['data'];
}else{
$result['msg']='发货失败';
}
}
exit(json_encode($result));
}
//取消调拨
public function actionCancelAllocation(){
$atId= Req::post('atId');
$rs = $this->getHttp('storage-allocate/coach/status/'.$atId, 'put');
$result['status']=0;
if($rs['status']==1){
$result['status']=1;
}else{
if($rs['data']){
$result['msg']=$rs['msg'];
}else{
$result['msg']='操作失败';
}
}
exit(json_encode($result));
}
//加载设备编号(添加零件)
public function actionGetDevice(){
$storageId= Req::post('storageId');
$rs = $this->getHttp('storage-inventory/greater-zero/0/'.$storageId, 'get');
exit(json_encode($rs));
}
//加载设备编号(添加零件)
public function actionGetPart(){
$fixedId= Req::post('fixedId');
$rs = $this->getHttp('fixed/part/list/'.$fixedId, 'get');
exit(json_encode($rs));
}
//根据零配件类型加载设备
public function actionGetDeviceByPart(){
$partType= Req::post('partType');
$storageId= Req::post('storageId');
$rs = $this->getHttp('storage-inventory/query-fixed/list/'.$partType.'/ '.$storageId, 'get');
exit(json_encode($rs));
}
}