/** * @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; $desc = new Product_Model_Desc(); $record = new Dcc_Model_Record(); $review = new Dcc_Model_Review(); if (count($deleted) > 0) { foreach ($deleted as $val) { $id = $val->id; // 操作记录 $data = array('type' => "materiel_desc", 'table_name' => "oa_product_materiel_desc", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "删除", 'ip' => $_SERVER['REMOTE_ADDR']); try { // 增加record记录 $record->insert($data); // 删除review记录 $review->delete("type = 'materiel_desc' and file_id = {$id}"); // 更新物料状态 $desc->update(array('state' => 'Deleted'), "id = {$id}"); } catch (Exception $e) { $result['result'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } } echo Zend_Json::encode($result); exit; }
public function importitemsAction() { $result = array('success' => true, 'data' => array(), 'info' => '导入成功'); if (isset($_FILES['csv'])) { $file = $_FILES['csv']; $file_extension = strrchr($file['name'], "."); $h = new Application_Model_Helpers(); $tmp_file_name = $h->getMicrotimeStr() . $file_extension; $savepath = "../temp/"; $tmp_file_path = $savepath . $tmp_file_name; move_uploaded_file($file["tmp_name"], $tmp_file_path); $file = fopen($tmp_file_path, "r"); $i = 0; $materiel = new Product_Model_Materiel(); $desc = new Product_Model_Desc(); while (!feof($file)) { $csv_data = fgetcsv($file); $code = isset($csv_data[1]) ? $csv_data[1] : ''; $qty = isset($csv_data[2]) ? $csv_data[2] : 0; $date_req = isset($csv_data[3]) ? str_replace('-', '/', $csv_data[3]) : ''; $project_info = isset($csv_data[4]) ? $csv_data[4] : ''; $order_req_num = isset($csv_data[5]) ? $csv_data[5] : ''; $customer_address = isset($csv_data[6]) ? $csv_data[6] : ''; $customer_aggrement = isset($csv_data[7]) ? $csv_data[7] : ''; $remark = isset($csv_data[8]) ? $csv_data[8] : ''; if ($i > 0 && $code != '') { $materielData = $materiel->getOptionList($code); $is_changing = false; if ($code != '') { $is_changing = $desc->isChanging($code); } if (count($materielData) > 0) { array_push($result['data'], array('code' => $code, 'is_changing' => $is_changing, 'name' => $materielData['name'], 'description' => $materielData['description'], 'unit' => $materielData['unit'], 'qty' => $qty, 'date_req' => $date_req, 'project_info' => mb_convert_encoding($project_info, 'UTF-8', 'GBK'), 'order_req_num' => $order_req_num, 'customer_address' => $customer_address, 'customer_aggrement' => $customer_aggrement, 'remark' => mb_convert_encoding($remark, 'UTF-8', 'GBK'))); } else { $result['success'] = 0; $result['info'] = $code . '未找到,导入失败!'; echo Zend_Json::encode($result); exit; } } $i++; } fclose($file); } else { $result['success'] = false; $result['info'] = '没有选择文件,导入失败!'; } //echo '<pre>';print_r($result);die; echo Zend_Json::encode($result); exit; }