Browse Source

隐藏项目管理附件

NoNZero 8 years ago
parent
commit
3ccb4156df

File diff suppressed because it is too large
+ 991 - 1072
global/css/style.css


+ 7 - 0
protected/class/itemfile.php

@@ -22,6 +22,8 @@ class ItemFile
         $this->__itemfile->filesize = $postArray['filesize'];
         $this->__itemfile->filepath = $postArray['filepath'];
         $this->__itemfile->intime = time();
+        if (isset($postArray['oldiaid']))
+            $this->__itemfile->oldiaid = $postArray['oldiaid'];
         return $this->__itemfile->insert();
     }
 
@@ -35,6 +37,11 @@ class ItemFile
         return $pmid ? $this->__itemfile->find(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE)) : FALSE;
     }
 
+    public function getFileHistory($oldiaid)
+    {
+        return $oldiaid ? $this->__itemfile->find(array('where' => 'oldiaid=?', 'param' => array($oldiaid), 'asArray' => TRUE)) : FALSE;
+    }
+
     public function updateItemFields($id, $fname)
     {
         $this->__itemfile->filename = iconv('GBK', 'UTF-8', $fname);

+ 6 - 0
protected/class/itemmeasurenum.php

@@ -55,6 +55,12 @@ class ItemMeasureNumpofper
         return $this->__itemMeasureNum->update(array('where' => 'imnid=?', 'param' => array($id)));
     }
 
