Files
OMS/app/purchase/model/purchase/need.php
2026-01-04 19:08:31 +08:00

114 lines
3.7 KiB
PHP

<?php
/**
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class purchase_mdl_purchase_need extends purchase_mdl_po{
/**
* table_name
* @param mixed $real real
* @return mixed 返回值
*/
public function table_name($real=false){
$table_name = 'po';
if($real){
return kernel::database()->prefix.$this->app->app_id.'_'.$table_name;
}else{
return $table_name;
}
}
function utf8togbk($s){
return $s;//iconv("UTF-8", "GBK//TRANSLIT", $s);
}
function fgetlist_csv(&$data,$filter,$offset,$exportType = 1){
if( !$data['title']['need'] ){
$title = array();
foreach( $this->io_title('need') as $k => $v ){
$title[] = $this->utf8togbk($v);
}
$data['title']['need'] = '"'.implode('","',$title).'"';
}
$filter = utils::addslashes_array($filter);
$page = $page ? $page : 1;
//获取所有数据
$pagelimit = 16777215;
$oPo = app::get('purchase')->model('po');
$_safeData = $oPo->getSafeStock($filter, $pagelimit*($page-1), $pagelimit);
if(!empty( $_safeData)){
unset( $_safeData['count']);
$_data = array();
foreach($_safeData as $v){
unset($v['product_id']);
unset($v['supplier_id']);
//计算需要补货商品的数量
$v['need'] = $v['safe_store'] + $v['store_freeze'] - $v['store'] - $v['arrive_store'];
$_data[] = $v;
}
foreach($_data as $key=>$value){
foreach($this->oSchema['csv']['need'] as $k => $v){
$pRow[$k] = $this->utf8togbk( utils::apath( $value,explode('/',$v) ) );
}
$data['content']['need'][] = '"'.implode('","', $pRow).'"';
}
$data['name'] = 'need'.date("Ymd");
}
}
/**
* 获得日志类型(non-PHPdoc)
* @see dbeav_model::getLogType()
*/
public function getLogType($logParams) {
$type = $logParams['type'];
$logType = 'none';
if ($type == 'export') {
$logType = $this->exportLogType($logParams);
}
elseif ($type == 'import') {
$logType = $this->importLogType($logParams);
}
return $logType;
}
/**
* 导出日志类型
* @param Array $logParams 日志参数
*/
public function exportLogType($logParams) {
$params = $logParams['params'];
$type = 'purchase';
if ($logParams['app'] == 'purchase' && $logParams['ctl'] == 'admin_po') {
$type .= '_needRemind';
}
$type .= '_export';
return $type;
}
/**
* 导入操作日志类型
* @param Array $logParams 日志参数
*/
public function importLogType($logParams) {
$params = $logParams['params'];
$type = 'purchase';
if ($logParams['app'] == 'purchase' && $logParams['ctl'] == 'admin_po') {
$type .= '_needRemind';
}
$type .= '_import';
return $type;
}
}