function loadTest($aTestData, $aFields)
 {
     $oAppDocument = new AppDocument();
     try {
         return $oAppDocument->load($aFields['APP_DOC_UID']);
     } catch (Exception $oError) {
         return $oError;
     }
 }
function casesShowOuputDocumentExist($url)
{
    $urlArray = explode("?", $url);
    $urlParametroString = $urlArray[1];
    parse_str($urlParametroString, $_GET);
    require_once "classes/model/AppDocumentPeer.php";
    $oAppDocument = new AppDocument();
    $oAppDocument->Fields = $oAppDocument->load($_GET['a'], isset($_GET['v']) ? $_GET['v'] : null);
    $sAppDocUid = $oAppDocument->getAppDocUid();
    $info = pathinfo($oAppDocument->getAppDocFilename());
    if (!isset($_GET['ext'])) {
        $ext = $info['extension'];
    } else {
        if ($_GET['ext'] != '') {
            $ext = $_GET['ext'];
        } else {
            $ext = $info['extension'];
        }
    }
    $ver = isset($_GET['v']) && $_GET['v'] != '' ? '_' . $_GET['v'] : '';
    if (!$ver) {
        //This code is in the case the outputdocument won't be versioned
        $ver = '_1';
    }
    $realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $sAppDocUid . $ver . '.' . $ext;
    $realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . $ver . '.' . $ext;
    $realPath2 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/outdocs/' . $info['basename'] . '.' . $ext;
    $sw_file_exists = false;
    if (file_exists($realPath)) {
        $sw_file_exists = true;
    } elseif (file_exists($realPath1)) {
        $sw_file_exists = true;
        $realPath = $realPath1;
    } elseif (file_exists($realPath2)) {
        $sw_file_exists = true;
        $realPath = $realPath2;
    }
    $swFileExist = 0;
    if ($sw_file_exists) {
        $swFileExist = 1;
    }
    return $swFileExist;
}
}
if ((int) $_SESSION['INDEX'] < 1) {
    G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
    G::header('location: ' . $_SERVER['HTTP_REFERER']);
    die;
}
/* Includes */
G::LoadClass('case');
G::LoadClass('derivation');
/* GET , POST & $_SESSION Vars */
//$_SESSION['STEP_POSITION'] = (int)$_GET['POSITION'];
/* Menues */
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'cases';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = 'CASES_TO_REVISE';
$oCase = new Cases();
$Fields = $oCase->loadCase($_SESSION['APPLICATION']);
require_once 'classes/model/AppDocument.php';
require_once 'classes/model/Users.php';
$G_PUBLISH = new Publisher();
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['DOC']);
$oo = $oAppDocument->load($_GET['DOC']);
$oUser = new Users();
$aUser = $oUser->load($oAppDocument->Fields['USR_UID']);
$Fields['CREATOR'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'];
$oAppDocument->Fields['VIEW'] = G::LoadTranslation('ID_OPEN');
$oAppDocument->Fields['FILE'] = 'cases_ShowDocument?a=' . $_GET['DOC'] . '&r=' . rand();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ViewInputDocumentToRevise', '', G::array_merges($Fields, $oAppDocument->Fields), '');
G::RenderPage('publish');
 * 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.
 * 
 */
/*
 * Created on 13-02-2008
 *
 * @author David Callizaya <*****@*****.**>
 */
if (!isset($_SESSION['PROCESS'])) {
    G::header('location: login');
}
require_once "classes/model/AppDocumentPeer.php";
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['a']);
$sAppDocUid = $oAppDocument->getAppDocUid();
$info = pathinfo($oAppDocument->getAppDocFilename());
if (!isset($_GET['ext'])) {
    $ext = $info['extension'];
} else {
    if ($_GET['ext'] != '') {
        $ext = $_GET['ext'];
    } else {
        $ext = $info['extension'];
    }
}
$realPath = PATH_DOCUMENT . $_SESSION['APPLICATION'] . '/outdocs/' . $info['basename'] . '.' . $ext;
G::streamFile($realPath, true);
Exemplo n.º 5
0
    public function getAllObjectsFromProcess($PRO_UID, $OBJ_TYPE = '%')

    {

        $RESULT = Array();

        $oCriteria = new Criteria('workflow');

        $oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);

        $oCriteria->addSelectColumn(AppDocumentPeer::APP_UID);

        $oCriteria->addSelectColumn(AppDocumentPeer::DEL_INDEX);

        $oCriteria->addSelectColumn(AppDocumentPeer::DOC_UID);

        $oCriteria->addSelectColumn(AppDocumentPeer::USR_UID);

        $oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE);

        $oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_CREATE_DATE);

        $oCriteria->addSelectColumn(AppDocumentPeer::APP_DOC_INDEX);

        $oCriteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);



        $oCriteria->add(ApplicationPeer::PRO_UID, $PRO_UID);

        $oCriteria->addJoin(ApplicationPeer::APP_UID, AppDocumentPeer::APP_UID);



        $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, $OBJ_TYPE, Criteria::LIKE);



        $oDataset = DynaformPeer::doSelectRS($oCriteria);

        $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        while ($oDataset->next()) {

            $row = $oDataset->getRow();

            $oAppDocument = new AppDocument();

            $oAppDocument->Fields = $oAppDocument->load($row['APP_DOC_UID'], $row['DOC_VERSION']);



            $row['APP_DOC_FILENAME'] = $oAppDocument->Fields['APP_DOC_FILENAME'];

            array_push($RESULT, $row);

        }

        return $RESULT;

    }
Exemplo n.º 6
0
 /**
  * Get data of Cases InputDocument
  *
  * @param string $applicationUid
  * @param string $userUid
  *
  * return array Return an array with data of an InputDocument
  */
 public function getCasesInputDocuments($applicationUid, $userUid)
 {
     try {
         //Verify data inbox
         $case = new \ProcessMaker\BusinessModel\Cases();
         $arrayResult = $case->getStatusInfo($applicationUid, 0, $userUid);
         $flagInbox = true;
         if (empty($arrayResult) || !preg_match("/^(?:TO_DO|DRAFT)\$/", $arrayResult["APP_STATUS"])) {
             $flagInbox = false;
         }
         $user = new \Users();
         $appDocument = new \AppDocument();
         $configuraction = new \Configurations();
         $confEnvSetting = $configuraction->getFormats();
         $arrayInputDocument = array();
         //Query
         $criteria = $this->getAppDocumentCriteriaByData($applicationUid);
         if (!$flagInbox) {
             $criteria->add(\AppDocumentPeer::USR_UID, $userUid, \Criteria::EQUAL);
         }
         $rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         /*----------------------------------********---------------------------------*/
         $licensedFeatures =& \PMLicensedFeatures::getSingleton();
         $enablePMGmail = false;
         if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
             \G::LoadClass("pmDrive");
             $pmDrive = new \PMDrive();
             $enablePMGmail = $pmDrive->getStatusService();
         }
         /*----------------------------------********---------------------------------*/
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $arrayUserData = $user->load($row["USR_UID"]);
             $arrayAppDocument = $appDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);
             $row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
             $row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
             $row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];
             /*----------------------------------********---------------------------------*/
             //change donwload link - drive
             $driveDownload = @unserialize($arrayAppDocument['APP_DOC_DRIVE_DOWNLOAD']);
             if ($driveDownload !== false && is_array($driveDownload) && $enablePMGmail) {
                 if (array_key_exists('INPUT', $driveDownload)) {
                     $row['APP_DOC_LINK'] = $driveDownload['INPUT'];
                 } else {
                     if (array_key_exists('ATTACHED', $driveDownload)) {
                         $row['APP_DOC_LINK'] = $driveDownload['ATTACHED'];
                     }
                 }
             }
             /*----------------------------------********---------------------------------*/
             $arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
         }
         //Return
         return $arrayInputDocument;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 7
