diff --git a/admin/controllers/Img.php b/admin/controllers/Img.php index beb1f739..118687b6 100644 --- a/admin/controllers/Img.php +++ b/admin/controllers/Img.php @@ -36,6 +36,7 @@ class Img extends CI_Controller $this->load->model('receiver/order/receiver_order_contracts_model', 'order_contracts_model'); require_once COMMPATH.'/third_party/TCPDF/tcpdf.php'; $brand_id = $this->input->get('brand_id'); + $sid = $this->input->get('sid'); $page = $this->input->get('page'); $size = $this->input->get('size'); !$page && $page = 1; @@ -47,6 +48,7 @@ class Img extends CI_Controller 'page' => $page, 'size' => $size ]; + $sid && $params['sid'] = $sid; $result = $this->ordersv2list->lists($params['status_pid'], $params); $lists = $result['lists']; $type_arr = [0=>'汽车购车协议',1=>'委托服务协议',2=>'车辆确定',3=>'车辆交付']; @@ -59,6 +61,7 @@ class Img extends CI_Controller if($contract){ foreach ($contract as $v) { $path = FCPATH."pdf/{$row['sid']}"; +// $row['owner_mobile'] && $path .= "({$row['owner_mobile']})"; if (!file_exists($path)) { $oldumask = umask(0); mkdir($path, 0777, true); @@ -114,4 +117,47 @@ class Img extends CI_Controller echo "执行结束"; } } + //修改文件名 + public function change_dir_name(){ + $this->load->model('receiver/order/receiver_orders_v2_model'); + $path = FCPATH."pdf/"; + //PHP遍历所有文件夹 + $handle=opendir($path."."); + $array_file = array(); + while (false !== ($file = readdir($handle))) + { + if ($file != "." && $file != "..") { + $array_file[] = $file; //输出文件名 + } + } + closedir($handle); + if(is_array($array_file)){ + foreach ($array_file as $item) { + if(is_numeric($item)){ + $dir = $path.$item; + $arr = scandir($dir); + $len = count($arr)-2; + if($len>0){ + $row = $this->receiver_orders_v2_model->get(['sid'=>$item],'owner_mobile,owner_name'); + if($row){ + $rename = $path.$row['owner_name']; + $row['owner_mobile'] && $rename.="({$row['owner_mobile']})"; + if(rename($dir,$rename)){ + echo "更名成功{$rename}
"; + }else{ + echo "更名失败{$item}
"; + } + }else{ + echo "订单不存在{$item}
"; + } + }else{ + @unlink($dir); + echo "删除文件夹:{$dir}
"; + } + }else{ + echo "无需改名:{$item}.
"; + } + } + } + } }