Example #1
0
 public function actionAdd()
 {
     $flowId = intval(EnvUtil::getRequest("flowid"));
     $flow = new ICFlowType($flowId);
     if (EnvUtil::submitCheck("formhash")) {
         $this->checkFlowAccess($flowId, 1, $this->createUrl("new/add"));
         $this->beforeAdd($_POST, $flow);
         $run = array("name" => $_POST["name"], "flowid" => $flowId, "beginuser" => $this->uid, "begintime" => TIMESTAMP);
         $runId = FlowRun::model()->add($run, true);
         $runProcess = array("runid" => $runId, "processid" => 1, "uid" => $this->uid, "flag" => FlowConst::PRCS_UN_RECEIVE, "flowprocess" => 1, "createtime" => TIMESTAMP);
         FlowRunProcess::model()->add($runProcess);
         if (strstr($flow->autoname, "{N}")) {
             FlowType::model()->updateCounters(array("autonum" => 1), sprintf("flowid = %d", $flowId));
             CacheUtil::rm("flowtype_" . $flowId);
         }
         $runData = array("runid" => $runId, "name" => $_POST["name"], "beginuser" => $this->uid, "begin" => TIMESTAMP);
         $this->handleRunData($flow, $runData);
         $param = array("flowid" => $flowId, "runid" => $runId, "processid" => 1, "flowprocess" => 1, "fromnew" => 1);
         $jumpUrl = $this->createUrl("form/index", array("key" => WfCommonUtil::param($param)));
         $this->ajaxReturn(array("isSuccess" => true, "jumpUrl" => $jumpUrl));
     } else {
         $this->checkFlowAccess($flowId, 1);
         if (!empty($flow->autoname)) {
             $runName = WfNewUtil::replaceAutoName($flow, $this->uid);
         } else {
             $runName = sprintf("%s (%s)", $flow->name, date("Y-m-d H:i:s"));
         }
         $data = array("flow" => $flow->toArray(), "runName" => $runName, "lang" => Ibos::getLangSources());
         $this->renderPartial("add", $data);
     }
 }
Example #2
0
 public function actionAdd()
 {
     $flowId = intval(EnvUtil::getRequest("flowid"));
     $flowname = EnvUtil::getRequest("name");
     $flow = new ICFlowType($flowId);
     if (!empty($flow->autoname)) {
         $flowname = WfNewUtil::replaceAutoName($flow, $this->uid);
     } else {
         $flowname = sprintf("%s (%s)", $flow->name, date("Y-m-d H:i:s"));
     }
     $this->checkFlowAccess($flowId, 1, $this->createUrl("new/add"));
     $run = array("name" => $flowname, "flowid" => $flowId, "beginuser" => $this->uid, "begintime" => TIMESTAMP);
     $runId = FlowRun::model()->add($run, true);
     $runProcess = array("runid" => $runId, "processid" => 1, "uid" => $this->uid, "flag" => FlowConst::PRCS_UN_RECEIVE, "flowprocess" => 1, "createtime" => TIMESTAMP);
     FlowRunProcess::model()->add($runProcess);
     if (strstr($flow->autoname, "{N}")) {
         FlowType::model()->updateCounters(array("autonum" => 1), sprintf("flowid = %d", $flowId));
     }
     $runData = array("runid" => $runId, "name" => $flowname, "beginuser" => $this->uid, "begin" => TIMESTAMP);
     $this->handleRunData($flow, $runData);
     $param = array("flowid" => $flowId, "runid" => $runId, "processid" => 1, "flowprocess" => 1, "fromnew" => 1);
     if (Ibos::app()->request->getIsAjaxRequest()) {
         $this->ajaxReturn(array("isSuccess" => true, "key" => WfCommonUtil::param($param)), "JSONP");
     } else {
         $url = Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param($param)));
         header("Location: {$url}");
     }
 }