Ejemplo n.º 1
0
    public static function getPODists($poId)
    {
        $dists= PoDists::model()->findAllByAttributes(array(
            'PO_ID' => $poId,
        ));
        $i=0;
        if($dists){
            foreach ($dists as $dist) {

                $return_array[$i]['PO_Dists_GL_Code']=$dist->PO_Dists_GL_Code;
                $return_array[$i]['Short_Hand']=$dist->Short_Hand;
                $return_array[$i]['PO_Dists_Amount']=$dist->PO_Dists_Amount;
                $return_array[$i]['PO_Dists_Description']=$dist->PO_Dists_Description;

                $i++;

            }

            for($i = count($return_array); $i < 4; $i++) {
                $return_array[$i] = array(
                    'PO_Dists_GL_Code' => '',
                    'Short_Hand'=>'',
                    'PO_Dists_Amount' => '',
                    'PO_Dists_Description' => '',
                );

            }

        $empty=false;
        } else {
            for($i = 1; $i <= 4; $i++) {
                $return_array[$i] = array(
                    'PO_Dists_GL_Code' => '',
                    'Short_Hand'=>'',
                    'PO_Dists_Amount' => '',
                    'PO_Dists_Description' => '',
                );

            }
        $empty=true;
        }
        return array('empty'=>$empty,'dists'=>$return_array);
    }
Ejemplo n.º 2
0
    /**
     * Delete PO with rows in relative tables
     * @param $poId
     */
    public static function deletePO($poId)
    {
        $po = Pos::model()->with('document.image')->findByPk($poId);
        if ($po) {
            $document = $po->document;
            $image = $document->image;
            $image->delete();
            $document->delete();

            PoDists::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            PoDescDetail::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            PoPmtsTraking::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $po->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($po->Document_ID);

            $po->delete();
        }
    }