예제 #1
0
파일: Aps.php 프로젝트: ranvijayj/htmlasa
    /**
     * Generate PDF for fake AP using FPDF library without saving to database.
     * @param $poId
     * @param bool $approved
     */
    public static function generatePdfFpdfPreview($ap, $ckRequest, $apDists,$approved = false)
    {
        // get PO formatting
        $poFormatting = PoFormatting::model()->findByAttributes(array(
            'Project_ID' => Yii::app()->user->projectID,
        ));

        // get Sign_Requested_By user info
        $signRequestedByUser = Users::model()->with('person')->findByPk($ckRequest->Sign_Requested_By);

        $aproval_detail_list = Audits::getApprovalDetailList($ap->Document_ID);
        // get current vendor info
        $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($ap->Vendor_ID);

        $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
        $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

        $pdf = new FpdfAp('P','mm','Letter');

        $pdf->AddFont('HelveticaB','','helveticab.php');
        $pdf->AddFont('Courier','','courier.php');
        $pdf->AddFont('CourierB','','courierb.php');
        $pdf->SetAutoPageBreak(true, 10);

        $pdf->setVariables($ap,$poFormatting,$ckRequest,$apDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved);
        $pdf->AliasNbPages();
        $pdf->setPageNo(1);
        //$pdf->AliasNbPages();
        $pdf->AddPage('P');
        $pdf->SetFont('Helvetica','',13.5);
        $pdf->SetXY(5,10);
        $pdf->PrintContent();

        //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
        $fileName = 'ApTempPdf'.date('Y-m-d h:i:s').'.pdf';
        $filepath = Helper::createDirectory('ap');
        $filepath = Helper::createDirectory('ap/'.Yii::app()->user->clientID);
        $filepath.= '/'.$fileName;
        $pdf->Output($filepath, 'F');
        //$pdf->Output();

        $last_page = $pdf->custom_page_num;
        $pdf->Close();


        return array(
            'filename'=>$fileName,
            'filepath'=>$filepath
        );
    }
예제 #2
0
    /**
     * Generate or regenerate PDF for AP using FPDF library
     * @param $apId
     * @param bool $approved
     */
    public static function generatePdfFpdf($doc_id, $doc_type, $approved = false)
    {


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

            $ckRequest = $ap->ck_req_detail;

            // get PO dists
            $apDists = $ap->dists;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $ap->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($ckRequest->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($ap->Document_ID);
            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($ap->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $pdf = new FpdfAp('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($ap,$poFormatting,$ckRequest,$apDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'ApTempPdf'.date('Y-m-d h:i:s').'.pdf';
            $filepath = Helper::createDirectory('ap');
            $filepath = Helper::createDirectory('ap/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;



            $pdf->Close();
        }
        if (( $doc_type == 'PO' )) {

            $po = Pos::model()->findByAttributes(
                array('Document_ID' => $doc_id)
            );

            // get PO dists
            $poDists = $po->dists;

            // get PO details
            $poDecrDetails = $po->decr_details;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $po->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($po->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($po->Document_ID);

            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($po->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $paymentTypes = array(
                'OA' => 'On Account',
                'CC' => 'Credit Card',
                'DP' => 'Deposit',
                'CK' => 'Payment Check',
                'PC' => 'Petty Cash',
            );


            $pdf = new FpdfPo('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($po,$poFormatting,$poDecrDetails,$poDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved,$paymentTypes);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'TempFile.pdf';
            $filepath = Helper::createDirectory('po');
            $filepath = Helper::createDirectory('po/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;
            $pdf->Close();
        }


        return array(
          'path' => $filepath,
          'pages'=> $last_page
        );
    }