Exemplo n.º 1
0
 /**
  * @abstract    删除
  * @return      null
  */
 public function removeAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => true, 'info' => '删除成功');
     $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $json = json_decode($request['json']);
     $deleted = $json->deleted;
     $newbom = new Product_Model_Newbom();
     $fa = new Product_Model_Fa();
     $son = new Product_Model_Son();
     $fadev = new Product_Model_Fadev();
     $sondev = new Product_Model_Sondev();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             $id = $val->sid;
             $recordkey = $val->recordkey;
             // 操作记录
             $data = array('type' => "bom", 'table_name' => "oa_product_bom_new", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "删除", 'ip' => $_SERVER['REMOTE_ADDR']);
             try {
                 // 增加record记录
                 $record->insert($data);
                 // 删除bom表
                 $fa->delete("sid = {$id}");
                 $son->delete("recordkey = {$recordkey}");
                 if ($val->nid) {
                     $fadev->delete("recordkey = {$recordkey}");
                     $sondev->delete("recordkey = {$recordkey}");
                 }
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 2
0
 public function removeexistsAction()
 {
     $return = array("success" => true, "info" => "");
     $result = $this->getRequest()->getParams();
     if (isset($result['nid']) && $result['nid']) {
         $nid = $result['nid'];
         $type = $result['type'];
         $fadev = new Product_Model_Fadev();
         $sondev = new Product_Model_Sondev();
         $data = $fadev->getFaList("nid={$nid} and type='{$type}'");
         $keys = array();
         foreach ($data as $row) {
             $keys[] = $row['recordkey'];
         }
         $fadev->delete("nid={$nid} and type='{$type}'");
         $sondev->delete("recordkey in (" . implode(',', $keys) . ")");
     } else {
         $return['success'] = false;
         $return['info'] = "没有获取到ID,请刷新页面再重试";
     }
     // 转为json格式并输出
     echo Zend_Json::encode($return);
     exit;
 }
Exemplo n.º 3
0
 /**
  * @abstract    删除
  * @return      null
  */
 public function removeAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => true, 'info' => '删除成功');
     $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $json = json_decode($request['json']);
     $deleted = $json->deleted;
     $newbom = new Product_Model_Newbom();
     $fadev = new Product_Model_Fadev();
     $sondev = new Product_Model_Sondev();
     $fa = new Product_Model_Fa();
     $son = new Product_Model_Son();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             $id = $val->id;
             // 操作记录
             $data = array('type' => "bom", 'table_name' => "oa_product_bom_new", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "删除", 'ip' => $_SERVER['REMOTE_ADDR']);
             // 获取bom fa表的recordkey
             $sql = "select recordkey from oa_product_bom_fa_dev where nid={$id} and (type='new')";
             $keys = $fa->getAdapter()->query($sql)->fetchObject();
             if ($keys && $keys->recordkey) {
                 $recordkey = $keys->recordkey;
             } else {
                 $sql = "select recordkey from oa_product_bom_fa where nid={$id} and (type='new')";
                 $keys = $fa->getAdapter()->query($sql)->fetchObject();
                 if ($keys && $keys->recordkey) {
                     $recordkey = $keys->recordkey;
                 }
             }
             try {
                 // 增加record记录
                 $record->insert($data);
                 // 删除review记录
                 $review->delete("type = 'bom' and file_id = {$id}");
                 // 删除bom表
                 $newbom->delete("id = {$id}");
                 if (isset($recordkey) && $recordkey) {
                     $where = "recordkey = {$recordkey}";
                     $fadev->delete($where);
                     $sondev->delete($where);
                     $fa->delete($where);
                     $son->delete($where);
                 }
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }