public function report($id)
 {
     $dataObj = $this->FacsimileMassage->findById($id);
     if ($dataObj) {
         $this->checkCanDo($dataObj);
         $this->layout = 'blank';
         App::uses('PdfLib', 'Lib');
         $marginWidth = 50;
         $pdf = new PdfLib(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->SetMargins(0, 0, 0, true);
         $pdf->SetFont('freeserif', '', 10, '', false);
         $logoHeaderPath = WWW_ROOT . 'img/document_header_logo.png';
         $headerHtml = '<label style="text-align:center"><img src="' . $logoHeaderPath . '" /></label><br>';
         $pdf->SetHeaderData($logoHeaderPath, 200, 'custom', $headerHtml);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->setFooterMargin($marginWidth);
         $pdf->Cell(0, 1, '', 0, 1, 'C');
         $pdf->AddPage('P');
         $pageTitle = "BẢNG CHÀO GIÁ BAO BÌ";
         $titleHtml = '<label style="font-size:15px; text-align:center"><u>' . $pageTitle . '</u></label><br>';
         $pdf->setY(40);
         $pdf->writeHTML($titleHtml, true, false, false, false, '');
         $totalPage = $pdf->getAliasNbPages();
         $view = new View($this);
         $view->set('data', $dataObj);
         $view->set('totalPage', $totalPage);
         $productItems = $this->FacsimileMassageProduct->find('all', array('conditions' => array('facsimile_massage_id' => $id)));
         $view->set('productItems', $productItems);
         $html = $view->render('report_pdf');
         //echo $html; die();
         $pdf->setX(30);
         $pdf->writeHTML($html, true, false, false, false, '');
         $date = reformatDate($dataObj['FacsimileMassage']['created_time'], '\\N\\g\\à\\y d \\t\\h\\á\\n\\g m \\n\\ă\\m Y');
         $pdf->setX(150);
         $pdf->MultiCell(225, 101, $date, 0, 'J', 0, 1, '', '', true, null, true);
         $exportFileName = 'pdf_report_' . date('Y_m_d_H_i_s') . '.pdf';
         $tmpFile = WWW_ROOT . 'files/uploads/tmp/' . $exportFileName;
         $pdf->Output($tmpFile, 'I');
     }
 }
Beispiel #2
1
 public function report($id)
 {
     $dataObj = $this->WorksSheet->findById($id);
     if ($dataObj) {
         $this->checkCanDo($dataObj);
         $costingProduct = $this->Costing->find("first", array('conditions' => array('Costing.product_id' => $dataObj['Product']['id'])));
         if ($costingProduct) {
             $productPO = $this->PurchaseOrder->find('first', array('joins' => array(array('table' => $this->PurchaseOrderProduct->useTable, 'alias' => 'PurchaseOrderProduct', 'type' => 'INNER', 'conditions' => array('PurchaseOrder.id = PurchaseOrderProduct.purchase_order_id', 'PurchaseOrderProduct.deleted_time IS NULL')), array('table' => $this->Product->useTable, 'alias' => 'Product', 'type' => 'INNER', 'conditions' => array('Product.id = PurchaseOrderProduct.product_id', 'Product.deleted_time IS NULL'))), 'conditions' => array('PurchaseOrder.customer_id' => $dataObj['WorksSheet']['customer_id'], 'PurchaseOrderProduct.product_id' => $dataObj['WorksSheet']['product_id']), 'fields' => array('PurchaseOrder.*')));
             $listUnit = Hash::combine($this->ProductUnit->find('all'), '{n}.ProductUnit.id', '{n}.ProductUnit');
             $this->layout = 'blank';
             App::uses('PdfLib', 'Lib');
             $marginWidth = 50;
             $pdf = new PdfLib(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
             $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
             $pdf->SetMargins(0, 0, 0, true);
             $pdf->SetFont('freeserif', '', 10, '', false);
             $logoHeaderPath = WWW_ROOT . 'img/document_header_logo.png';
             $headerHtml = '<label style="text-align:center"><img src="' . $logoHeaderPath . '" /></label><br>';
             $pdf->SetHeaderData($logoHeaderPath, 200, 'custom', $headerHtml);
             $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
             $pdf->setFooterMargin($marginWidth);
             $pdf->AddPage('P');
             $pageTitle = "PHIẾU BÁO SẢN XUẤT";
             $titleHtml = '<label style="font-size:15px; text-align:center"><u>' . $pageTitle . '</u></label><br>';
             $pdf->setY(40);
             $pdf->writeHTML($titleHtml, true, false, false, false, '');
             $view = new View($this);
             $view->set('data', $dataObj);
             $view->set('listUnit', $listUnit);
             $orderProgress = $this->WorksSheetProgress->find('all', array('conditions' => array('product_order_id' => $id), 'order' => array('order asc')));
             $view->set('orderProgress', $orderProgress);
             $view->set('productPO', $productPO);
             //---------------------
             $cutting = $costingProduct['Costing']['paper_cutting'];
             $numProduc = $costingProduct['Costing']['quantity'];
             $haoPhi = $numProduc / $cutting / 50;
             $reportNum = $numProduc / $cutting + $haoPhi;
             $view->set('reportNum', $reportNum);
             $view->set('haoPhi', $haoPhi);
             $view->set('costingProduct', $costingProduct);
             $paperName = Configure::read("PAPER_NAME");
             $view->set('paperName', $paperName);
             //--------------------
             $html = $view->render('report_pdf');
             //$pdf->setY(40);
             $pdf->setX(30);
             $pdf->writeHTML($html, true, false, false, false, '');
             $pdf->setX(31);
             $note = trim($dataObj['WorksSheet']['special_note']);
             $strText = str_replace("\n", "<br>", $note);
             $pdf->MultiCell(205, 10, $strText, 0, 'J', 0, 1, '', '', true, null, true);
             $date = reformatDate($dataObj['WorksSheet']['created_time'], '\\N\\g\\à\\y d \\t\\h\\á\\n\\g m \\n\\ă\\m Y');
             $pdf->setX(130);
             $pdf->MultiCell(205, 10, $date, 0, 'J', 0, 1, '', '', true, null, true);
             //$pdf->Write(0, $date);
             $pdf->setX(31);
             $htmlFooter = '<table>';
             $htmlFooter .= '<tr>';
             $htmlFooter .= '<td width="50%">Người lập phiếu</td>';
             $htmlFooter .= '<td width="50%">Người duyệt</td>';
             $htmlFooter .= '</tr>';
             /*$htmlFooter .= '<tr><td></td></tr>';
               $htmlFooter .= '<tr><td></td></tr>';
               $htmlFooter .= '<tr><td></td></tr>';
               $htmlFooter .= '<tr><td></td></tr>';
               $htmlFooter .= '<tr>';
               $htmlFooter .= '<td width="50%">'.$dataObj['User']['display_name'].'</td>';
               $htmlFooter .= '<td width="50%"></td>';
               $htmlFooter .= '</tr>';*/
             $htmlFooter .= '</table>';
             $pdf->MultiCell(205, 35, $htmlFooter, 0, 'J', 0, 1, '', '', true, null, true);
             //$text2 = "<b>".$dataObj['CreatedUser']['display_name']."<b>".$tabSpace.$dataObj['ApprovedUser']['display_name'];
             //$pdf->setX(31);
             //$pdf->MultiCell(205, 5,$text2, 0, 'J', 0, 1, '', '', true, null, true);
             $exportFileName = 'pdf_report_' . date('Y_m_d_H_i_s') . '.pdf';
             $tmpFile = WWW_ROOT . 'files/uploads/tmp/' . $exportFileName;
             header("Content-type: application/pdf");
             $pdf->Output($tmpFile, 'I');
         } else {
         }
     }
 }
Beispiel #3
0
function addDate($date = '', $diff = '', $format = "d/m/Y")
{
    if (empty($date) || empty($diff)) {
        return false;
    }
    $formatedDate = reformatDate($date, $format, $to_format = 'Y-m-d H:i:s');
    $newdate = strtotime($diff, strtotime($formatedDate));
    return date($format, $newdate);
}
Beispiel #4
0
function createEventDetails($id, $definition){
	$data = rmatch('%<th.*?>(.*?)</th>.*?Activit&eacute; propos&eacute;e par (.+?)</td>.*?mailto:(.+?)".*?<b>(.*?)</b>.*?<b>(.*?)</b>.*?<td>(.*?)</td>.*?<th>Les inscrits.*?</tr>(.*?)<form%', $definition);
	
	$participants = array();
	$participantMatches = array();
	
	if (preg_match_all('%<td>(\d+?) - (<a href="mailto:(.+?)">)?(.+?)(</a>)?( - .*?)?</td>%', $data[7], $participantMatches))
		for ($i=0; $i<count($participantMatches[0]); $i++)
			array_push($participants, createParticipant($participantMatches[1][$i], $participantMatches[4][$i], $participantMatches[3][$i]));
	
	return array(
		'id' => intval($id),
		'title' => decodeEntities($data[4]),
		'date' => reformatDate($data[1]),
		'author' => decodeEntities($data[2]),
		'authorEmail' => $data[3],
		'description' => decodeEntities($data[6]),
		'participants' => $participants,
		'maxParticipants' => parseMaxCount($data[5])
	);
}
Beispiel #5
0
function convertYMDtoLocal($in_time, $from_format, $to_format)
{
    $from_format = get_locale_date_format($from_format);
    $to_format = get_locale_date_format($to_format);
    if (!class_exists("DateTime", false) || !method_exists("DateTime", "createFromFormat")) {
        //handle_error("This version of PHP does not have the DateTime class. Must be PHP >= 5.3 to use date criteria");
        //return false;
        $retval = reformatDate($from_format, $to_format, $in_time);
        return $retval;
    }
    try {
        $datetime = DateTime::createFromFormat($from_format, $in_time);
        if (!$datetime) {
            handle_error("Date value '{$in_time}' is expected in date format {$from_format}");
            return false;
        }
        $retval = $datetime->format($to_format);
    } catch (Exception $e) {
        handle_error("Error in date formatting<BR>" . $e->getMessage());
        return "";
    }
    return $retval;
}
Beispiel #6
0
        $avatar = $currentitem['user']['profile_image_url'];
        $rt = '';
        $tweeter = $currentitem['user']['screen_name'];
        $fullname = $currentitem['user']['name'];
        $tweetTitle = $currentitem['text'];
    }
    ?>
                <title>[<?php 
    echo $tweeter;
    ?>
] <?php 
    echo $tweetTitle;
    ?>
 </title>
                <pubDate><?php 
    echo reformatDate($currentitem['created_at']);
    ?>
</pubDate>
                <link>https://twitter.com/<?php 
    echo $tweeter;
    ?>
/statuses/<?php 
    echo $currentitem['id_str'];
    ?>
</link>
                <guid isPermaLink='false'><?php 
    echo $currentitem['id_str'];
    ?>
</guid>

                <description>