0
    public function getCompleteDocumentInfo ($appUid, $appDocUid, $docVersion, $docUid, $usrId)
    {
        //require_once ("classes/model/AppDocument.php");
        //require_once ("classes/model/InputDocument.php");
        //require_once ("classes/model/OutputDocument.php");
        //require_once ("classes/model/Users.php");

        //**** start get Doc Info
        $oApp = new Application();
        $oAppDocument = new AppDocument();
        G::LoadClass( 'case' );
        $oCase = new Cases();
        G::LoadClass( 'process' );
        $oProcess = new Process();
        if (($oApp->exists( $appUid )) || ($appUid == "00000000000000000000000000000000")) {
            if ($appUid == "00000000000000000000000000000000") {
                //External Files
                $row1 = $oAppDocument->load( $appDocUid, $docVersion );
                $row2 = array ('PRO_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' ));
                $row3 = array ('APP_TITLE' => G::LoadTranslation( 'ID_NOT_PROCESS_RELATED' ));
            } else {
                $row1 = $oAppDocument->load( $appDocUid, $docVersion );
                $row2 = $oCase->loadCase( $appUid );
                $row3 = $oProcess->Load( $row2['PRO_UID'] );
            }
            $lastVersion = $oAppDocument->getLastAppDocVersion( $appDocUid, $appUid );

            switch ($row1['APP_DOC_TYPE']) {
                case "OUTPUT":
                    $oOutputDocument = new OutputDocument();

                    $row4 = array();
                    $swOutDocExists = 0;

                    if ($oOutputDocument->OutputExists($docUid)) {
                        $row4 = $oOutputDocument->load($docUid);
                        $swOutDocExists = 1;
                    }

                    if ($swOutDocExists == 0) {
                        $swpdf = 0;
                        $swdoc = 0;

                        $info = pathinfo($oAppDocument->getAppDocFilename());

                        $version = (!empty($docVersion))? "_" . $docVersion : "_1";
                        $outDocPath = PATH_DOCUMENT . G::getPathFromUID($row1["APP_UID"]) . PATH_SEP . "outdocs" . PATH_SEP;

                        if (file_exists($outDocPath . $appDocUid . $version . ".pdf") ||
                            file_exists($outDocPath . $info["basename"] . $version . ".pdf") ||
                            file_exists($outDocPath . $info["basename"] . ".pdf")
                        ) {
                            $swpdf = 1;
                        }

                        if (file_exists($outDocPath . $appDocUid . $version . ".doc") ||
                            file_exists($outDocPath . $info["basename"] . $version . ".doc") ||
                            file_exists($outDocPath . $info["basename"] . ".doc")
                        ) {
                            $swdoc = 1;
                        }

                        if ($swpdf == 1 && $swdoc == 1) {
                            $row4["OUT_DOC_GENERATE"] = "BOTH";
                        } else {
                            if ($swpdf == 1) {
                                $row4["OUT_DOC_GENERATE"] = "PDF";
                            } else {
                                if ($swdoc == 1) {
                                    $row4["OUT_DOC_GENERATE"] = "DOC";
                                } else {
                                    $row4["OUT_DOC_GENERATE"] = "NOFILE";
                                }
                            }
                        }
                    }

                    $versioningEnabled = false; //$row4['OUT_DOC_VERSIONING']; //Only enabled for Input or Attached documents. Need to study the best way for Output docs.

                    switch ($row4['OUT_DOC_GENERATE']) {
                        case "PDF":
                            $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand();
                            $downloadLink1 = "";
                            $downloadLabel = ".pdf";
                            $downloadLabel1 = "";
                            break;
                        case "DOC":
                            $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand();
                            $downloadLink1 = "";
                            $downloadLabel = ".doc";
                            $downloadLabel1 = "";
                            break;
                        case "BOTH":
                            $downloadLink = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=pdf" . "&random=" . rand();
                            $downloadLink1 = "../cases/cases_ShowOutputDocument?a=" . $appDocUid . "&v=" . $docVersion . "&ext=doc" . "&random=" . rand();
                            $downloadLabel = ".pdf";
                            $downloadLabel1 = ".doc";
                            break;
                        case "NOFILE":
                            $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
                            $downloadLink1 = "";
                            $downloadLabel = G::LoadTranslation("ID_DOWNLOAD");
                            $downloadLabel1 = "";
                            break;
                    }

                    if ($swOutDocExists == 0) {
                        $row4 = array();
                    }
                    break;
                case "INPUT":
                    $oInputDocument = new InputDocument();
                    if ($docUid != - 1) {
                        if ($oInputDocument->InputExists( $docUid )) {
                            $row4 = $oInputDocument->load( $docUid );
                            $versioningEnabled = $row4['INP_DOC_VERSIONING'];
                        } else {
                            $row4 = array ();
                            $versioningEnabled = false;
                        }
                        $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
                        $downloadLink1 = "";
                        $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
                        $downloadLabel1 = "";
                    } else {
                        $row4 = array ();
                        $versioningEnabled = false;
                        $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
                        $downloadLink1 = "";
                        $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
                        $downloadLabel1 = "";
                    }

                    if (! empty( $row1["APP_DOC_PLUGIN"] )) {
                        $pluginRegistry = &PMPluginRegistry::getSingleton();
                        $pluginName = $row1["APP_DOC_PLUGIN"];
                        $fieldValue = "";

                        if (file_exists( PATH_PLUGINS . $pluginName . ".php" )) {
                            $pluginDetail = $pluginRegistry->getPluginDetails( $pluginName . ".php" );

                            if ($pluginDetail) {
                                if ($pluginDetail->enabled) {
                                    require_once (PATH_PLUGINS . $pluginName . ".php");
                                    $pluginNameClass = $pluginName . "Plugin";
                                    $objPluginClass = new $pluginNameClass( $pluginName );

                                    if (isset( $objPluginClass->sMethodGetUrlDownload ) && ! empty( $objPluginClass->sMethodGetUrlDownload )) {
                                        if (file_exists( PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php" )) {
                                            require_once (PATH_PLUGINS . $pluginName . PATH_SEP . "class." . $pluginName . ".php");
                                            $pluginNameClass = $pluginName . "Class";
                                            $objClass = new $pluginNameClass();

                                            if (method_exists( $objClass, $objPluginClass->sMethodGetUrlDownload )) {
                                                eval( "\$url = \$objClass->" . $objPluginClass->sMethodGetUrlDownload . "(\"" . $row1["APP_DOC_UID"] . "\");" );
                                                $downloadLink = $url;
                                                $fieldValue = $row1["APP_DOC_PLUGIN"];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $row1["APP_DOC_PLUGIN"] = $fieldValue;
                    }
                    break;
                default:
                    $row4 = array ();
                    $versioningEnabled = false;
                    $downloadLink = "../cases/cases_ShowDocument?a=" . $appDocUid . "&v=" . $docVersion;
                    $downloadLink1 = "";
                    $downloadLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
                    $downloadLabel1 = "";
                    break;
            }
            $oUser = new Users();
            if (($usrId != "-1") && ($oUser->userExists( $usrId ))) {
                $row5 = $oUser->load( $usrId );
            } else {
                $row5['USR_USERNAME'] = "******";
            }

            //Labels/Links
            $row6 = array ();
            $row6['DELETE_LABEL'] = G::LoadTranslation( 'ID_DELETE' );
            $row6['DOWNLOAD_LABEL'] = $downloadLabel;
            $row6['DOWNLOAD_LINK'] = $downloadLink;
            $row6['DOWNLOAD_LABEL1'] = $downloadLabel1;
            $row6['DOWNLOAD_LINK1'] = $downloadLink1;
            //if(($docVersion>1)&&($row1['APP_DOC_TYPE']!="OUTPUT")){
            if (($docVersion > 1)) {
                $row6['VERSIONHISTORY_LABEL'] = G::LoadTranslation( 'ID_VERSION_HISTORY' );
            }
            if ($versioningEnabled) {
                $row6['NEWVERSION_LABEL'] = G::LoadTranslation( 'ID_NEW_VERSION' );
            }
            $row6['APP_DOC_UID_VERSION'] = $appDocUid . "_" . $docVersion;

            if ($appUid == "00000000000000000000000000000000") {
                //External Files
                $row1['APP_DOC_TYPE'] = G::LoadTranslation( 'ID_EXTERNAL_FILE' );
            }
            //**** End get docinfo
            $infoMerged = array_merge( $row1, $row2, $row3, $row4, $row5, $row6 );

            $sUserUID = $_SESSION['USER_LOGGED'];
            $aObjectPermissions = array ();
            if (isset( $infoMerged['PRO_UID'] )) {
                $aObjectPermissions = $oCase->getAllObjects( $infoMerged['PRO_UID'], $infoMerged['APP_UID'], '', $sUserUID );
            }

            if (! is_array( $aObjectPermissions )) {
                $aObjectPermissions = array ('DYNAFORMS' => array (- 1),
                'INPUT_DOCUMENTS' => array (- 1),
                'OUTPUT_DOCUMENTS' => array (- 1)
                );
            }
            if (! isset( $aObjectPermissions['DYNAFORMS'] )) {
                $aObjectPermissions['DYNAFORMS'] = array (- 1);
            } else {
                if (! is_array( $aObjectPermissions['DYNAFORMS'] )) {
                    $aObjectPermissions['DYNAFORMS'] = array (- 1);
                }
            }
            if (! isset( $aObjectPermissions['INPUT_DOCUMENTS'] )) {
                $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1);
            } else {
                if (! is_array( $aObjectPermissions['INPUT_DOCUMENTS'] )) {
                    $aObjectPermissions['INPUT_DOCUMENTS'] = array (- 1);
                }
            }
            if (! isset( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) {
                $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1);
            } else {
                if (! is_array( $aObjectPermissions['OUTPUT_DOCUMENTS'] )) {
                    $aObjectPermissions['OUTPUT_DOCUMENTS'] = array (- 1);
                }
            }
            return array_merge( $infoMerged, $aObjectPermissions );
        }
    }
Exemplo n.º 8
0
    /**
     * Get data of Cases InputDocument
     *
     * @param string $applicationUid
     * @param string $userUid
     *
     * return array Return an array with data of an InputDocument
     */
    public function getCasesInputDocuments($applicationUid, $userUid)
    {
        try {
            //Verify data inbox
            $case = new \ProcessMaker\BusinessModel\Cases();
            $arrayResult = $case->getStatusInfo($applicationUid, 0, $userUid);

            $flagInbox = true;

            if (empty($arrayResult) || !preg_match("/^(?:TO_DO|DRAFT)$/", $arrayResult["APP_STATUS"])) {
                $flagInbox = false;
            }

            $user = new \Users();
            $appDocument = new \AppDocument();
            $configuraction = new \Configurations();

            $confEnvSetting = $configuraction->getFormats();

            $arrayInputDocument = array();

            //Query
            $criteria = $this->getAppDocumentCriteriaByData($applicationUid);

            if (!$flagInbox) {
                $criteria->add(\AppDocumentPeer::USR_UID, $userUid, \Criteria::EQUAL);
            }

            $rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
            $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

            while ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                $arrayUserData = $user->load($row["USR_UID"]);

                $arrayAppDocument = $appDocument->load($row["APP_DOC_UID"], $row["DOC_VERSION"]);

                $row["APP_DOC_FILENAME"] = $arrayAppDocument["APP_DOC_FILENAME"];
                $row["APP_DOC_CREATE_USER"] = $configuraction->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
                $row["APP_DOC_LINK"] = "cases/cases_ShowDocument?a=" . $row["APP_DOC_UID"] . "&v=" . $row["DOC_VERSION"];

                $arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
            }

            //Return
            return $arrayInputDocument;
        } catch (\Exception $e) {
            throw $e;
        }
    }
Exemplo n.º 9
0
     $dateFormat = "";
     $varFlag = isset($generalConfCasesList['casesListDateFormat']);
     if ($varFlag && !empty($generalConfCasesList['casesListDateFormat'])) {
         $dateFormat = $generalConfCasesList['casesListDateFormat'];
     }
     $r = new stdclass();
     $r->data = $aProcesses;
     $r->totalCount = $totalCount;
     $r->dataFormat = $dateFormat;
     echo Bootstrap::json_encode($r);
     break;
 case 'showGeneratedDocument':
     //require_once 'classes/model/AppDocument.php';
     //require_once 'classes/model/AppDelegation.php';
     $oAppDocument = new AppDocument();
     $aFields = $oAppDocument->load($_POST['APP_DOC_UID']);
     require_once 'classes/model/OutputDocument.php';
     $oOutputDocument = new OutputDocument();
     $aOD = $oOutputDocument->load($aFields['DOC_UID']);
     $oCriteria = new Criteria('workflow');
     $oCriteria->add(AppDelegationPeer::APP_UID, $aFields['APP_UID']);
     $oCriteria->add(AppDelegationPeer::DEL_INDEX, $aFields['DEL_INDEX']);
     $oDataset = AppDelegationPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aRow = $oDataset->getRow();
     $oTask = new Task();
     $aTask = $oTask->load($aRow['TAS_UID']);
     $aFields['ORIGIN'] = $aTask['TAS_TITLE'];
     require_once 'classes/model/Users.php';
     $oUser = new Users();
Exemplo n.º 10
0
     $Fields['APP_DOC_UID'] = $_POST['appDocId'];
     $Fields['actionType'] = $_POST['actionType'];
     $Fields["docVersion"] = (int) $_POST["docVersion"];
     $oInputDocument = new InputDocument();
     $InpDocData = $oInputDocument->load($Fields['DOC_UID']);
     $inpDocMaxFilesize = $InpDocData["INP_DOC_MAX_FILESIZE"];
     $inpDocMaxFilesizeUnit = $InpDocData["INP_DOC_MAX_FILESIZE_UNIT"];
     $inpDocMaxFilesize = $inpDocMaxFilesize * ($inpDocMaxFilesizeUnit == "MB" ? 1024 * 1024 : 1024);
     //Bytes
     $Fields["INP_DOC_SUPPORTED_EXTENSIONS_FILENAME_LABEL"] = "[" . $InpDocData["INP_DOC_TYPE_FILE"] . "]";
     $Fields["INP_DOC_MAX_FILESIZE"] = $inpDocMaxFilesize;
     $Fields["INP_DOC_MAX_FILESIZE_LABEL"] = $inpDocMaxFilesize > 0 ? "[" . $InpDocData["INP_DOC_MAX_FILESIZE"] . " " . $InpDocData["INP_DOC_MAX_FILESIZE_UNIT"] . "]" : "";
     $Fields['fileTypes'] = $InpDocData['INP_DOC_TYPE_FILE'];
     if ($_POST['actionType'] == 'NV') {
         $appDocument = new AppDocument();
         $arrayAppDocumentData = $appDocument->load($_POST["appDocId"]);
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SupervisorSaveDocument?APP_DOC_UID=' . $_POST['appDocId'] . "&DOC_VERSION=" . ($Fields['docVersion'] + 1) . '&APP_UID=' . $arrayAppDocumentData["APP_UID"] . '&UID=' . $_POST['docID']);
     } else {
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'cases_SupervisorSaveDocument?UID=' . $_POST['docID'] . '&APP_UID=' . $_POST['appDocId']);
     }
     G::RenderPage('publish', 'raw');
     break;
 case "inputDocumentVersionHistory":
     //krumo($_POST);
     $G_PUBLISH = new Publisher();
     $Fields['DOC_UID'] = $_POST['docID'];
     $Fields['APP_DOC_UID'] = $_POST['appDocId'];
     $G_PUBLISH->AddContent('propeltable', 'paged-table', 'cases/cases_InputdocsListHistory', $oCase->getInputDocumentsCriteria($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_POST['docID'], $_POST['appDocId']), array());
     //$aFields
     //$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral',
     // '', $Fields, 'cases_SaveDocument?UID=' . $_POST['docID']);
Exemplo n.º 11
0
 public function getDynaformHistory($PRO_UID, $TAS_UID, $APP_UID, $DYN_UID = "")
 {
     G::LoadClass('case');
     $oCase = new Cases();
     $oCase->verifyTable();
     $aObjectPermissions = $oCase->getAllObjects($PRO_UID, $APP_UID, $TAS_UID, $_SESSION['USER_LOGGED']);
     if (!is_array($aObjectPermissions)) {
         $aObjectPermissions = array('DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1));
     }
     if (!isset($aObjectPermissions['DYNAFORMS'])) {
         $aObjectPermissions['DYNAFORMS'] = array(-1);
     } else {
         if (!is_array($aObjectPermissions['DYNAFORMS'])) {
             $aObjectPermissions['DYNAFORMS'] = array(-1);
         }
     }
     if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) {
         $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
     } else {
         if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) {
             $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
         }
     }
     if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
         $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
     } else {
         if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
             $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
         }
     }
     $appDocument = new AppDocument();
     foreach (array("INPUT_DOCUMENTS", "OUTPUT_DOCUMENTS") as $value) {
         $key = $value;
         if ($aObjectPermissions[$key]) {
             foreach ($aObjectPermissions[$key] as $key2 => $value2) {
                 $appDocumentUid = $value2;
                 try {
                     $arrayAppDocumentData = $appDocument->load($appDocumentUid);
                     $aObjectPermissions[$key][$key2] = $arrayAppDocumentData["DOC_UID"];
                 } catch (Exception $e) {
                 }
             }
         }
     }
     $dynaForm = new Dynaform();
     $inputDocument = new InputDocument();
     $outputDocument = new OutputDocument();
     $c = new Criteria('workflow');
     $c->addSelectColumn(AppHistoryPeer::APP_UID);
     $c->addSelectColumn(AppHistoryPeer::DEL_INDEX);
     $c->addSelectColumn(AppHistoryPeer::PRO_UID);
     $c->addSelectColumn(AppHistoryPeer::TAS_UID);
     $c->addSelectColumn(AppHistoryPeer::DYN_UID);
     $c->addSelectColumn(AppHistoryPeer::OBJ_TYPE);
     $c->addSelectColumn(AppHistoryPeer::USR_UID);
     $c->addSelectColumn(AppHistoryPeer::APP_STATUS);
     $c->addSelectColumn(AppHistoryPeer::HISTORY_DATE);
     $c->addSelectColumn(AppHistoryPeer::HISTORY_DATA);
     $c->addSelectColumn(UsersPeer::USR_FIRSTNAME);
     $c->addSelectColumn(UsersPeer::USR_LASTNAME);
     $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)");
     $c->addJoin(AppHistoryPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
     //WHERE
     $c->add($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["DYNAFORMS"], Criteria::IN)->addOr($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["INPUT_DOCUMENTS"], Criteria::IN))->addOr($c->getNewCriterion(AppHistoryPeer::DYN_UID, $aObjectPermissions["OUTPUT_DOCUMENTS"], Criteria::IN)));
     $c->add(AppHistoryPeer::PRO_UID, $PRO_UID);
     $c->add(AppHistoryPeer::APP_UID, $APP_UID);
     $c->add(AppHistoryPeer::TAS_UID, $TAS_UID);
     if (isset($DYN_UID) && $DYN_UID != "") {
         $c->add(AppHistoryPeer::DYN_UID, $DYN_UID);
     }
     //Execute
     $oDataset = AppHistoryPeer::doSelectRS($c);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aDynHistory = array();
     $aDynHistory[] = array('DYN_TITLE' => 'char');
     while ($oDataset->next()) {
         $aRow = $oDataset->getRow();
         $title = "";
         switch ($aRow["OBJ_TYPE"]) {
             case "DYNAFORM":
                 $arrayDynaFormData = $dynaForm->Load($aRow["DYN_UID"]);
                 $title = $arrayDynaFormData["DYN_TITLE"] . " (" . G::LoadTranslation("ID_DYNAFORM") . ")";
                 break;
             case "INPUT_DOCUMENT":
                 $arrayInputDocumentData = $inputDocument->load($aRow["DYN_UID"]);
                 $title = $arrayInputDocumentData["INP_DOC_TITLE"] . " (" . G::LoadTranslation("ID_INPUT_DOCUMENT") . ")";
                 break;
             case "OUTPUT_DOCUMENT":
                 $arrayOutputDocumentData = $outputDocument->load($aRow["DYN_UID"]);
                 $title = $arrayOutputDocumentData["OUT_DOC_TITLE"] . " (" . G::LoadTranslation("ID_OUTPUT_DOCUMENT") . ")";
                 break;
             case "ASSIGN_TASK":
                 $title = G::LoadTranslation("ID_ASSIGN_TASK") . " (" . G::LoadTranslation("ID_TRIGGERS") . ")";
                 break;
         }
         $aRow["DYN_TITLE"] = $title;
         $changedValues = unserialize($aRow['HISTORY_DATA']);
         $html = "<table border='0' cellpadding='0' cellspacing='0'>";
         $sw_add = false;
         foreach ($changedValues as $key => $value) {
             if ($value != null && !is_array($value)) {
                 $sw_add = true;
                 $html .= "<tr>";
                 $html .= "<td><b>{$key}:</b> </td>";
                 $html .= "<td>{$value}</td>";
                 $html .= "</tr>";
             }
             if (is_array($value)) {
                 $html .= "<tr>";
                 $html .= "<td><b>{$key} (grid):</b> </td>";
                 $html .= "<td>";
                 $html .= "<table>";
                 foreach ($value as $key1 => $value1) {
                     $html .= "<tr>";
                     $html .= "<td><b>{$key1}</b></td>";
                     $html .= "<td>";
                     if (is_array($value1)) {
                         $sw_add = true;
                         $html .= "<table>";
                         foreach ($value1 as $key2 => $value2) {
                             $html .= "<tr>";
                             $html .= "<td><b>{$key2}</b></td>";
                             $html .= "<td>{$value2}</td>";
                             $html .= "</tr>";
                         }
                         $html .= "</table>";
                     }
                     $html .= "</td>";
                     $html .= "</tr>";
                 }
                 $html .= "</table>";
                 $html .= "</td>";
                 $html .= "</tr>";
                 $html .= "</td>";
             }
         }
         $html .= "</table>";
         $aRow['FIELDS'] = $html;
         if ($sw_add) {
             $aDynHistory[] = $aRow;
         }
     }
     global $_DBArray;
     $_DBArray['DynaformsHistory'] = $aDynHistory;
     $_SESSION['_DBArray'] = $_DBArray;
     G::LoadClass('ArrayPeer');
     $oCriteria = new Criteria('dbarray');
     $oCriteria->setDBArrayTable('DynaformsHistory');
     $oCriteria->addAscendingOrderByColumn(AppHistoryPeer::HISTORY_DATE);
     return $oCriteria;
 }
