public function __construct($controller, $name, $order_id)
 {
     $Order = Order::get_by_id("Order", $order_id);
     /* Fields */
     $fields = FieldList::create(HiddenField::create("business", "business", DataObject::get_one("Gateway_PayPal")->EmailAddress), HiddenField::create("cmd", "cmd", "_xclick"), HiddenField::create("notify_url", "notify_url", Director::absoluteURL(Store_OrderController::create()->link() . "/payment/response?gateway=Gateway_PayPal")), HiddenField::create("custom", "custom", $order_id), HiddenField::create("item_name", "item_name", "Order No. " . $order_id . " @ " . StoreSettings::get_settings()->StoreSettings_StoreName), HiddenField::create("amount", "amount", Order::create()->calculateOrderTotal($Order)), HiddenField::create("currency_code", "currency_code", DataObject::get_one("StoreCurrency", "(`SystemCreated`='1')")->Code), HiddenField::create("no_note", "no_note", "1"), HiddenField::create("no_shipping", "no_shipping", "1"), HiddenField::create("return", "return", Director::absoluteURL(Store_OrderController::create()->link()) . "/payment/success?gateway=Gateway_PayPal"), HiddenField::create("rm", "rm", "2"), HiddenField::create("cbt", "cbt", "Return to " . StoreSettings::get_settings()->StoreSettings_StoreName), HiddenField::create("cancel_return", "cancel_return", Director::absoluteURL(Store_OrderController::create()->link()) . "/payment/cancelled?gateway=Gateway_PayPal"));
     /* Actions */
     $actions = FieldList::create(FormAction::create('', 'If you are not transferred to PayPal in 5 seconds, click here.'));
     /* Required Fields */
     $required = new RequiredFields(array("business", "cmd", "notify_url", "item_name", "amount", "currency_code"));
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $actions, $required);
 }
 /**
  * newPayment
  * Begin payment process for an order using this payment method.
  *
  * @param Object $order_id The ID of the order we are to take payment for.
  * @return Void
  */
 public function newPayment($order_id)
 {
     $Order = Order::get_by_id("Order", $order_id);
     /* First things first, lets check that for this order:
      *
      * 1 - Courier is set
      * 2 - BillingAddressID is set
      * 3 - ShippingAddressID
      * 4 - TempBasketID is null
      *
      * If all checks pass, continue. Otherwise, show an unknown error.
      */
     if ($Order->Courier && $Order->BillingAddressID && $Order->ShippingAddressID && is_null($Order->TempBasketID)) {
         return Store_OrderController::create()->customise(array("Title" => "Transferring to PayPal...", "PayPalForm" => $this->PayPalForm($order_id)))->renderWith(array("Store_Order_Payment_PayPal", "Page"));
     } else {
         return Store_OrderController::create()->redirect(Store_OrderController::create()->link() . "/place/error");
     }
 }
Пример #3
0
 public function start($type, $order_id)
 {
     AuthPlugins::required($this, $this->available_type_permission[$type]);
     if (!array_key_exists($type, $this->available_type)) {
         $this->unsupported($type);
     }
     $smarty = parent::load('smarty');
     import('system/share/network/redirect');
     parent::load('model', 'system/contrib/auth');
     parent::load('model', 'order');
     parent::load('model', 'work');
     /*
      * 是否此人工作
      */
     $order = Order::get_by_id($order_id);
     $userinfo = User::info();
     if ($order->designer_id != $userinfo['id'] && $order->layouter_id != $userinfo['id'] && $order->programmer != $userinfo['id']) {
         $message = '这份工作好像不属于你';
         HTTPRedirect::flash_to('order', $message, $smarty);
     }
     /*
      * 下一工作流程
      */
     $workflow = Workflow::get_by_alias($this->available_type[$type]);
     $work = OrderWork::get_by_order($order_id, $type);
     /*
      * 工作已经开始
      */
     if ($work) {
         $message = sprintf('此订单的 %s 工作已经开始', $this->available_type[$type]);
         HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty);
     }
     $work = new OrderWork();
     $work->order_id = $order_id;
     $work->process = '10';
     $work->type = $type;
     $work->user_id = User::info('id');
     $work->save();
     $message = '标记工作开始成功, 工作进度被设为10%, 请及时登记您的工作进度';
     HTTPRedirect::flash_to('order/list/' . $workflow->id, $message, $smarty);
 }
Пример #4
0
 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);
 }
Пример #5
0
 public function last_pay($order_id)
 {
     AuthPlugins::required($this, array('销售顾问', '销售经理'));
     $workflow = Workflow::get_by_alias('尾款提交确认');
     $order = Order::get_by_id($order_id);
     $action = $order->Workflow->action;
     $payment = Payment::get_by_order_and_state($order_id, 0, 'last');
     if (!$payment) {
         HTTPRedirect::flash_to('order/detail/' . $order_id, '款项信息不存在', $this->smarty);
     }
     $payment->is_payed = '1';
     $payment->save();
     Order::set_workflow($order, $workflow);
     $message = '已经转入财务工作流程, 等待财务确认尾款';
     HTTPRedirect::flash_to($action, $message, $this->smarty);
 }
Пример #6
0
 public function detail($id)
 {
     $smarty = parent::load('smarty');
     $smarty->assign('page_title', '客户详情');
     $id = abs(intval($id));
     if (!$id) {
         $smarty->display(404);
     }
     parent::load('model', 'order');
     $order = Order::get_by_id($id);
     $smarty->assign('order', $order);
     $smarty->display('customer/detail');
 }