Example #1
0
    /**
     * Generates from array of dists  array of dist's models. Used for generating PO document without saving metadata to database.
     * @param $poId
     * @param $distsToSave
     */
    public static function preparePODistsArray($poId, $distsToSave)
    {
        $resultArray = array();
        $coaStructure = Coa::getProjectCoaStructure(Yii::app()->user->projectID);

        foreach ($distsToSave as $distToSave) {

            $distToSave['PO_Dists_Description']= substr($distToSave['PO_Dists_Description'],0,125);

            $newDist = new PoDists();
            $newDist->PO_ID = $poId;

            if ($distToSave['PO_Dists_GL_Code'] == '') {
                $newDist->PO_Dists_GL_Code = null;
            } else {


                    //full functionality not available from ver 13210
                    $newDist->Short_Hand = $distToSave['PO_Dists_GL_Code'];
                    $constructed_value = Coa::constructCoaNumber(Yii::app()->user->projectID, $distToSave['PO_Dists_GL_Code']);
                    $newDist->PO_Dists_GL_Code =$constructed_value;
                    $coa=Coa::model()->findByAttributes(array('COA_Acct_Number'=>$newDist->PO_Dists_GL_Code));
                    if ($coa) {$coa->COA_Used = 1;}

            }

            if ($distToSave['PO_Dists_Description'] == '') {
                $newDist->PO_Dists_Description = '-';
            } else {
                $newDist->PO_Dists_Description = $distToSave['PO_Dists_Description'];
            }

            if ($distToSave['PO_Dists_Amount'] == '') {
                $newDist->PO_Dists_Amount = 0;
            } else {
                $newDist->PO_Dists_Amount = $distToSave['PO_Dists_Amount'];
            }

            array_push($resultArray,$newDist);

        }
        return $resultArray;
    }
Example #2
0
    /**
     * Prepare AP Dists Models
     * @param $apId
     * @param $distsToSave
     */
    public static function prepareAPDistsModelsArray($apId, $distsToSave)
    {

        $result = array();

        $coaStructure = Coa::getProjectCoaStructure(Yii::app()->user->projectID);

        foreach ($distsToSave as $distToSave) {
            $newDist = new GlDistDetails();
            $newDist->AP_ID = $apId;

            if ($distToSave['GL_Dist_Detail_COA_Acct_Number'] == '') {
                $newDist->GL_Dist_Detail_COA_Acct_Number = null;
            } else {


                    //full functionality not available from ver 13210
                    $newDist->Short_Hand = $distToSave['GL_Dist_Detail_COA_Acct_Number'];

                    $constructed_value = Coa::constructCoaNumber(Yii::app()->user->projectID, $distToSave['GL_Dist_Detail_COA_Acct_Number']);
                    //$newDist->GL_Dist_Detail_COA_Acct_Number =$distToSave['GL_Dist_Detail_COA_Acct_Number'];
                    $newDist->GL_Dist_Detail_COA_Acct_Number =$constructed_value;
                    $coa=Coa::model()->findByAttributes(array('COA_Acct_Number'=>$newDist->GL_Dist_Detail_COA_Acct_Number));
                    if ($coa) {$coa->COA_Used = 1;}


            }

            if ($distToSave['GL_Dist_Detail_Desc'] == '') {
                $newDist->GL_Dist_Detail_Desc = '-';
            } else {
                $newDist->GL_Dist_Detail_Desc = $distToSave['GL_Dist_Detail_Desc'];
            }

            if ($distToSave['GL_Dist_Detail_Amt'] == '') {
                $newDist->GL_Dist_Detail_Amt = 0;
            } else {
                $newDist->GL_Dist_Detail_Amt = $distToSave['GL_Dist_Detail_Amt'];
            }

            array_push($result,$newDist);

        }

        return $result;
    }
Example #3
0
    public static function checkCoaNumber($projectID, $userInput){

        if (strlen($userInput)<=63 || strlen(Coa::constructCoaNumber($projectID, $userInput)<=63) ) {
            return true;
        } else {return false;}

    }