コード例 #1
0
ファイル: LibraryDocs.php プロジェクト: ranvijayj/htmlasa
    /**
     * Add document to binder
     * @param $docId
     */
    public static function addDocumentToBinder($docId)
    {
        $document = Documents::model()->findByPk($docId);
        if ($document) {
            $year = substr($document->Created, 0, 4);
            Storages::createProjectStorages($document->Project_ID, $year);
            $subsectionId = 0;
            if ($document->Document_Type == Documents::PM) {
                $payment = Payments::model()->findByAttributes(array(
                    'Document_ID' => $docId,
                ));
                $year = substr($payment->Payment_Check_Date, 0, 4);
                $subsectionId = Sections::createLogBinder($document->Project_ID, $document->Document_Type, $year);
            } elseif ($document->Document_Type == Documents::PO) {
                $po = Pos::model()->findByAttributes(array(
                    'Document_ID' => $docId,
                ));
                $year = substr($po->PO_Date, 0, 4);
                $subsectionId = Sections::createLogBinder($document->Project_ID, $document->Document_Type, $year);
                if ($po->PO_Backup_Document_ID != 0) {
                    $bu = LibraryDocs::model()->findByAttributes(array(
                        'Document_ID' => $po->PO_Backup_Document_ID,
                        'Subsection_ID' => $subsectionId,
                    ));
                    if (!$bu) {
                        $libDoc = new LibraryDocs();
                        $libDoc->Document_ID = $po->PO_Backup_Document_ID;
                        $libDoc->Subsection_ID = $subsectionId;
                        $libDoc->Access_Type = Storages::HAS_ACCESS;
                        $libDoc->Sort_Numb = 0;
                        if ($libDoc->validate()) {
                            $libDoc->save();
                        }
                    }
                }
            }

            $libDoc = LibraryDocs::model()->findByAttributes(array(
                'Document_ID' => $docId,
                'Subsection_ID' => $subsectionId,
            ));

            if (!$libDoc) {
                $libDoc = new LibraryDocs();
                $libDoc->Document_ID = $docId;
                $libDoc->Subsection_ID = $subsectionId;
                $libDoc->Access_Type = Storages::HAS_ACCESS;
                $libDoc->Sort_Numb = 0;
                if ($libDoc->validate()) {
                    $libDoc->save();
                }
            }

            LibraryDocs::sortDocumentsInSubsection($subsectionId);
        }
    }
コード例 #2
0
 case "check_files":
     $stage = $_REQUEST['stage'];
     $relocation = $_REQUEST['relocation'];
     $hide = $_REQUEST['hide'];
     switch ($stage) {
         case "reset":
             $directories = array_unique(array_merge($config['rootdir'], isset($config['storages']) ? $config['storages'] : array(), isset($config['source']) ? $config['source'] : array()));
             $_SESSION['check_files'] = array('directories' => $directories, 'files' => array(), 'files_index' => array(), 'name_index' => array(), 'size_index' => array());
             $_RESULT["status_text"] = 'Подготовка';
             $_RESULT["nextstage"] = 'indexing';
             break;
         case "indexing":
             $t1 = time() + microtime();
             $checkFiles = $_SESSION['check_files'];
             require_once dirname(__FILE__) . "/classes/storages.php";
             $storages = new Storages();
             if (isset($config["dir_extensions"])) {
                 $storages->set_dir_extensions($config["dir_extensions"]);
             }
             while ($directory = array_shift($checkFiles['directories'])) {
                 $newFiles = $storages->directory_list($directory);
                 foreach ($newFiles as $file) {
                     if ($file['isdir']) {
                         if (preg_match('{^ftp://}', $file['path']) || is_readable($file['path_dec'])) {
                             $checkFiles['directories'][] = $file['path'];
                         }
                     } else {
                         $key = md5($file['name'] . ':' . $file['size']);
                         $checkFiles['files'][$key] = $file;
                         $checkFiles['files_index'][$file['path']] = true;
                         $checkFiles['name_index'][$file['name']][] = $key;
コード例 #3
0
ファイル: Storages.php プロジェクト: ranvijayj/htmlasa
    /**
     * Get years list
     * @param $clientID
     * @param $projectID
     * @return CActiveRecord[]
     */
    public static function getYearsList($clientID, $projectID)
    {
        // create condition
        $condition = new CDbCriteria();
        $condition->select = 'distinct Year';
        $condition->condition = "(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '" . self::HAS_ACCESS . "')";
        $condition->addCondition("t.Client_ID = '" . $clientID . "'");
        if ($projectID != 'all') {
            $condition->addCondition("t.Project_ID = '" . $projectID . "'");
        }
        $condition->order = "t.Year DESC";

        // get storages
        $years = Storages::model()->findAll($condition);
        return $years;
    }
コード例 #4
0
ファイル: Sections.php プロジェクト: ranvijayj/htmlasa
    /**
     * Get Shelf for folder Create
     * @param $projectID
     * @param $year
     * @return CActiveRecord
     */
    public static function getShelfForBinderCreate($projectID, $year)
    {
        // get shelf
        $shelf = Storages::model()->findByAttributes(array(
            'Storage_Type' => Storages::SHELF,
            'Created_By' => '0',
            'Project_ID' => $projectID,
            'Year' => $year,
        ));

        if (!$shelf) {
            Storages::createProjectStorages($projectID, $year);

            // get shelf
            $shelf = Storages::model()->findByAttributes(array(
                'Storage_Type' => Storages::SHELF,
                'Created_By' => '0',
                'Project_ID' => $projectID,
                'Year' => $year,
            ));
        }

        return $shelf;
    }