Exemplo n.º 1
0
    /**
     * Sort documents in Tab or Panel
     * @param $subsectionId
     */
    public static function sortDocumentsInSubsection($subsectionId)
    {
        $subsection = Subsections::model()->with('section')->findByPk($subsectionId);
        $section = $subsection->section;

        if ($section->Folder_Cat_ID == Sections::VENDOR_DOCUMENTS) {
            LibraryDocs::sortDocumentsInVendorFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::PAYROLL) {
            LibraryDocs::sortDocumentsPayrollFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::JOURNAL_ENTRY) {
            LibraryDocs::sortDocumentsJournalEntryFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::PATTY_CASH) {
            LibraryDocs::sortDocumentsPettyCashFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::ACCOUNTS_RECEIVABLE) {
            LibraryDocs::sortDocumentsAccountsReceivableFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::GENERAL) {
            LibraryDocs::sortDocumentsGeneralFolder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::PURCHASE_ORDER_LOG) {
            LibraryDocs::sortDocumentsPosBinder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::CHECK_LOG) {
            LibraryDocs::sortDocumentsPaymentsBinder($subsectionId);
        } else if ($section->Folder_Cat_ID == Sections::W9_BOOK) {
            LibraryDocs::sortDocumentsW9Binder($subsectionId);
        }
    }
Exemplo n.º 2
0
 /**
  * Delete subsection
  * @param $id
  */
 public static function deleteSubsection($id)
 {
     $subsection = Subsections::model()->findByPk($id);
     LibraryDocs::model()->deleteAllByAttributes(array(
         'Subsection_ID' => $subsection->Subsection_ID,
     ));
     $subsection->delete();
 }
Exemplo n.º 3
0
    /**
     * Check user's access to storage
     * @param $id
     * @param $rowType
     * @return bool
     */
    public static function hasAccess($id, $rowType)
    {
        $id = intval($id);
        if ($rowType == 'storage') {
            $condition = new CDbCriteria();
            $condition->condition = "t.Storage_ID = '" . $id . "'";
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("t.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("t.Project_ID = '" . Yii::app()->user->projectID . "'");
            }
            $storage = Storages::model()->find($condition);
            if ($storage) {
                return true;
            }
        } else if ($rowType == 'section') {
            $condition = new CDbCriteria();
            $condition->join = "LEFT JOIN storages ON storages.Storage_ID = t.Storage_ID";
            $condition->condition = "t.Section_ID = '" . $id . "'";
            $condition->addCondition("(storages.Created_By = '" . Yii::app()->user->userID . "' OR storages.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '1')");
            $condition->addCondition("storages.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("storages.Project_ID = '" . Yii::app()->user->projectID . "'");
            }

            $section = Sections::model()->find($condition);

            if ($section) {
                return true;
            }
        } else if ($rowType == 'subsection') {
            $condition = new CDbCriteria();
            $condition->join = "LEFT JOIN sections ON sections.Section_ID = t.Section_ID
                                LEFT JOIN storages ON storages.Storage_ID = sections.Storage_ID";
            $condition->condition = "t.Subsection_ID = '" . $id . "'";
            $condition->addCondition("(storages.Created_By = '" . Yii::app()->user->userID . "' OR storages.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(sections.Created_By = '" . Yii::app()->user->userID . "' OR sections.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("(t.Created_By = '" . Yii::app()->user->userID . "' OR t.Access_Type = '" . self::HAS_ACCESS . "')");
            $condition->addCondition("storages.Client_ID = '" . Yii::app()->user->clientID . "'");
            if (Yii::app()->user->projectID != 'all') {
                $condition->addCondition("storages.Project_ID = '" . Yii::app()->user->projectID . "'");
            }

            $subsection = Subsections::model()->find($condition);

            if ($subsection) {
                return true;
            }
        }

        return false;
    }
Exemplo n.º 4
0
    /**
     * Delete sub section
     * @param $id
     */
    public static function deleteSubsection($section_id,$subsection_id)
    {
        $subsection = Subsections::model()->findByAttributes(array(
            'Subsection_ID' =>$subsection_id
        ));

        if ($subsection) {
                    LibraryDocs::model()->deleteAllByAttributes(array(
                        'Subsection_ID' => $subsection->Subsection_ID,
                    ));

                    $subsection->delete();

        }

        //delete section if it is now have no panels
        $section = Sections::model()->findByPk($section_id);
        if (!count($section->subsections)) {
            $section->delete();
        }
    }