Пример #1
0
    /**
     * Prepare subsections with documents to review
     * @param $subsections
     * @param $section
     * @param $year
     * @return array
     */
    public static function prepareSubsectionsToView($subsections, $section, $year)
    {
        $result = array();
        foreach ($subsections as $subsection) {
            if ($section->folder_type->Folder_Cat_ID == Sections::PURCHASE_ORDER_LOG && isset($_SESSION['sort_po_by_vendor_name'])) {
                $documents = LibraryDocs::sortDocumentsPosBinder($subsection->Subsection_ID, 'alpha', true);
            } else {
                $condition = new CDbCriteria();
                $condition->condition = 't.Access_Type = ' . Storages::HAS_ACCESS;
                $condition->addCondition("document.User_ID = '" . Yii::app()->user->userID . "'", 'OR');
                $condition->addCondition("t.Subsection_ID = '" . $subsection->Subsection_ID . "'");

                if (Yii::app()->user->id == 'user') {
                    $condition->addCondition("document.User_ID= '" . Yii::app()->user->userID . "'");
                }

                $condition->order = "t.Sort_Numb ASC";

                $documents = LibraryDocs::model()->with('document')->findAll($condition);
            }
            $documents = LibraryDocs::prepareDocumentsOfSubsectionToView($documents, $section->Vendor_ID, $section->Folder_Cat_ID, $year);

            $result[] = array(
                'subsection' => $subsection,
                'documents' => $documents,
            );
        }

        return $result;
    }
Пример #2
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);
        }
    }