public function insert() { $id = parent::insert(true); import("@.Workflow.Workflow"); $workflow = new Workflow($this->workflowAlias); $rs = $workflow->doNext($id, null, false, false); }
public function updateReview(DB $db, APIRequest $request, APIResponse $response) { $this->vars->review = new PerformanceReview(); $this->vars->review->loadById($db, $request->get('reviewId')); //validate? foreach ($request->post('questions') as $questionId => $answerPost) { $answer = new ReviewAnswer(); if (!$answer->loadOneWhere($db, 'question_id = ? and review_id = ?', [$questionId, $this->vars->review->id])) { $answer->questionId = $questionId; $answer->reviewId = $this->vars->review->id; } $answer->text = $answerPost['text']; $answer->scale = $answerPost['scale']; $answer->store($db); } if ($_POST['action'] == 'submit') { $this->vars->review->submitted = 'yes'; $this->vars->review->submittedYmdt = gmdate('Y-m-d H:i:s'); $this->vars->review->submit($db); $updater = new WorkflowUpdater(); $workflow = new Workflow(); $workflow->loadOneWhere($db, 'table_row_id = ? and type = ?', [$this->vars->review->id, 'review']); $updater->complete($db, $workflow); } $response->success(); }
public static function newWorkflow($type) { $wf = new Workflow(); $wf->ui_type = $type; $wf->save(); return $wf; }
public function run() { $bomModel = D("ProduceBoms"); $stockoutModel = D("Stockout"); $stockoutDetailModel = D("StockoutDetail"); $theBoms = $bomModel->where("plan_id=" . $this->mainrowId)->select(); $stockoutModel->startTrans(); $theStockout = array("bill_id" => makeBillCode("CK"), "source_id" => $this->mainrowId, "source_model" => "ProducePlan", "dateline" => CTS, "total_num" => 0, "stock_manager" => 0, "shipment_id" => 0, "status" => 0, "memo" => "ProducePlan #" . $this->mainrowId); $stockoutId = $stockoutModel->add($theStockout); if (!$stockoutId) { Log::write("SQL Error:" . $stockoutModel->getLastSql(), Log::SQL); $stockoutModel->rollback(); $this->response(array("type" => "message", "msg" => "Server Error.", "error" => 1)); } $totalNum = 0; foreach ($theBoms as $k => $v) { $totalNum += $v["num"]; $theDetail = array("stockout_id" => $stockoutId, "factory_code_all" => $v["factory_code_all"], "goods_id" => $v["goods_id"], "stock_id" => 0, "num" => $v["num"]); if (!$stockoutDetailModel->add($theDetail)) { //@todo Log::write("SQL Error:" . $stockoutModel->getLastSql(), Log::SQL); $stockoutModel->rollback(); $this->response(array("type" => "message", "msg" => "Server Error.", "error" => 1)); } } $stockoutModel->where("id=" . $stockoutId)->save(array("total_num" => $totalNum)); // echo $stockoutModel->getLastSql();exit; $stockoutModel->commit(); $workflow = new Workflow("stockout"); $workflow->doNext($stockoutId, false, true, false); // print_r($theBoms);exit; }
public function select($options = array()) { $data = parent::select($options); if (!$data) { return $data; } foreach ($data as $k => $v) { if ($v["stock_manager"]) { $data[$k]["stock_manager_name"] = toTruename($v["stock_manager"]); } else { $data[$k]["stock_manager_name"] = ""; } $data[$k]["sponsor"] = toTruename($v["user_id"]); $ids[] = $v["id"]; } // print_r($data);exit; if ($this->workflowAlias) { import("@.Workflow.Workflow"); $workflow = new Workflow($this->workflowAlias); $processData = $workflow->getListProcess($ids); foreach ($data as $k => $v) { $data[$k]["processes"] = $processData[$v[$this->workflowMainRowField]]; } } return $data; }
public function newPlan($data) { $rows = $data["rows"]; unset($data["rows"]); $this->startTrans(); $id = $this->add($data); if (!$id) { Log::write("SQL Error:" . $this->getLastSql(), Log::SQL); $this->rollback(); return false; } $detailModel = D("ProducePlanDetail"); foreach ($rows as $row) { $row["plan_id"] = $id; $rs = $detailModel->add($row); if (!$rs) { Log::write("SQL Error:" . $this->getLastSql(), Log::SQL); $this->rollback(); return false; } } $this->commit(); $workflow = new Workflow($this->workflowAlias); $workflow->doNext($id, "", true); return $id; }
public function newBill($data) { if (!$data["rows"]) { return; } if (!$this->checkFactoryCodeAll($data["rows"])) { $this->error = "factory_code_not_full"; return false; } $this->startTrans(); $purchaseId = $this->add($data); if (!$purchaseId) { $this->error = "insert purchase bill failed"; Log::write("SQL Error:" . $this->getLastSql(), Log::SQL); $this->rollback(); return false; } $detailModel = D("PurchaseDetail"); foreach ($data["rows"] as $row) { $row["purchase_id"] = $purchaseId; $row["price"] = $row["amount"]; if (!$detailModel->add($row)) { $this->error = "insert purchase bill detail failed"; Log::write("SQL Error:" . $detailModel->getLastSql(), Log::SQL); $this->rollback(); return false; } } $this->commit(); $workflow = new Workflow($this->workflowAlias); $workflow->doNext($purchaseId, "", true); return $purchaseId; }
public function run() { DB::table('workflow')->delete(); $flow = new Workflow(); $flow->id = '1'; $flow->workFlowName = 'Small Value Procurement (Below P50,000)'; $flow->totalDays = '45'; $flow->save(); $flow = new Workflow(); $flow->id = '2'; $flow->workFlowName = 'Small Value Procurement (Above P50,000 Below P500,000)'; $flow->totalDays = '120'; $flow->save(); $flow = new Workflow(); $flow->id = '3'; $flow->workFlowName = 'Bidding (Above P500,000)'; $flow->totalDays = '200'; $flow->save(); $flow = new Workflow(); $flow->id = '4'; $flow->workFlowName = 'Pakyaw'; $flow->totalDays = '200'; $flow->save(); $flow = new Workflow(); $flow->id = '5'; $flow->workFlowName = 'Direct Contracting'; $flow->totalDays = '200'; $flow->save(); }
public function read() { $mainrowId = $_GET["id"]; $workflowAlias = $_GET["workflowAlias"]; $modelName = ucfirst($workflowAlias); $model = D($modelName); $workflow = new Workflow($workflowAlias); $process = $workflow->getItemProcesses($modelName, $mainrowId, $model->relationModels); $this->response($process); }
/** * @param Workflow $workflow * @return ByTimeWorkflowStepsAndProgressBarForWizardView| * OnSaveWorkflowStepsAndProgressBarForWizardView * @throws NotSupportedException */ public static function makeStepsAndProgressBarViewFromWorkflow(Workflow $workflow) { $type = $workflow->getType(); if ($type == Workflow::TYPE_BY_TIME) { return new ByTimeWorkflowStepsAndProgressBarForWizardView(); } elseif ($type == Workflow::TYPE_ON_SAVE) { return new OnSaveWorkflowStepsAndProgressBarForWizardView(); } else { throw new NotSupportedException(); } }
public function run() { $stockin = D("Stockin"); $stockin->where("id=" . $this->mainrowId)->save(array("status" => 2)); $theStockin = $stockin->find($this->mainrowId); if ($theStockin["source_model"]) { //若外部生成,走外部下一流程 $workflow = new Workflow(lcfirst($theStockin["source_model"]), $this->action); $workflow->doNext($theStockin["source_id"], "", true, 3); } }
public function run() { $model = D("Stockout"); $theStockout = $model->find($this->mainrowId); $model->where("id=" . $this->mainrowId)->save(array("status" => 2)); if ($this->context["sourceModel"]) { $sourceNode = $this->getNodeByAlias(lcfirst($this->context["sourceModel"]), "Complete"); $workflow = new Workflow($this->context["sourceWorkflow"], $this->context); $workflow->doNext($theStockout["source_id"], $sourceNode["id"], true, 3); } }
public function record($data) { $data["create_dateline"] = CTS; $data["status"] = 0; $data["user_id"] = getCurrentUid(); $lastId = $this->add($data); if (!$lastId) { Log::write($this->getLastSql(), Log::SQL); return false; } $workflow = new Workflow("financePay"); $workflow->doNext($lastId, "", true); return $lastId; }
public function index() { //获取所有节点 if (!$_GET["mainrow_id"]) { return parent::index(); } //仅获取当前数据的下一ID // $map = array(); // $this->_filter($map); import("@.Workflow.Workflow"); $workflow = new Workflow($_GET["workflow_alias"]); $process = $workflow->getCurrentProcess($_GET["mainrow_id"]); $this->response(reIndex($process["nextNode"])); }
public function run() { $stockout = D("Stockout"); $stockoutId = $stockout->makeStockoutPaper("Orders", $this->mainrowId, "saler_id", "order_id"); //流程上下文 $this->context = array("sourceModel" => "Orders", "sourceWorkflow" => "orders", "sourceId" => $this->mainrowId, "sourceMainrowField" => "order_id"); $this->updateStatus("Orders", $this->mainrowId, 1); // $orderModel = D("Orders"); // $orderModel->where("id=".$this->mainrowId)->save(array("status" => 1)); // print_r($this->context);exit; //新建出库工作流 import("@.Workflow.Workflow"); $workflow = new Workflow("stockout", $this->context); $workflow->doNext($stockoutId, "", true, true); }
public function __construct(Tracker_RulesManager $global_rules_manager, Tracker_Workflow_Trigger_RulesManager $trigger_rules_manager, WorkflowBackendLogger $logger, $tracker_id) { $workflow_id = 0; $field_id = 0; $is_used = false; parent::__construct($global_rules_manager, $trigger_rules_manager, $logger, $workflow_id, $tracker_id, $field_id, $is_used); }
function generar_arbol_descendientes_sobre_grafo($grafo) { if (is_null($this->siguiente_caso_true) || is_null($this->siguiente_caso_false)) { throw new Exception("Error al dibujar arbol, este choice node no tiene siguientes!."); } $nombre_partida = "{$this->name}\\n({$this->accion})"; if (!empty($this->siguiente_caso_true)) { $siguiente_caso_true = Workflow::obtener_nodo($this->siguiente_caso_true); $nombre_llegada_true = "{$siguiente_caso_true->name}\\n({$siguiente_caso_true->accion})"; } else { $nombre_llegada_true = 'Ejecución Terminada'; } if (!empty($this->siguiente_caso_false)) { $siguiente_caso_false = Workflow::obtener_nodo($this->siguiente_caso_false); $nombre_llegada_false = "{$siguiente_caso_false->name}\\n({$siguiente_caso_false->accion})"; } else { $nombre_llegada_false = 'Ejecución Terminada'; } $nombre_partida = "{$this->name}\\n({$this->accion})"; $grafo->agregar($nombre_partida, $nombre_llegada_true, "VERDADERO", '#9ac836', 'octagon', 'ne'); $grafo->agregar($nombre_partida, $nombre_llegada_false, "FALSO", '#ff9c00', 'octagon', 'se'); if (!$grafo->existe_nodo_salida($nombre_llegada_true)) { $siguiente_caso_true->generar_arbol_descendientes_sobre_grafo($grafo); } if (!$grafo->existe_nodo_salida($nombre_llegada_false)) { $siguiente_caso_false->generar_arbol_descendientes_sobre_grafo($grafo); } }
public static function init($query = null) { self::$query = $query; $dataDir = $_SERVER['HOME'] . '/Library/Application Support/Alfred 2/Workflow Data/' . self::BUNDLE; if (!is_dir($dataDir)) { mkdir($dataDir); } self::$fileCookies = $dataDir . '/cookies'; $fileDb = $dataDir . '/db.sqlite'; $exists = file_exists($fileDb); self::$db = new PDO('sqlite:' . $fileDb, null, null, array(PDO::ATTR_PERSISTENT => true)); if (!$exists) { self::$db->exec(' CREATE TABLE config ( key TEXT PRIMARY KEY, value TEXT ) '); self::$db->exec(' CREATE TABLE request_cache ( url TEXT PRIMARY KEY, timestamp INTEGER, etag TEXT, content TEXT, refresh INTEGER ) '); } register_shutdown_function(array(__CLASS__, 'shutdown')); }
/** * Adds an email to the outgoing mail queue. * * @param string $recipient The recipient of this email * @param array $headers The list of headers that should be sent with this email * @param string $body The body of the message * @param integer $save_email_copy Whether to send a copy of this email to a configurable address or not (eventum_sent@) * @param integer $issue_id The ID of the issue. If false, email will not be associated with issue. * @param string $type The type of message this is. * @param integer $sender_usr_id The id of the user sending this email. * @param integer $type_id The ID of the event that triggered this notification (issue_id, sup_id, not_id, etc) * @return true, or a PEAR_Error object */ public static function add($recipient, $headers, $body, $save_email_copy = 0, $issue_id = false, $type = '', $sender_usr_id = false, $type_id = false) { Workflow::modifyMailQueue(Auth::getCurrentProject(false), $recipient, $headers, $body, $issue_id, $type, $sender_usr_id, $type_id); // avoid sending emails out to users with inactive status $recipient_email = Mail_Helper::getEmailAddress($recipient); $usr_id = User::getUserIDByEmail($recipient_email); if (!empty($usr_id)) { $user_status = User::getStatusByEmail($recipient_email); // if user is not set to an active status, then silently ignore if (!User::isActiveStatus($user_status) && !User::isPendingStatus($user_status)) { return false; } } $to_usr_id = User::getUserIDByEmail($recipient_email); $recipient = Mail_Helper::fixAddressQuoting($recipient); $reminder_addresses = Reminder::_getReminderAlertAddresses(); // add specialized headers if (!empty($issue_id) && (!empty($to_usr_id) && User::getRoleByUser($to_usr_id, Issue::getProjectID($issue_id)) != User::getRoleID('Customer')) || @in_array(Mail_Helper::getEmailAddress($recipient), $reminder_addresses)) { $headers += Mail_Helper::getSpecializedHeaders($issue_id, $type, $headers, $sender_usr_id); } // try to prevent triggering absence auto responders $headers['precedence'] = 'bulk'; // the 'classic' way, works with e.g. the unix 'vacation' tool $headers['Auto-submitted'] = 'auto-generated'; // the RFC 3834 way if (empty($issue_id)) { $issue_id = 'null'; } // if the Date: header is missing, add it. if (empty($headers['Date'])) { $headers['Date'] = Mime_Helper::encode(date('D, j M Y H:i:s O')); } if (!empty($headers['To'])) { $headers['To'] = Mail_Helper::fixAddressQuoting($headers['To']); } // encode headers and add special mime headers $headers = Mime_Helper::encodeHeaders($headers); $res = Mail_Helper::prepareHeaders($headers); if (Misc::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return $res; } // convert array of headers into text headers list(, $text_headers) = $res; $params = array('maq_save_copy' => $save_email_copy, 'maq_queued_date' => Date_Helper::getCurrentDateGMT(), 'maq_sender_ip_address' => !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'maq_recipient' => $recipient, 'maq_headers' => $text_headers, 'maq_body' => $body, 'maq_iss_id' => $issue_id, 'maq_subject' => $headers['Subject'], 'maq_type' => $type); if ($sender_usr_id) { $params['maq_usr_id'] = $sender_usr_id; } if ($type_id) { $params['maq_type_id'] = $type_id; } $stmt = 'INSERT INTO {{%mail_queue}} SET ' . DB_Helper::buildSet($params); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return $res; } return true; }
/** * @param $moduleClassName * @return null | string */ public static function renderNonEditableModuleStringContent($moduleClassName) { assert('is_string($moduleClassName)'); $modulesAndLabels = Workflow::getWorkflowSupportedModulesAndLabelsForCurrentUser(); if (isset($modulesAndLabels[$moduleClassName])) { return $modulesAndLabels[$moduleClassName]; } }
public function paramRules() { $workflows = Workflow::getList(false); // no "none" options $workflowIds = array_keys($workflows); $stages = count($workflowIds) ? Workflow::getStagesByNumber($workflowIds[0]) : array('---'); return array('title' => $this->title, 'modelClass' => 'modelClass', 'modelRequired' => 1, 'options' => array(array('name' => 'workflowId', 'label' => 'Process', 'type' => 'dropdown', 'options' => $workflows), array('name' => 'stageNumber', 'label' => 'Stage', 'type' => 'dependentDropdown', 'dependency' => 'workflowId', 'options' => $stages, 'optionsSource' => Yii::app()->createUrl('/workflow/workflow/getStageNames')))); }
public function paramRules() { $workflows = Workflow::getList(false); // no "none" options $workflowIds = array_keys($workflows); $stages = count($workflowIds) ? Workflow::getStages($workflowIds[0]) : array('---'); return array('title' => Yii::t('studio', $this->title), 'modelRequired' => 1, 'options' => array(array('name' => 'workflowId', 'label' => 'Workflow', 'type' => 'dropdown', 'options' => $workflows), array('name' => 'stageNumber', 'label' => 'Stage', 'type' => 'dropdown', 'options' => $stages))); }
public function paramRules() { $workflows = Workflow::getList(false); // no "none" options $workflowIds = array_keys($workflows); $stages = count($workflowIds) ? Workflow::getStagesByNumber($workflowIds[0]) : array('---'); $stages = array('' => Yii::t('app', 'Any')) + $stages; return array('title' => Yii::t('studio', $this->title), 'modelClass' => 'modelClass', 'options' => array(array('name' => 'workflowId', 'label' => Yii::t('studio', 'Process'), 'type' => 'dropdown', 'options' => $workflows), array('name' => 'stageNumber', 'label' => Yii::t('studio', 'Stage'), 'type' => 'dependentDropdown', 'dependency' => 'workflowId', 'options' => $stages, 'optional' => true, 'optionsSource' => Yii::app()->createUrl('/workflow/workflow/getStageNames')), array('name' => 'modelClass', 'label' => Yii::t('studio', 'Associated Record Type'), 'type' => 'dropdown', 'options' => X2Model::getModelTypesWhichSupportWorkflow(true)))); }
public function run() { $this->updateStatus("Returns", $this->mainrowId, 2); //财务 if (isModuleEnabled("Finance")) { $returns = D("Returns"); $theReturns = $returns->find($this->mainrowId); $financeModel = D("FinancePayPlan"); $data = array("source_model" => "Returns", "source_id" => $this->mainrowId, "subject" => $theReturns["subject"], "supplier_id" => $theReturns["customer_id"], "amount" => $theReturns["total_price_real"], "create_dateline" => CTS, "status" => 0, "type_id" => getTypeIdByAlias("pay", "returns"), "user_id" => getCurrentUid()); $lastId = $financeModel->add($data); // echo $lastId;exit; // echo $financeModel->getLastSql();exit; import("@.Workflow.Workflow"); $workflow = new Workflow("financePay"); $node = $workflow->doNext($lastId, "", true); // var_dump($node); } }
public function find($options = array()) { $data = parent::find($options); if (!$data) { return $data; } /** * 工作流 */ if ($this->workflowAlias) { import("@.Workflow.Workflow"); $workflow = new Workflow($this->workflowAlias); // var_dump($workflow);exit; $processData = $workflow->getCurrentProcess($data["id"]); $data["processes"] = $processData; } return $data; }
function onSubmit($vals) { loader_import('cms.Versioning.Rex'); $collection = $vals['collection']; unset($vals['collection']); if (empty($collection)) { $collection = 'sitellite_page'; } $return = $vals['_return']; unset($vals['_return']); $changelog = $vals['changelog']; unset($vals['changelog']); $rex = new Rex($collection); //$vals['sitellite_owner'] = session_username (); //$vals['sitellite_team'] = session_team (); unset($vals['submit_button']); unset($vals['tab1']); unset($vals['tab2']); unset($vals['tab3']); unset($vals['tab-end']); unset($vals['header_properties']); unset($vals['header_contact']); unset($vals['header_loc']); if ($vals['contact_url'] == 'http://') { $vals['contact_url'] = ''; } if ($vals['loc_map'] == 'http://') { $vals['loc_map'] = ''; } $res = $rex->create($vals, $changelog); if (isset($vals[$rex->key])) { $key = $vals[$rex->key]; } elseif (!is_bool($res)) { $key = $res; } else { $key = 'Unknown'; } if (!$res) { if (!$return) { $return = site_prefix() . '/index/cms-browse-action?collection=siteevent_event'; } echo loader_box('cms/error', array('message' => $rex->error, 'collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'return' => $return)); } else { loader_import('cms.Workflow'); echo Workflow::trigger('add', array('collection' => $collection, 'key' => $key, 'data' => $vals, 'changelog' => intl_get('Item added.'), 'message' => 'Collection: ' . $collection . ', Item: ' . $key)); session_set('sitellite_alert', intl_get('Your item has been created.')); if ($return) { header('Location: ' . $return); exit; } } header('Location: ' . site_prefix() . '/index/siteevent-app/id.' . $res); exit; }
/** * 删除流程 * * @param $hash_id * @param $user_id * @return bool */ public function delete($hash_id, $user_id) { $workflow = Workflow::findFirst(['hash_id = :hash_id: and user_id = :user_id:', 'bind' => ['hash_id' => $hash_id, 'user_id' => $user_id]]); if ($workflow) { WorkflowVar::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); WorkflowResult::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); WorkflowLog::find(['wf_id = :wf_id:', 'bind' => ['wf_id' => $workflow->id]])->delete(); return $workflow->delete(); } else { return false; } }
public static function getList() { $workflows = array(); $db = Loader::db(); $r = $db->Execute("select wfID from Workflows order by wfName asc"); while ($row = $r->FetchRow()) { $wf = Workflow::getByID($row['wfID']); if (is_object($wf)) { $workflows[] = $wf; } } return $workflows; }
/** * Process any workflow actions that are updates to the passed in model during the processing of any * ByTimeWorkflowQueue models. @see ByTimeWorkflowInQueueJob. * @param Workflow $workflow * @param RedBeanModel $model * @param User $triggeredByUser * @throws FailedToSaveModelException */ public static function processOnByTimeWorkflowInQueueJob(Workflow $workflow, RedBeanModel $model, User $triggeredByUser) { foreach ($workflow->getActions() as $action) { try { $helper = new WorkflowActionProcessingHelper((int) $workflow->getId(), $workflow->getName(), $action, $model, $triggeredByUser, false); $helper->processUpdateSelfAction(); $helper->processNonUpdateSelfAction(); } catch (Exception $e) { WorkflowUtil::handleProcessingException($e, 'application.modules.workflows.utils.WorkflowActionsUtil.processOnByTimeWorkflowInQueueJob'); } } }
function generar_arbol_descendientes_sobre_grafo($grafo) { $nombre_llegada = 'Ejecución Terminada'; $nombre_partida = "{$this->name}\\n({$this->accion})"; if (!empty($this->siguiente)) { $siguiente = Workflow::obtener_nodo($this->siguiente); $nombre_llegada = "{$siguiente->name}\\n({$siguiente->accion})"; } $grafo->agregar($nombre_partida, $nombre_llegada); if (!$grafo->existe_nodo_salida($nombre_llegada)) { $siguiente->generar_arbol_descendientes_sobre_grafo($grafo); } }