Exemplo n.º 1
0
    /**
     * Approve AP
     * @param $docId
     * @param $userApprovalRange
     */
    public static function HardApApprove($docId, $userApprovalRange)
    {
        //check document
        $document = Documents::model()->with('client')->findByAttributes(array(
            'Client_ID' => Yii::app()->user->clientID,
            'Document_ID' => $docId,
        ));

        if ($document) {
            //get AP
            $ap = Aps::model()->with('ck_req_detail')->findByAttributes(array(
                'Document_ID' => $docId,
            ));

            if ($ap) {
                if ($ap->AP_Approval_Value < $userApprovalRange['user_appr_val']) {
                    // set AP_Approval_Value and save
                    $ap->Previous_AP_A_Val = $ap->AP_Approval_Value;
                    $ap->AP_Approval_Value = $userApprovalRange['user_appr_val'];

                    if ($userApprovalRange['user_appr_val'] == self::APPROVED) {
                        $ap->Approved = 1;
                        LibraryDocs::addDocumentToFolder($ap->Document_ID);
                    }

                    $ap->save();
                    Audits::LogAction($docId,Audits::ACTION_APPROVAL);

                    // regenerate pdf
                    if ($document->Origin == 'G') {
                        //Aps::generatePdfFpdf($ap->AP_ID, ($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Documents::pdfGeneration($ap->Document_ID,'AP',($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Audits::LogAction($ap->Document_ID,Audits::ACTION_REPDF);
                    }



                }

                // find and unset doc from session
                Helper::removeDocumentFromViewSession($docId, 'ap_to_review');
                Helper::removeDocumentFromViewSession($docId, 'ap_hard_approve');
            }
        }
    }
Exemplo n.º 2
0
    /**
     * Approve PO jumping over the queue
     * @param $docId
     * @param $userApprovalRange
     */
    public static function HardPOApprove($docId, $userApprovalRange)
    {
        //check document
        $document = Documents::model()->with('client')->findByAttributes(array(
            'Client_ID' => Yii::app()->user->clientID,
            'Document_ID' => $docId,
        ));

        if ($document) {
            //get AP
            $po = Pos::model()->with('dists', 'document')->findByAttributes(array(
                'Document_ID' => $docId,
            ));

            if ($po) {
                if ($po->PO_Approval_Value < $userApprovalRange['user_appr_val']) {
                    // set PO_Approval_Value and save
                    $po->PO_Previous_PO_Val = $po->PO_Approval_Value;
                    $po->PO_Approval_Value = $userApprovalRange['user_appr_val'];

                    if ($userApprovalRange['user_appr_val'] == Pos::APPROVED) {
                        $po->PO_Approved = 1;

                        LibraryDocs::addDocumentToFolder($po->Document_ID);
                        LibraryDocs::addDocumentToBinder($po->Document_ID);
                    }

                    $po->save();

                    Audits::LogAction($docId,Audits::ACTION_APPROVAL);

                    // regenerate pdf
                    if ($document->Origin == 'G') {
                        Documents::pdfGeneration($po->Document_ID,'PO',($userApprovalRange['user_appr_val'] == Pos::APPROVED));
                        Audits::LogAction($po->Document_ID,Audits::ACTION_REPDF);
                    }

                    if ($userApprovalRange['user_appr_val'] == Pos::APPROVED) {
                        $po->updateCoaCurrentBudget();
                    }
                }

                // find and unset doc from session
                Helper::removeDocumentFromViewSession($docId, 'po_to_review');
                Helper::removeDocumentFromViewSession($docId, 'po_hard_approve');
            }
        }
    }