public function createForm($id_hopdong)
 {
     $kh = new Model_Hopdong();
     $hopdong = $kh->getWhereIdHopDong($id_hopdong);
     $this->setDisableLoadDefaultDecorators(true);
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'formnoindex/hopdong_layout.phtml')), 'Form'));
     $data = new My_Data();
     $opMau = $data->getOptionMau();
     $opLoaiVai = $data->getOptionLoaiVai();
     $opNCC = $data->getOptionNCC();
     $tenhopdong = $this->createElement('text', 'tenhopdong', array('decorators' => array('ViewHelper')));
     $mota = $this->createElement('text', 'mota', array('decorators' => array('ViewHelper')));
     $ngayky = $this->createElement('text', 'ngayky', array('decorators' => array('ViewHelper')));
     $sotansoi = $this->createElement('text', 'sotansoi', array('decorators' => array('ViewHelper')));
     $thanhtien = $this->createElement('text', 'thanhtien', array('decorators' => array('ViewHelper')));
     $mamau = $this->createElement('select', 'mamau', array('multioptions' => $opMau, 'decorators' => array('ViewHelper')));
     $maloaivai = $this->createElement('select', 'maloaivai', array('multioptions' => $opLoaiVai, 'decorators' => array('ViewHelper')));
     $manhacungcap = $this->createElement('select', 'manhacungcap', array('multioptions' => $opNCC, 'decorators' => array('ViewHelper')));
     $them = $this->createElement('submit', 'them', array('decorators' => array('ViewHelper'), 'label' => 'Chỉnh sửa'));
     $mydate = Zend_Locale_Format::getDate($hopdong['NgayKy'], array("date_format" => "yyyy.MM.dd"));
     $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year'];
     $tenhopdong->setAttrib('class', 'formEdit')->setValue($hopdong['TenHopDong']);
     $mota->setAttrib('class', 'formEdit')->setValue($hopdong['MoTa']);
     $ngayky->setAttrib('class', 'formEdit')->setValue($date_str);
     $sotansoi->setAttrib('class', 'formEdit')->setValue($hopdong['SoTanSoi']);
     $thanhtien->setAttrib('class', 'formEdit')->setValue($hopdong['ThanhTien']);
     $mamau->setAttrib('class', 'formEdit')->setValue($hopdong['MaMau']);
     $maloaivai->setAttrib('class', 'formEdit')->setValue($hopdong['MaLoaiVai']);
     $manhacungcap->setAttrib('class', 'formEdit')->setValue($hopdong['MaNhaCungCap']);
     $this->addElement($tenhopdong)->addElement($mota)->addElement($ngayky)->addElement($sotansoi)->addElement($thanhtien)->addElement($mamau)->addElement($maloaivai)->addElement($manhacungcap)->addElement($them);
 }
<?php

echo $this->headMeta();
echo $this->headLink();
$dx = new Model_Donxuat();
$donxuatall = $dx->getAll();
if ($donxuatall) {
    $maincontent = array();
    $title = array("Tên Đơn Xuất", "Ngày Xuất", "Thuộc Hợp Đồng", "Tùy Chỉnh");
    $data = new My_Data();
    foreach ($donxuatall as $donxuat) {
        $mydate = Zend_Locale_Format::getDate($donxuat['NgayXuat'], array("date_format" => "yyyy.MM.dd"));
        $date_str = $mydate['day'] . "/" . $mydate['month'] . "/" . $mydate['year'];
        $hd = new Model_Hopdong();
        $myhopdong = $hd->getWhereIdHopDong($donxuat['MaHopDong']);
        $tendonxuat = "<a href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $myhopdong['MaHopDong'] . "/right/donxuat/madonxuat/" . $donxuat['MaDonXuat'] . "/'>" . $donxuat['TenDonXuat'] . "</a>";
        $content = array($tendonxuat, $date_str, $myhopdong['TenHopDong'], '<a href="' . HOST_PROJECT . "/index/chinhsua/donxuat/true/madonxuat/" . $donxuat['MaDonXuat'] . '/option/donxuat/">Sửa</a>&nbsp|&nbsp' . '<a href="' . HOST_PROJECT . "/index/xoa/donxuat/true/mahopdong/" . $myhopdong['TenHopDong'] . "/madonxuat/" . $donxuat['MaDonXuat'] . '/option/donxuat/" onclick="return confirm(' . "'bạn có chắc muốn xóa ?'" . ')">Xóa</a>');
        $maincontent[] = $content;
    }
    $table = $data->createTable($title, $maincontent, "600px");
    echo $table;
} else {
    echo "<div class='message'>";
    echo "Chưa tồn tại Đơn Xuất";
    echo "</div>";
}
 public function getNameKhachHang($mahopdong)
 {
     $hd = new Model_Hopdong();
     $hopdong = $hd->getWhereIdHopDong($mahopdong);
     $madonhang = $hopdong['MaDonHang'];
     $dh = new Model_Donhang();
     $donhang = $dh->getWhere($madonhang);
     $kh = new Model_Khachhang();
     $khachhang = $kh->getWhere($donhang['MaKhachHang'])[0];
     return $khachhang['TenKhachHang'];
 }
<?php

echo $this->headMeta();
echo $this->headLink();
$id_hopdong = $this->param->getParam('mahopdong');
$cm = new Model_Caymoc();
$caymoc = $cm->getWhere_IdHopdong($id_hopdong);
if ($caymoc) {
    echo "<div class='long_message'>";
    echo "Không thể xóa Hợp Đồng đã tạo Cây Mộc !";
    echo "</div>";
} else {
    $hd = new Model_Hopdong();
    $id_donhang = $hd->getWhereIdHopDong($id_hopdong)['MaDonHang'];
    $dh = new Model_Donhang();
    $id_khachhang = $dh->getWhere($id_donhang)['MaKhachHang'];
    $hopdong = $hd->delete_hopdong($id_hopdong);
    if (array_key_exists('option', $this->param->getParams())) {
        echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/hopdong/true';</script>";
    } else {
        echo "<script>window.location.href='" . HOST_PROJECT . "/index/main/khachhang_detail/true/makhachhang/" . $id_khachhang . "/';</script>";
    }
}