Esempio n. 1
0
    /**
     * 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;
    }
Esempio n. 2
0
    /**
     * 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;
    }