Exemplo n.º 12
0
    /**
     * second step for upload file
     * upload file in foler app_uid
     *
     * @param $userUid
     * @param $Fields
     * @param $type
     * @throws \Exception
     */
    public function documentUploadFiles($userUid, $app_uid, $app_doc_uid, $request_data)
    {
        $response = array("status" => "fail");
        if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
            $arrayField = array ();
            $arrayFileName = array ();
            $arrayFileTmpName = array ();
            $arrayFileError = array ();
            $i = 0;

            foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
                if (is_array( $fieldValue )) {
                    foreach ($fieldValue as $index => $value) {
                        if (is_array( $value )) {
                            foreach ($value as $grdFieldIndex => $grdFieldValue) {
                                $arrayField[$i]["grdName"] = $fieldIndex;
                                $arrayField[$i]["grdFieldName"] = $grdFieldIndex;
                                $arrayField[$i]["index"] = $index;

                                $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
                                $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
                                $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
                                $i = $i + 1;
                            }
                        }
                    }
                } else {
                    $arrayField[$i] = $fieldIndex;

                    $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
                    $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
                    $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
                    $i = $i + 1;
                }
            }
            if (count( $arrayField ) > 0) {
                for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
                    if ($arrayFileError[$i] == 0) {
                        $indocUid = null;
                        $fieldName = null;
                        $fileSizeByField = 0;

                        $oAppDocument = new \AppDocument();
                        $aAux = $oAppDocument->load($app_doc_uid);

                        $iDocVersion = $oAppDocument->getDocVersion();
                        $sAppDocUid = $oAppDocument->getAppDocUid();
                        $aInfo = pathinfo( $oAppDocument->getAppDocFilename() );
                        $sExtension = ((isset( $aInfo["extension"] )) ? $aInfo["extension"] : "");
                        $pathUID = G::getPathFromUID($app_uid);
                        $sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
                        $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
                        G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
                        $response = array("status" => "ok");
                    }
                }
            }
        }

        return $response;
    }
