Example #1
0
    /**
     * Create Step for a Task
     *
     * @param string $taskUid    Unique id of Task
     * @param string $processUid Unique id of Process
     * @param array  $arrayData  Data
     *
     * return array Return data of the new Step created
     */
    public function create($taskUid, $processUid, $arrayData)
    {
        try {
            $arrayData = array_change_key_case($arrayData, CASE_UPPER);

            unset($arrayData["STEP_UID"]);

            //Verify data
            $this->throwExceptionIfNotExistsTask($taskUid);

            $this->throwExceptionIfNotExistsProcess($processUid);

            if (!isset($arrayData["STEP_TYPE_OBJ"])) {
                throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepTypeObj"])));
            }

            $arrayData["STEP_TYPE_OBJ"] = trim($arrayData["STEP_TYPE_OBJ"]);

            if ($arrayData["STEP_TYPE_OBJ"] == "") {
                throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepTypeObj"])));
            }

            if (!isset($arrayData["STEP_UID_OBJ"])) {
                throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepUidObj"])));
            }

            $arrayData["STEP_UID_OBJ"] = trim($arrayData["STEP_UID_OBJ"]);

            if ($arrayData["STEP_UID_OBJ"] == "") {
                throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepUidObj"])));
            }

            if (!isset($arrayData["STEP_MODE"])) {
                throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepMode"])));
            }

            $arrayData["STEP_MODE"] = trim($arrayData["STEP_MODE"]);

            if ($arrayData["STEP_MODE"] == "") {
                throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepMode"])));
            }

            $this->throwExceptionIfHaveInvalidValueInTypeObj($arrayData["STEP_TYPE_OBJ"]);

            $this->throwExceptionIfHaveInvalidValueInMode($arrayData["STEP_MODE"]);

            $msg = $this->existsObjectUid($arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"], $this->arrayParamException["stepUidObj"]);

            if ($msg != "") {
                throw new \Exception($msg);
            }

            if ($this->existsRecord($taskUid, $arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"])) {
                throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($taskUid . ", " . $arrayData["STEP_TYPE_OBJ"] . ", " . $arrayData["STEP_UID_OBJ"], "STEP")));
            }

            //Create
            $step = new \Step();

            $stepUid = $step->create(array(
                "PRO_UID" => $processUid,
                "TAS_UID" => $taskUid,
                "STEP_POSITION" => $step->getNextPosition($taskUid)
            ));

            if (!isset($arrayData["STEP_POSITION"]) || $arrayData["STEP_POSITION"] == "") {
                unset($arrayData["STEP_POSITION"]);
            }

            $arrayData = $this->update($stepUid, $arrayData);

            //Return
            unset($arrayData["STEP_UID"]);

            $arrayData = array_merge(array("STEP_UID" => $stepUid), $arrayData);

            if (!$this->formatFieldNameInUppercase) {
                $arrayData = array_change_key_case($arrayData, CASE_LOWER);
            }

            return $arrayData;
        } catch (\Exception $e) {
            throw $e;
        }
    }
Example #2
0
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 *
 */
try {
    global $RBAC;
    switch ($RBAC->userCanAccess('PM_FACTORY')) {
        case -2:
            G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
            G::header('location: ../login/login');
            die;
            break;
        case -1:
            G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
            G::header('location: ../login/login');
            die;
            break;
    }
    require_once 'classes/model/Step.php';
    $oStep = new Step();
    $sStepUID = $oStep->create(array('PRO_UID' => $_POST['sProcess'], 'TAS_UID' => $_POST['sTask']));
    $oStep->update(array('STEP_UID' => $sStepUID, 'STEP_TYPE_OBJ' => $_POST['sType'], 'STEP_UID_OBJ' => $_POST['sUID'], 'STEP_POSITION' => $oStep->getNextPosition($_POST['sTask']) - 1, 'STEP_MODE' => isset($_POST['sMode']) ? $_POST['sMode'] : 'EDIT'));
    G::LoadClass('processMap');
    $oProcessMap = new ProcessMap();
    $oProcessMap->getStepsCriteria($_POST['sTask']);
} catch (Exception $oException) {
    die($oException->getMessage());
}