/***********************************************

Sintak di form
Nama file biasanya index.phtml
<?php echo $this->render('header.phtml'); ?> Selengkapnya...

Nama file CobaModel.php
<?php
class SaveModel extends Zend_Db_Table {
var $dbcon;
function __construct(){
$this->dbcon = Zend_Registry::get('db1');
}
function get(){
$qry=$this->dbcon->query("select max(biodata_id) as maxId from `biodata` where biodata_id like 'B-%'");
$nil=$qry->fetchObject();
return $nil;
}
}
Selengkapnya...

Sintak di controller
Nama file biasanya ClientController.php
<?php

class ClientController extends Zend_Controller_Action
{
public function init(){
$this->initView();
$this->view->baseUrl=$this->_request->getBaseUrl();
}

Public function index(){
$form = new Application_Form_ClientForm();
$this->view->assign("content_panel",$form);

$ClientModel = new ClientModel();
$upload=new Zend_File_Transfer();
$files=$upload->getFileInfo();
foreach ($files as $file=>$info){
$upload=new Zend_File_Transfer_Adapter_Http();
$upload->setDestination('../public/foto');
$upload->addValidator('Extension',true,'jpg,png,jpeg');
$upload->addValidator('Size',true,array(
'max' => '500KB',
'bytestring' => false
));
//print_r($info);
if($upload->receive($file)){
if($ClientModel->addPhoto($_REQUEST,$info['name'])){
$_SESSION["msg"]="Add new Client success.";
if($_REQUEST["email"]=="true"){
$email=$_REQUEST["client_contactEmail"];
$pass=$_REQUEST["client_contactPassword"];
$this->dapatemail($email,$pass);
}
$this->_redirect("/client");
} else {
$_SESSION["msg"]="Add new Client fail.<br/>Client already exist or invalid input.";
$this->_redirect("/client/add/");
}
}
}
}

Selengkapnya...

Untuk configurasi dom pdf di zend,anda dapat menggunkan code sebagai berikut :
function printAction(){
$tmps=explode("/",$_SERVER['REQUEST_URI']);
$idView=$tmps[5];
$data=new SaveModel();
$dataAll=$data->getAll($idView);
$cat=$this->note($dataAll->tgl,$dataAll->biodata_nama);
$this->view->assign('data',$dataAll);
$this->view->assign('cat',$cat);
//echo $idView;
/* $invoicePrint="<div style='color:#F00;'>ini merah</div>";
$dompdf = new DOMPDF();
$dompdf->load_html($invoicePrint);
$dompdf->render();
$dompdf->stream("sample.pdf"); */
$html = $this->view->render("PDFLayout.phtml");
$dompdf = new DOMPDF();
$dompdf->set_paper("a4","portrait");
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("Biodata_".$dataAll->biodata_nama.".pdf");
//$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}

File di print.phtml
<style>
body {
margin: 65pt 28pt 40pt 28pt;
font-size: 1em;
}
</style>
<body>
<script type="text/php">

if ( isset($pdf) ) {

$font = Font_Metrics::get_font("verdana");;
$size = 6;
$color = array(0,0,0);
$text_height = Font_Metrics::get_font_height($font, $size);

$foot = $pdf->open_object();

$w = $pdf->get_width();
$h = $pdf->get_height();

// Draw a line along the bottom
$y = $h - $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 0.5);

$pdf->close_object();
$pdf->add_object($foot, "all");

$header = $pdf->open_object();
$pdf->image("../public/Logo.png",'png',200,10, 200,50);
$pdf->close_object();
$pdf->add_object($header, "all");

$text = "Page {PAGE_NUM} of {PAGE_COUNT}";

// Center the text
$width = Font_Metrics::get_text_width("Page 1 of 2", $font, $size);
$pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);

}
</script>


Selengkapnya...

sintak untuk bootstrap.php di zend framework versi saya adalah sebagai berikut :



<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}

public function _initRegistry(){
// //$this->bootstrap("multidb.db1");
// $db1=$this->getResource("multidb.db1");
// $db2=$this->getResource("multidb.db2");
// Zend_Registry::set("db",$db1);
// Zend_Registry::set("db2",$db2);
}

public function _initDatabase(){
$resource = $this->getPluginResource('multidb');
$resource->init();

Zend_Registry::set('db1', $resource->getDb('db1'));
Zend_Registry::set('db2', $resource->getDb('db2'));
}

}


Selengkapnya...