Exemplo n.º 13
0
    public function getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
    {
        \G::LoadClass("configuration");
        $conf = new \Configurations();
        $confEnvSetting = $conf->getFormats();
        //verifica si la tabla OBJECT_PERMISSION
        $cases = new \cases();
        $cases->verifyTable();
        $listing = false;
        $oPluginRegistry = & \PMPluginRegistry::getSingleton();
        if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
            $folderData = new \folderData(null, null, $sApplicationUID, null, $sUserUID);
            $folderData->PMType = "OUTPUT";
            $folderData->returnList = true;
            //$oPluginRegistry = & PMPluginRegistry::getSingleton();
            $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
        }
        $aObjectPermissions = $cases->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID);
        if (!is_array($aObjectPermissions)) {
            $aObjectPermissions = array('DYNAFORMS' => array(-1),'INPUT_DOCUMENTS' => array(-1),'OUTPUT_DOCUMENTS' => array(-1));
        }
        if (!isset($aObjectPermissions['DYNAFORMS'])) {
            $aObjectPermissions['DYNAFORMS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['DYNAFORMS'])) {
                $aObjectPermissions['DYNAFORMS'] = array(-1);
            }
        }
        if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) {
            $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) {
                $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1);
            }
        }
        if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
            $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
        } else {
            if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) {
                $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1);
            }
        }
        $aDelete = $cases->getAllObjectsFrom($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID, 'DELETE');
        $oAppDocument = new \AppDocument();
        $oCriteria = new \Criteria('workflow');
        $oCriteria->add(\AppDocumentPeer::APP_UID, $sApplicationUID);
        $oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
        $oCriteria->add(\AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), \Criteria::IN);
        //$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], Criteria::IN);
        $oCriteria->add(
            $oCriteria->getNewCriterion(
                \AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], \Criteria::IN)->addOr($oCriteria->getNewCriterion(\AppDocumentPeer::USR_UID, $sUserUID, \Criteria::EQUAL))
        );
        $aConditions = array();
        $aConditions[] = array(\AppDocumentPeer::APP_UID, \AppDelegationPeer::APP_UID);
        $aConditions[] = array(\AppDocumentPeer::DEL_INDEX, \AppDelegationPeer::DEL_INDEX);
        $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
        $oCriteria->add(\AppDelegationPeer::PRO_UID, $sProcessUID);
        $oCriteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
        $oDataset = \AppDocumentPeer::doSelectRS($oCriteria);
        $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
        $oDataset->next();
        $aOutputDocuments = array();
        $aOutputDocuments[] = array(
            'APP_DOC_UID' => 'char',
            'DOC_UID' => 'char',
            'APP_DOC_COMMENT' => 'char',
            'APP_DOC_FILENAME' => 'char',
            'APP_DOC_INDEX' => 'integer'
        );
        $oUser = new \Users();
        while ($aRow = $oDataset->getRow()) {
            $oCriteria2 = new \Criteria('workflow');
            $oCriteria2->add(\AppDelegationPeer::APP_UID, $sApplicationUID);
            $oCriteria2->add(\AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']);
            $oDataset2 = \AppDelegationPeer::doSelectRS($oCriteria2);
            $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
            $oDataset2->next();
            $aRow2 = $oDataset2->getRow();
            $oTask = new \Task();
            if ($oTask->taskExists($aRow2['TAS_UID'])) {
                $aTask = $oTask->load($aRow2['TAS_UID']);
            } else {
                $aTask = array('TAS_TITLE' => '(TASK DELETED)');
            }
            $lastVersion = $oAppDocument->getLastDocVersion($aRow['DOC_UID'], $sApplicationUID);
            if ($lastVersion == $aRow['DOC_VERSION']) {
                //Only show last document Version
                $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']);
                //Get output Document information
                $oOutputDocument = new \OutputDocument();
                $aGields = $oOutputDocument->load($aRow['DOC_UID']);
                //OUTPUTDOCUMENT
                $outDocTitle = $aGields['OUT_DOC_TITLE'];
                switch ($aGields['OUT_DOC_GENERATE']) {
                    //G::LoadTranslation(ID_DOWNLOAD)
                    case "PDF":
                        $fileDoc = 'javascript:alert("NO DOC")';
                        $fileDocLabel = " ";
                        $filePdf = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
                        $filePdfLabel = ".pdf";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) {
                                    $filePdfLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf";
                                    $filePdf = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                    case "DOC":
                        $fileDoc = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
                        $fileDocLabel = ".doc";
                        $filePdf = 'javascript:alert("NO PDF")';
                        $filePdfLabel = " ";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) {
                                    $fileDocLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc";
                                    $fileDoc = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                    case "BOTH":
                        $fileDoc = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand();
                        $fileDocLabel = ".doc";
                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) {
                                    $fileDocLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc";
                                    $fileDoc = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        $filePdf = 'cases_ShowOutputDocument?a=' .
                            $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand();
                        $filePdfLabel = ".pdf";

                        if (is_array($listing)) {
                            foreach ($listing as $folderitem) {
                                if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) {
                                    $filePdfLabel = \G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf";
                                    $filePdf = $folderitem->downloadScript;
                                    continue;
                                }
                            }
                        }
                        break;
                }
                try {
                    $aAux1 = $oUser->load($aAux['USR_UID']);
                    $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]);
                } catch (\Exception $oException) {
                    $sUser = '******';
                }
                //if both documents were generated, we choose the pdf one, only if doc was
                //generate then choose the doc file.
                $firstDocLink = $filePdf;
                $firstDocLabel = $filePdfLabel;
                if ($aGields['OUT_DOC_GENERATE'] == 'DOC') {
                    $firstDocLink = $fileDoc;
                    $firstDocLabel = $fileDocLabel;
                }
                $aFields = array(
                    'APP_DOC_UID' => $aAux['APP_DOC_UID'],
                    'DOC_UID' => $aAux['DOC_UID'],
                    'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'],
                    'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'],
                    'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'],
                    'ORIGIN' => $aTask['TAS_TITLE'],
                    'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'],
                    'CREATED_BY' => $sUser,
                    'FILEDOC' => $fileDoc,
                    'FILEPDF' => $filePdf,
                    'OUTDOCTITLE' => $outDocTitle,
                    'DOC_VERSION' => $aAux['DOC_VERSION'],
                    'TYPE' => $aAux['APP_DOC_TYPE'] . ' ' . $aGields['OUT_DOC_GENERATE'],
                    'DOWNLOAD_LINK' => $firstDocLink,
                    'DOWNLOAD_FILE' => $aAux['APP_DOC_FILENAME'] . $firstDocLabel
                );
                if (trim($fileDocLabel) != '') {
                    $aFields['FILEDOCLABEL'] = $fileDocLabel;
                }
                if (trim($filePdfLabel) != '') {
                    $aFields['FILEPDFLABEL'] = $filePdfLabel;
                }
                if ($aFields['APP_DOC_FILENAME'] != '') {
                    $aFields['TITLE'] = $aFields['APP_DOC_FILENAME'];
                } else {
                    $aFields['TITLE'] = $aFields['APP_DOC_COMMENT'];
                }
                //$aFields['POSITION'] = $_SESSION['STEP_POSITION'];
                $aFields['CONFIRM'] = \G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT');
                if (in_array($aRow['APP_DOC_UID'], $aObjectPermissions['OUTPUT_DOCUMENTS'])) {
                    if (in_array($aRow['APP_DOC_UID'], $aDelete['OUTPUT_DOCUMENTS'])) {
                        $aFields['ID_DELETE'] = \G::LoadTranslation('ID_DELETE');
                    }
                }
                $aOutputDocuments[] = $aFields;
            }
            $oDataset->next();
        }
        global $_DBArray;
        $_DBArray['outputDocuments'] = $aOutputDocuments;
        \G::LoadClass('ArrayPeer');
        $oCriteria = new \Criteria('dbarray');
        $oCriteria->setDBArrayTable('outputDocuments');
        $oCriteria->addDescendingOrderByColumn('CREATE_DATE');
        return $oCriteria;
    }
