public function uploaddeleteAction()
 {
     if (isset($_POST["op"]) && $_POST["op"] == "delete" && isset($_POST['doc_new_name'])) {
         $filePath = "";
         if (isset($_POST["doc_id"]) && $_POST["doc_id"] != '') {
             // Update attachments field in database by removing deleted attachment
             $empDocuModel = new Default_Model_Employeedocs();
             $empDocuments = $empDocuModel->getEmpDocumentsByFieldOrAll('id', $_POST["doc_id"]);
             if ($empDocuments[0]['attachments']) {
                 $attData = json_decode($empDocuments[0]['attachments'], true);
                 foreach ($attData as $key => $attachment) {
                     if ($attachment['new_name'] == $_POST['doc_new_name']) {
                         unset($attData[$key]);
                         break;
                     }
                 }
                 $data = array('attachments' => count($attData) > 0 ? json_encode($attData) : null);
                 $where = array('id=?' => $_POST["doc_id"]);
                 $empDocuModel->SaveorUpdateEmpDocuments($data, $where);
             }
             $filePath = EMP_DOC_UPLOAD_PATH . $_POST['doc_new_name'];
             // Remove attachment files from upload folder.
             if (file_exists($filePath)) {
                 unlink($filePath);
             }
             // Update photo gallery with removed attachment.
             $this->view->path = CA_FILES_PATH;
             $this->view->attachments = $attData;
             $this->view->doc_id = $_POST["doc_id"];
         } else {
             $filePath = EMP_DOC_TEMP_UPLOAD_PATH . $_POST['doc_new_name'];
             // Remove attachment files from upload folder.
             if (file_exists($filePath)) {
                 unlink($filePath);
             }
             $this->_helper->json(array());
         }
     }
 }