+    public function updateIAID($oldiaid, $newiaid)
+    {
+        $this->__itemMeasureNum->iaid = $newiaid;
+        return $this->__itemMeasureNum->update(array('where' => 'iaid=?', 'param' => array($oldiaid)));
+    }
+
 
     public function delItemFields($imnid)
     {

+ 44 - 21
protected/controller/ProjectController.php

@@ -9,6 +9,7 @@ Doo::loadClass('numofperact');
 Doo::loadClass('measureauditact');
 Doo::loadClass('itemmeasurenum');
 Doo::loadClass('itemfile');
+Doo::loadClass('attachment');
 
 /* * proDetail
  * MainController
@@ -20,7 +21,7 @@ Doo::loadClass('itemfile');
 class ProjectController extends DooController
 {
 
-    private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '<span class = "colGray">未审批</span>', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>'), $itemmeasurenum, $itemfle;
+    private $data, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '<span class = "colGray">未审批</span>', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>'), $itemmeasurenum, $itemfle, $att;
 
     public function beforeRun($resource, $action)
     {
@@ -46,6 +47,7 @@ class ProjectController extends DooController
         $this->measureauditact = new MeasureauditAct();
         $this->itemmeasurenum = new ItemMeasureNumpofper();
         $this->itemfle = new ItemFile();
+        $this->att = new attachment();
         $this->data['rootUrl'] = Doo::conf()->APP_URL;
         $this->data['currChannle'] = 'p';
         $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
@@ -355,6 +357,29 @@ class ProjectController extends DooController
 
     function proSectionFiles()
     {
+        if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
+            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
+            if ($imnidArray['iaid'] > 0) {
+                $fileArray = $this->upItemFile('file')[0];
+                if (isset($fileArray['filepath'])) {
+                    $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
+                    if (isset($itemArray)) {
+                        if ($itemArray['oldiaid'] > 0) {
+                            $oldiaid = $itemArray['oldiaid'];
+                        } else {
+                            $oldiaid = $imnidArray['iaid'];
+                        }
+                        $postArray = array('ownerid' => $this->auth->getUid(), 'pid' => $itemArray['pid'], 'pmid' => $itemArray['pmid'], 'filename' => $fileArray['filename'], 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath'], 'oldiaid' => $oldiaid);
+                        $iaid = $this->itemfle->insertItemFileRecord($postArray);
+                        if ($iaid > 1) {
+                            $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
+                            echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
+                            die();
+                        }
+                    }
+                }
+            }
+        }
         if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
             $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
             if ($imnidArray['iaid'] > 0) {
@@ -489,6 +514,19 @@ class ProjectController extends DooController
         $this->render('w-project-section-files-recover', $this->data, TRUE);
     }
 
+    function getItemFileHistory()
+    {
+        if ($this->params['iaid']) {
+            $iaidArray = $this->itemfle->getItemFile($this->params['iaid']);
+            if ($iaidArray['oldiaid'] > 0) {
+                $oldiaidArray = $this->itemfle->getFileHistory($iaidArray['oldiaid']);
+                foreach ($oldiaidArray as $k => $v) {
+                    $htmlstr = '<div class="media"><div class="pull-left"><h4>#1</h4></div><div class="media-body"><h5>陈特&nbsp;上传于 2016-10-10 10:10</h5><a href="#" target="_blank">QQ截图20160629164352.png</a></div></div>';
+                }
+            }
+        }
+    }
+
     Function fNumber($number)
     {
         if ($number == '')
@@ -680,26 +718,6 @@ class ProjectController extends DooController
         $this->render('welcome', $this->data);
     }
 
-    public function prolist()
-    {
-//	if (!$this->auth->isLoggedIn())
-//	    return Doo::conf()->APP_URL;
-//	$proArray = new stdClass();
-//	$jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
-//	$extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
-//	if ($handle = opendir($extPathdir)) {
-//	    while (false !== ($file = readdir($handle))) {
-//		$filename = pathinfo($file);
-//		if ($filename['extension'] == 'json')
-//		    $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
-//	    }
-//	    closedir($handle);
-//	}
-//	$this->data['proArray'] = null;
-        $this->render('s-project
-
-	', $this->data);
-    }
 
 // ajax提取密码名称
     public function getAjaxSection()
@@ -709,6 +727,11 @@ class ProjectController extends DooController
         echo json_encode($_POST);
     }
 
+    function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
+    {
+        $this->att->setUploadDir();
+        return $this->att->uploadMut($fildname, $param);
+    }
 }
 
 ?>

+ 2 - 2
protected/model/itematt.php

@@ -18,10 +18,10 @@ class ItemAtt extends DooModel
     public $filepath;
     public $intime;
     public $isdel;
-    public $tips;
+    public $oldiaid;
     public $_table = 'jl_item_attachment';
     public $_primarykey = 'iaid';
-    public $_fields = array('iaid', 'ownerid', 'pid', 'pmid', 'filename', 'fileext', 'filesize', 'filepath', 'intime', 'isdel', 'tips');
+    public $_fields = array('iaid', 'ownerid', 'pid', 'pmid', 'filename', 'fileext', 'filesize', 'filepath', 'intime', 'isdel', 'oldiaid');
 
     public function __construct()
     {

+ 34 - 24
protected/view/w-project-section-files.html

@@ -34,8 +34,7 @@
                         </a>
                         <ul class="dropdown-menu">
                             <!-- loop allconArray -->
-                            <li><a href="{{rootUrl}}project/{{currproArray.pid}}/section">{{allconArray'
-                                value.stname}}</a></li>
+                            <li><a href="{{rootUrl}}project/{{currproArray.pid}}/section">{{allconArray' value.stname}}</a></li>
                             <!-- endloop -->
                         </ul>
                     </li>
@@ -118,7 +117,8 @@
                             <td width="">{{formatDate(itemMeasureArray' value.intime,'Y-m-d')}}</td>
                             <td>
                                 <div class="btn-group">
-                                    <a imnid="{{itemMeasureArray' value.imnid}}" id="dropdown_{{itemMeasureArray' value.imnid}}"
+                                    <a imnid="{{itemMeasureArray' value.imnid}}"
+                                       id="dropdown_{{itemMeasureArray' value.imnid}}"
                                        class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
                                         <span class="caret"></span>
                                     </a>
@@ -182,7 +182,9 @@
                                         data-toggle="modal"><i class="icon-time icon-white"></i>历史版本
                                 </button>
                                 &nbsp;&nbsp;&nbsp;&nbsp;
-                                <button id="del_{{itemMeasureArray' value.imnid}}" imnid="{{itemMeasureArray' value.imnid}}" class="btn btn-mini btn-danger" type="button" href="#file-del"
+                                <button id="del_{{itemMeasureArray' value.imnid}}"
+                                        imnid="{{itemMeasureArray' value.imnid}}" class="btn btn-mini btn-danger"
+                                        type="button" href="#file-del"
                                         data-toggle="modal"><i class="icon-remove icon-white"></i>删除
                                 </button>
                             </td>
@@ -237,10 +239,11 @@
     <div class="modal-body">
         <div class="form">
             <form class="form-horizontal">
+                <input type="hidden" name="fid" value="0" id="fid"/>
                 <div class="control-group">
                     <label class="control-label" for="inputEmail">选择文件</label>
                     <div class="controls">
-                        <input type="file">
+                        <input name="file" id="file" type="file">
                         <span class="help-block">替换新文件后,所有已下挂该文件的清单都将更新。</span>
                     </div>
                 </div>
@@ -249,7 +252,7 @@
     </div>
     <div class="modal-footer">
         <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
-        <button class="btn btn-primary">确定替换</button>
+        <button id="btreplacefile" class="btn btn-primary">确定替换</button>
     </div>
 </div>
 <!-- 替换弹出 -->
@@ -277,24 +280,6 @@
         <h3 id="myModalLabel">历史版本</h3>
     </div>
     <div class="modal-body">
-        <div class="media">
-            <div class="pull-left">
-                <h4>#1</h4>
-            </div>
-            <div class="media-body">
-                <h5>陈特&nbsp;上传于 2016-10-10 10:10</h5>
-                <a href="#" target="_blank">QQ截图20160629164352.png</a>
-            </div>
-        </div>
-        <div class="media">
-            <div class="pull-left">
-                <h4>#2</h4>
-            </div>
-            <div class="media-body">
-                <h5>陈特&nbsp;上传于 2016-9-24 17:30</h5>
-                <a href="#" target="_blank">dfsdf.png</a>
-            </div>
-        </div>
     </div>
     <div class="modal-footer">
         <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
@@ -312,6 +297,7 @@
             var intime = $(this).attr('intime');
             var tips = $(this).attr('tips');
             var numpname = $(this).attr('numpname');
+            var imnid = $(this).attr('imnid');
             $("#fn").html(filename);
             $("#fileico").html(fileext);
             $("#realname").html(realname);
@@ -319,6 +305,7 @@
             $("#tips").html(tips);
             $("#numpname").html(numpname);
             $(".filesDetail").show();
+            $("#fid").val(imnid);
         });
 
         $("a[id^='dropdown_']").click(function () {
@@ -359,6 +346,29 @@
                 }
             });
         });
+
+        $("#btreplacefile").click(function () {
+            var file_data = $('#file').prop('files')[0];
+            var form_data = new FormData();
+            form_data.append('file', file_data);
+            form_data.append('optype', 'replace');
+            var imnid = $("#fid").val();
+            form_data.append('imnid', imnid);
+            $.ajax({
+                type: "POST",
+                dataType: "text",
+                cache: false,
+                contentType: false,
+                data: form_data,
+                url: "/project/{{pid}}/section/{{pmid}}/files",
+                processData: false,
+                success: function (data) {
+                    if (data['status'] == 1) {
+                        window.location.href = "{{rootUrl}}project/{{pid}}/section/{{pmid}}/files";
+                    }
+                }
+            });
+        });
     });
 </script>
 </body>

+ 3 - 1
附件.sql

@@ -21,4 +21,6 @@ CREATE TABLE IF NOT EXISTS `jl_item_measure_numofper` (
   `categoryid` mediumint(9) NOT NULL,
   `tips` text NOT NULL,
   PRIMARY KEY (`imnid`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
+
+ALTER TABLE  `jl_item_attachment` ADD  `oldiaid` MEDIUMINT NOT NULL ;