Exemplo n.º 14
0
function uploadExternalDocument()
{
    $response['action']=$_POST['action']. " - ".$_POST['option'];
    $response['error']="error";
    $response['message']="error";
    $response['success']=false;
    $overwrite = (isset($_REQUEST['overwrite_files'])) ? $_REQUEST['overwrite_files'] : false;
    if (isset($_POST["confirm"]) && $_POST["confirm"] == "true") {
        if (isset($_FILES['uploadedFile'])) {
            $uploadedInstances=count($_FILES['uploadedFile']['name']);
            $sw_error=false;
            $sw_error_exists=isset($_FILES['uploadedFile']['error']);
            $emptyInstances=0;
            $quequeUpload=array();
            //overwrite files
            if ($overwrite) {
                for ($i=0; $i<$uploadedInstances; $i++) {
                    overwriteFile($_REQUEST['dir'], stripslashes($_FILES['uploadedFile']['name'][$i]));
                }
            }
            // upload files & check for errors
            for ($i=0; $i<$uploadedInstances; $i++) {
                $errors[$i] = null;
                $tmp = $_FILES['uploadedFile']['tmp_name'][$i];
                $items[$i] = stripslashes($_FILES['uploadedFile']['name'][$i]);
                if ($sw_error_exists) {
                    $up_err = $_FILES['uploadedFile']['error'][$i];
                } else {
                    $up_err=(file_exists($tmp)?0:4);
                }
                if ($items[$i]=="" || $up_err==4) {
                    $emptyInstances++;
                    continue;
                }
                if ($up_err==1 || $up_err==2) {
                    $errors[$i]='miscfilesize';
                    $sw_error = true;
                    continue;
                }
                if ($up_err==3) {
                    $errors[$i]='miscfilepart';
                    $sw_error=true;
                    continue;
                }
                if (!@is_uploaded_file($tmp)) {
                    $errors[$i]='uploadfile';
                    $sw_error=true;
                    continue;
                }
                //The uplaoded files seems to be correct and ready to be uploaded. Add to the Queque
                $fileInfo=array("tempName"=>$tmp,"fileName"=>$items[$i]);
                $quequeUpload[]=$fileInfo;
            }
        } elseif (isset($_POST['selitems'])) {
            $response="";
            $response['msg']= "correct reload";
            $response['success']=true;
            if (isset($_REQUEST['option']) && isset($_REQUEST['copyMove'])) {
                if ($_REQUEST['option'] == 'directory' && $_REQUEST['copyMove'] == 'all') {
                    $response['action'] = $_POST['action']. " - ".$_POST['option'];
                    $response['error']  = "Complete";
                    $response['message']= str_replace("Execute", "", $_POST['action']). " ". "Complete";
                    $response['success']= 'success';
                    $response['node']   = '';
                    $_POST ['node']     = "";
                    $newFolderUid = checkTree($_REQUEST['dir'], $_REQUEST['new_dir']);
                }
                $_POST['selitems'] = array();
            } else {
                require_once ("classes/model/AppDocument.php");
                $oAppDocument = new AppDocument();
                if (isset($_POST['selitems']) && is_array($_POST['selitems'])) {
                    foreach ($_POST['selitems'] as $docId) {
                        $arrayDocId = explode ('_',$docId);
                        $docInfo=$oAppDocument->load($arrayDocId[0]);
                        $docInfo['FOLDER_UID'] =  $_POST['new_dir'];
                        $docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s');
                        $oAppDocument->update($docInfo);
                    }
                }
            }
        }
        //G::pr($quequeUpload);

        //Read. Instance Document classes
        if (!empty($quequeUpload)) {
            $docUid=$_POST['docUid'];
            $appDocUid=isset($_POST['APP_DOC_UID'])?$_POST['APP_DOC_UID']:"";
            $docVersion=isset($_POST['docVersion'])?$_POST['docVersion']:"";
            $actionType=isset($_POST['actionType'])?$_POST['actionType']:"";
            $folderId=$_POST['dir']==""?"/":$_POST['dir'];
            $appId=$_POST['appId'];
            $docType=isset($_POST['docType'])?$_GET['docType']:"INPUT";
            //save info

            require_once ("classes/model/AppDocument.php");
            require_once ('classes/model/AppFolder.php');
            require_once ('classes/model/InputDocument.php');

            $oInputDocument = new InputDocument();
            if ($docUid != -1) {
                $aID = $oInputDocument->load($docUid);
            } else {
                $oFolder=new AppFolder();
                $folderStructure=$oFolder->getFolderStructure($folderId);
                $aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']);
            }



            //Get the Custom Folder ID (create if necessary)
            $oFolder=new AppFolder();
            if ($docUid!=-1) {
                //krumo("jhl");
                $folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'],$appId);
                //Tags
                $fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'],$appId);
            } else {
                $folderId=$folderId;
                $fileTags="EXTERNAL";
            }
            foreach ($quequeUpload as $key => $fileObj) {
                $oAppDocument = new AppDocument();
                switch ($actionType) {
                    case "R":
                        //replace
                        $aFields = array(
                            'APP_DOC_UID'           => $appDocUid,
                            'APP_UID'               => $appId,
                            'DOC_VERSION'           => $docVersion,
                            'DEL_INDEX'             => 1,
                            'USR_UID'               => $_SESSION['USER_LOGGED'],
                            'DOC_UID'               => $docUid,
                            'APP_DOC_TYPE'          => $docType,
                            'APP_DOC_CREATE_DATE'   => date('Y-m-d H:i:s'),
                            'APP_DOC_COMMENT'       => isset($_POST['form']['APP_DOC_COMMENT']) ?
                                $_POST['form']['APP_DOC_COMMENT'] : '',
                            'APP_DOC_TITLE'         => '',
                            'APP_DOC_FILENAME'      => $fileObj['fileName'],
                            'FOLDER_UID'            => $folderId,
                            'APP_DOC_TAGS'          => $fileTags
                        );
                        $oAppDocument->update($aFields);
                        break;
                    case "NV":
                        //New Version
                        $aFields = array(
                            'APP_DOC_UID'           => $appDocUid,
                            'APP_UID'               => $appId,
                            'DEL_INDEX'             => 1,
                            'USR_UID'               => $_SESSION['USER_LOGGED'],
                            'DOC_UID'               => $docUid,
                            'APP_DOC_TYPE'          => $docType,
                            'APP_DOC_CREATE_DATE'   => date('Y-m-d H:i:s'),
                            'APP_DOC_COMMENT'       => isset($_POST['form']['APP_DOC_COMMENT']) ?
                                $_POST['form']['APP_DOC_COMMENT'] : '',
                            'APP_DOC_TITLE'         => '',
                            'APP_DOC_FILENAME'      => $fileObj['fileName'],
                            'FOLDER_UID'            => $folderId,
                            'APP_DOC_TAGS'          => $fileTags
                        );
                        $oAppDocument->create($aFields);
                        break;
                    default:
                        //New
                        $aFields = array(
                            'APP_UID'               => $appId,
                            'DEL_INDEX'             => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1,
                            'USR_UID'               => $_SESSION['USER_LOGGED'],
                            'DOC_UID'               => $docUid,
                            'APP_DOC_TYPE'          => $docType,
                            'APP_DOC_CREATE_DATE'   => date('Y-m-d H:i:s'),
                            'APP_DOC_COMMENT'       => isset($_POST['form']['APP_DOC_COMMENT']) ?
                                $_POST['form']['APP_DOC_COMMENT'] : '',
                            'APP_DOC_TITLE'         => '',
                            'APP_DOC_FILENAME'      => $fileObj['fileName'],
                            'FOLDER_UID'            => $folderId,
                            'APP_DOC_TAGS'          => $fileTags
                        );
                        $oAppDocument->create($aFields);
                        break;
                }
                $sAppDocUid = $oAppDocument->getAppDocUid();
                $iDocVersion = $oAppDocument->getDocVersion();

                $info = pathinfo($oAppDocument->getAppDocFilename());
                $ext = (isset($info['extension']) ? $info['extension'] : '');
                //save the file
                //if (!empty($_FILES['form'])) {
                //if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
                $sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP;
                $file = G::getPathFromFileUID($appId, $sAppDocUid);
                $sPathName .= $file[0];
                $sFileName = $file[1] . "_" . $iDocVersion . '.' . $ext;

                G::uploadFile($fileObj['tempName'], $sPathName, $sFileName); //upload

                //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
                $oPluginRegistry =& PMPluginRegistry::getSingleton();
                if ($oPluginRegistry->existsTrigger (PM_UPLOAD_DOCUMENT) && class_exists ('uploadDocumentData')) {
                    $oData['APP_UID']   = $appId;
                    $documentData = new uploadDocumentData (
                        $appId,
                        $_SESSION['USER_LOGGED'],
                        $sPathName . $sFileName,
                        $fileObj['fileName'],
                        $sAppDocUid
                    );
                    //$oPluginRegistry->executeTriggers (PM_UPLOAD_DOCUMENT , $documentData);
                    //unlink ($sPathName . $sFileName);
                }
                //end plugin
                if ($sw_error) {
                    // there were errors
                    $err_msg="";
                    for ($i=0; $i<$uploadedInstances; $i++) {
                        if ($errors[$i]==null) {
                            continue;
                        }
                        $err_msg .= $items[$i]." : ".$errors[$i]."\n";
                    }
                    $response['error']=$err_msg;
                    $response['message']=$err_msg;
                    $response['success']=false;
                } elseif ($emptyInstances==$uploadedInstances) {
                    $response['error']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE');
                    $response['message']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE');
                    $response['success']=false;
                } else {
                    $response['error']= G::LoadTranslation('ID_UPLOAD_COMPLETE');
                    $response['message']="Upload complete";
                    $response['success']=true;
                }
            }
        }
    }
    print_r(G::json_encode($response));
    /*
     G::LoadClass ('case');
     $oCase = new Cases ();

     $G_PUBLISH = new Publisher ();
     $Fields ['DOC_UID'] = "-1";

     $Fields ['appId'] = "00000000000000000000000000000000";

     $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields,
     'appFolderSaveDocument?UID=-1&appId=' . $Fields ['appId'] . "&folderId=" . $_POST ['folderID']);
     G::RenderPage ('publish', 'raw');
     */
}
Exemplo n.º 15
0
 $sOptions .= '</tr></table>';
 $oCri = new Criteria();
 $oCri->add(AppDocumentPeer::APP_UID, $_SESSION['APPLICATION']);
 $oCri->add(AppDocumentPeer::DEL_INDEX, $_SESSION['INDEX']);
 $oCri->add(AppDocumentPeer::DOC_UID, $aRow->getStepUidObj());
 $oCri->add(AppDocumentPeer::APP_DOC_TYPE, 'INPUT');
 $oCri->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX);
 $aDocuments = AppDocumentPeer::doSelect($oCri);
 if (sizeof($aDocuments) !== 0) {
     $i = 1;
     $sOptions .= '<table width="90%" align="center" cellpadding="0" cellspacing="0" border="0">';
     reset($aDocuments);
     while ($oDocument = current($aDocuments)) {
         $aRow2 = $oDocument->toArray(BasePeer::TYPE_FIELDNAME);
         $oAux1 = new AppDocument();
         $aAux = $oAux1->load($aRow2['APP_DOC_UID']);
         $sOptions .= '<tr>';
         if ($aAux['APP_DOC_FILENAME'] != '') {
             $sAux = $aAux['APP_DOC_FILENAME'];
         } else {
             $sAux = $aAux['APP_DOC_COMMENT'];
         }
         $sOptions .= '<td width="5%">' . $i . '.</td><td width="55%" class="treeNodeAlternate"><input type="text" readonly="readonly" style="font:inherit;border:none;width:100%;" value="' . htmlentities($sAux, ENT_QUOTES, "utf-8") . '" title="' . $sAux . '" /></td>';
         global $oPluginRegistry;
         if (!$oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
             if (isset($_GET['DOC'])) {
                 $sOptions .= '<td width="20%" class="treeNode" align="center"><a style="' . ($_GET['TYPE'] == 'INPUT_DOCUMENT' && ($_GET['UID'] == $aRow->getStepUidObj() && $_GET['ACTION'] == 'VIEW' && $_GET['DOC'] == $aRow2['APP_DOC_UID']) ? 'background-color:orange;color:s***e;padding-left:5px;padding-right:5px;' : '') . '" href="../cases/cases_Step?TYPE=' . $aRow->getStepTypeObj() . '&UID=' . $aRow->getStepUidObj() . '&POSITION=' . $aRow->getStepPosition() . '&ACTION=VIEW&DOC=' . $aRow2['APP_DOC_UID'] . '&VERSION=' . $aRow2['DOC_VERSION'] . '">' . G::LoadTranslation('ID_VIEW') . '</a></td>';
             } else {
                 $sOptions .= '<td width="20%" class="treeNode" align="center"><a style="" href="../cases/cases_Step?TYPE=' . $aRow->getStepTypeObj() . '&UID=' . $aRow->getStepUidObj() . '&POSITION=' . $aRow->getStepPosition() . '&ACTION=VIEW&DOC=' . $aRow2['APP_DOC_UID'] . '&VERSION=' . $aRow2['DOC_VERSION'] . '">' . G::LoadTranslation('ID_VIEW') . '</a></td>';
             }
             $sOptions .= '<td width="20%" class="treeNode" align="center"><a href="../cases/cases_DeleteDocument?TYPE=INPUT&DOC=' . $aRow2['APP_DOC_UID'] . '" onclick="return confirm(\'' . G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT') . '\');">' . G::LoadTranslation('ID_DELETE') . '</a></td>';
Exemplo n.º 16
0
<?php

$actionAjax = isset($_REQUEST['actionAjax']) ? $_REQUEST['actionAjax'] : null;
if ($actionAjax == "streaming") {
    $app_uid = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
    $inp_doc_uid = isset($_REQUEST['d']) ? $_REQUEST['d'] : null;
    $oAppDocument = new \AppDocument();
    if (!isset($fileData['version'])) {
        $docVersion = $oAppDocument->getLastAppDocVersion($inp_doc_uid);
    } else {
        $docVersion = $fileData['version'];
    }
    $oAppDocument->Fields = $oAppDocument->load($inp_doc_uid, $docVersion);
    $sAppDocUid = $oAppDocument->getAppDocUid();
    $iDocVersion = $oAppDocument->getDocVersion();
    $info = pathinfo($oAppDocument->getAppDocFilename());
    $ext = isset($info['extension']) ? $info['extension'] : '';
    $file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
    $realPath = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
    $realPath1 = PATH_DOCUMENT . G::getPathFromUID($app_uid) . '/' . $file[0] . $file[1] . '.' . $ext;
    if (file_exists($realPath)) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($finfo, $realPath);
        finfo_close($finfo);
        if ($ext == "mp3") {
            $mimeType = "audio/mpeg";
        }
        rangeDownload($realPath, $mimeType);
    } elseif (file_exists($realPath1)) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($finfo, $realPath1);
Exemplo n.º 17
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.
 */
require_once "classes/model/AppDocumentPeer.php";
$oAppDocument = new AppDocument();
if (!isset($_GET['v'])) {
    //Load last version of the document
    $docVersion = $oAppDocument->getLastAppDocVersion($_GET['a']);
} else {
    $docVersion = $_GET['v'];
}
$oAppDocument->Fields = $oAppDocument->load($_GET['a'], $docVersion);
$sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo($oAppDocument->getAppDocFilename());
$ext = $info['extension'];
if (isset($_GET['b'])) {
    if ($_GET['b'] == '0') {
        $bDownload = false;
    } else {
        $bDownload = true;
    }
} else {
    $bDownload = true;
}
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '.' . $ext;
Exemplo n.º 18
0
    /**
     * Create the application document registry
     *
     * @param array $aData
     * @return string
     *
     */
    public function create ($aData)
    {
        $oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
        try {
            $oAppDocument = new AppDocument();

            if (! isset( $aData['APP_DOC_UID'] )) {
                $sUID = G::generateUniqueID();
                $docVersion = 1;
            } else {
                $sUID = $aData['APP_DOC_UID'];
                $docVersion = $this->getLastAppDocVersion( $aData['APP_DOC_UID'], $oAppDocument->getAppUid() );
                $oAppDocument->load( $aData['APP_DOC_UID'], $docVersion );
                switch ($oAppDocument->getAppDocType()) {
                    case "OUTPUT": //Output versioning
                        $o = new OutputDocument();
                        $oOutputDocument = $o->load( $oAppDocument->getDocUid() );

                        if (! $oOutputDocument['OUT_DOC_VERSIONING']) {
                            throw (new Exception( 'The Output document has not versioning enabled!' ));
                        }
                        break;
                    case "INPUT": // Input versioning
                        $o = new InputDocument();
                        $oInputDocument = $o->load( $oAppDocument->getDocUid() );
                        if (! $oInputDocument['INP_DOC_VERSIONING']) {
                            throw (new Exception( 'This Input document does not have the versioning enabled, for this reason this operation cannot be completed' ));
                        }
                        break;
                    default: //Not a valid type
                        throw (new Exception( 'The document is not of a valid Type' ));
                        break;
                }

                $docVersion ++;
            }

            $oAppDocument->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
            $oAppDocument->setDocVersion( $docVersion );

            $oAppDocument->setAppDocUid( $sUID );
            $oAppDocument->setAppDocIndex( $this->getLastIndex( $oAppDocument->getAppUid() ) + 1 );
            if ($oAppDocument->validate()) {
                $oConnection->begin();
                if (isset( $aData['APP_DOC_TITLE'] )) {
                    $oAppDocument->setAppDocTitle( $aData['APP_DOC_TITLE'] );
                }
                if (isset( $aData['APP_DOC_COMMENT'] )) {
                    $oAppDocument->setAppDocComment( $aData['APP_DOC_COMMENT'] );
                }
                if (isset( $aData['APP_DOC_FILENAME'] )) {
                    $oAppDocument->setAppDocFilename( $aData['APP_DOC_FILENAME'] );
                }
                $iResult = $oAppDocument->save();
                $oConnection->commit();
                $this->fromArray( $oAppDocument->toArray( BasePeer::TYPE_FIELDNAME ), BasePeer::TYPE_FIELDNAME );
                return $sUID;
            } else {
                $sMessage = '';
                $aValidationFailures = $oAppDocument->getValidationFailures();
                foreach ($aValidationFailures as $oValidationFailure) {
                    $sMessage .= $oValidationFailure->getMessage() . '<br />';
                }
                throw (new Exception( 'The registry cannot be created!<br />' . $sMessage ));
            }
        } catch (Exception $oError) {
            $oConnection->rollback();
            throw ($oError);
        }
    }
Exemplo n.º 19
0
                 }
                 break;
         }
     }
     $outputNextStep = 'cases_Step?TYPE=OUTPUT_DOCUMENT&UID=' . $_GET['UID'] . '&POSITION=' . $_SESSION['STEP_POSITION'] . '&ACTION=VIEW&DOC=' . $sDocUID;
     G::header('location: ' . $outputNextStep);
     die;
     break;
 case 'VIEW':
     if ($noShowTitle == 0) {
         $G_PUBLISH->AddContent('smarty', 'cases/cases_title', '', '', $array);
     }
     require_once 'classes/model/AppDocument.php';
     $oAppDocument = new AppDocument();
     $lastVersion = $oAppDocument->getLastAppDocVersion($_GET['DOC'], $_SESSION['APPLICATION']);
     $aFields = $oAppDocument->load($_GET['DOC'], $lastVersion);
     $listing = false;
     $oPluginRegistry =& PMPluginRegistry::getSingleton();
     if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) {
         $folderData = new folderData(null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED']);
         $folderData->PMType = "OUTPUT";
         $folderData->returnList = true;
         $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData);
     }
     require_once 'classes/model/OutputDocument.php';
     $oOutputDocument = new OutputDocument();
     $aGields = $oOutputDocument->load($aFields['DOC_UID']);
     if (isset($aGields['OUT_DOC_VERSIONING']) && $aGields['OUT_DOC_VERSIONING'] != 0) {
         $oAppDocument = new AppDocument();
         $lastDocVersion = $oAppDocument->getLastDocVersion($_GET['UID'], $_SESSION['APPLICATION']);
     } else {
 *
 * 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.
 *
 * Created on 13-02-2008
 *
 *
 * @author David Callizaya <*****@*****.**>
 */
require_once "classes/model/AppDocumentPeer.php";
require_once "classes/model/OutputDocumentPeer.php";
$oAppDocument = new AppDocument();
$oAppDocument->Fields = $oAppDocument->load($_GET['a'], isset($_GET['v']) ? $_GET['v'] : null);
$sAppDocUid = $oAppDocument->getAppDocUid();
$sDocUid = $oAppDocument->Fields['DOC_UID'];
$oOutputDocument = new OutputDocument();
$oOutputDocument->Fields = $oOutputDocument->getByUid($sDocUid);
$download = $oOutputDocument->Fields['OUT_DOC_OPEN_TYPE'];
$info = pathinfo($oAppDocument->getAppDocFilename());
if (!isset($_GET['ext'])) {
    $ext = $info['extension'];
} else {
    if ($_GET['ext'] != '') {
        $ext = $_GET['ext'];
    } else {
        $ext = $info['extension'];
    }
}