public function add($order_id) { import('system/share/network/redirect'); AuthPlugins::required($this, array('销售经理', '销售顾问')); $order_id = abs(intval($order_id)); if (!$this->is_post() || !$order_id) { return false; } /* * 上传方案附件 */ import('system/share/io/filesystem'); FileSystem::init(); $file_path = FileSystem::Upload($_FILES['attachment'], false); if (!$file_path) { HTTPRedirect::flash_to('order/detail/' . $order_id, '文件上传失败:' . FileSystem::$message, $this->smarty); } /* * 写入方案表 */ parent::load('model', 'order'); $solution = new Solution(); $solution->order_id = $order_id; $solution->solution_code = trim(strip_tags($_POST['solution_code'])); $solution->name = trim(strip_tags($_POST['name'])); $solution->attachment = $file_path; $solution->price = abs(intval($_POST['price'])); $solution->save(); HTTPRedirect::flash_to('order/detail/' . $order_id, '添加方案成功', $this->smarty); }
public function upload() { import('system/share/io/datastream'); import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['imgFile'], true); if (!$http_path) { $data = array('error' => 1, 'message' => FileSystem::$message); } else { $data = array('error' => 0, 'url' => $http_path); } echo Datastream::output('json', $data); }
public function decide_programe($order_id) { $workflow = Workflow::get_by_alias('程序验收完成'); import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['attachment']); if (!$_FILES['attachment'] || !$http_path) { HTTPRedirect::flash_to('customer', '请您上传首页确认书的扫描件', $this->smarty, 'cus_flash_to'); } $order = Order::get_by_id($order_id); $order->programe_decide_attachment = $http_path; $order->save(); Order::set_workflow($order_id, $workflow); $smarty = parent::load('smarty'); import('system/share/network/redirect'); $message = '程序验收完成,等待客户付尾款即可上线'; $flash_to = $userinfo['role']['0']['alias'] == '技术经理' ? 'order/list/' . $workflow->id : 'customer'; $template = $userinfo['role']['0']['alias'] == '技术经理' ? 'flash_to' : 'cus_flash_to'; HTTPRedirect::flash_to($flash_to, $message, $smarty, $template); }
public function contract($order_id, $step = null) { AuthPlugins::required($this, array('销售经理', '销售顾问')); $order_id = abs(intval($order_id)); $order = Order::get_by_id($order_id); if (!$step) { $step = 'solution'; } $smarty = parent::load('smarty'); $smarty->assign('order', $order); switch ($step) { case 'solution': $solution_id = abs(intval($_GET['id'])); if ($solution_id) { /* * 全部设为非选定方案 */ Solution::set_unchecked(); /* * 选定某个方案 */ Solution::select($solution_id); HttpRedirect::to('order/contract/' . $order_id . '/paper'); } else { $solutions = Solution::get_by_order($order_id); if (!$solutions) { $message = '您还没有为此订单添加方案, 请返回添加'; HTTPRedirect::flash_to('order/detail/' . $order_id, $message, $smarty); } $smarty->assign('page_title', '签约订单 - 选定方案 Step 1'); $smarty->display('contract/solution'); } break; case 'paper': if (!Solution::get_checked($order_id)) { $message = '您还没有选择方案, 请返回选择'; HTTPRedirect::flash_to('order/contract/' . $order_id . '/solution', $message, $smarty); } if ($this->is_post() || $_FILES) { import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['paper_attachment'], false); if (!FileSystem::$local_path) { $message = '不支持的附件类型, 请检查'; HTTPRedirect::flash_to('order/detail/' . $order_id, $message, $smarty); } $order->paper_attachment = $http_path; $order->save(); HTTPRedirect::flash_to('order/contract/' . $order_id . '/payment', '上传合同成功', $this->smarty); } else { $smarty->assign('page_title', '签约订单 - 上传合同附件 Step 2'); $smarty->display('contract/paper'); } break; case 'payment': if ($this->is_post()) { /* * 获取选定的订单方案 */ $solution = Solution::get_checked($order_id); /*首付款*/ $first_pay = new Payment(); $first_pay->order_id = $order_id; $first_pay->type = 'first'; $first_pay->price = abs(intval($_POST['deposit'])); $first_pay->invoice = abs(intval($_POST['invoice'])); $first_pay->public = abs(intval($_POST['pub'])); $first_pay->bank = trim(strip_tags($_POST['bank'])); $first_pay->is_payed = abs(intval($_POST['is_deposit'])); $first_pay->save(); /*二期款*/ $second_pay = new Payment(); $second_pay->order_id = $order_id; $second_pay->type = 'second'; $second_pay->price = abs(intval($_POST['payment'])); $second_pay->invoice = abs(intval($_POST['invoice'])); $second_pay->public = abs(intval($_POST['pub'])); $second_pay->bank = trim(strip_tags($_POST['bank'])); $second_pay->is_payed = abs(intval($_POST['is_payment'])); $second_pay->save(); /*尾款*/ $last_pay = new Payment(); $last_pay->order_id = $order_id; $last_pay->type = 'last'; $last_pay->price = abs(intval($_POST['last_pay'])); $last_pay->invoice = abs(intval($_POST['invoice'])); $last_pay->public = abs(intval($_POST['pub'])); $last_pay->bank = trim(strip_tags($_POST['bank'])); $last_pay->is_payed = abs(intval($_POST['is_last_pay'])); $last_pay->save(); $old_workflow = $order->Workflow->action; $workflow = Workflow::get_by_alias('新增财务订单'); $order->Workflow = $workflow; $order->save(); /* * 在用户表中写入客户的登录信息 * 登录名为客户填写的名字加订单ID * 密码为'MG-客服ID-订单号' */ $user = new User(); $user->username = $order->Customer->name . $order->id; $user->password = User::generate_password(sprintf('MG-%s-%s', $order->customer_service_id, $order->id)); $user->Role[0] = Role::get_by_alias('客户'); $user->save(); $order->Customer->CustomerUser = $user; $order->Customer->save(); $message = '恭喜您签约订单成功, 目前订单已转入财务管理页面'; HTTPRedirect::flash_to('order/list/6', $message, $smarty); } else { $smarty->assign('page_title', '签约订单 - 付款信息 Step 3'); $smarty->display('contract/payment'); } break; } }
public function add_customer() { AuthPlugins::required($this, '客服'); $smarty = parent::load('smarty'); $smarty->assign('page_title', '新增订单'); if ($this->is_post()) { unset($_POST['CSRF_TOKEN']); unset($_POST['sub4']); $model = parent::load('model', 'order'); $time_str = sprintf('%s %s:%s', $_POST['subscribe_time'], $_POST['book_hour'], $_POST['book_minu']); $_POST['subscribe_time'] = date('Y-m-d H:i', strtotime($time_str)); try { $customer = new Customer(); $order = new Order(); foreach ($_POST as $k => $v) { if (isset($customer->{$k})) { $customer->{$k} = trim(htmlspecialchars($v)); } else { if (isset($order->{$k})) { $order->{$k} = trim(htmlspecialchars($v)); } } } /* * 客户提供资料 */ if ($_FILES['cus_docs']) { import('system/share/io/filesystem'); FileSystem::init(); $http_path = FileSystem::Upload($_FILES['cus_docs'], false); $customer->docs = $http_path; } /* * 保存客户信息 */ $customer->save(); /* * 取得工作流程ID(订单状态) */ $workflow = Workflow::get_by_alias('新增订单管理'); /* * 新建订单, 并写入当前的订单初始信息 */ $order->Customer = $customer; $order->Workflow = $workflow; /* * 客服 */ $order->CustomerService = User::current(); $order->save(); import('system/share/network/redirect'); $message = '订单信息录入成功, 转入新增订单管理页面'; /* * 清除订单列表缓存 */ // $smarty->clearCache('order/list'); $smarty->clearAllCache(); HTTPRedirect::flash_to($workflow['action'], $message, $smarty); } catch (Doctrine_Query_Exception $e) { $smarty->raise('system'); } } else { parent::load('form', 'NewCustomer'); $smarty->display('customer/add'); } }