<?php echo $this->headMeta(); echo $this->headLink(); $mancc = $this->param->getParam('mancc'); $id_hopdong = $this->param->getParam('mahopdong'); $fupdate = new Form_Update_Nhacungcap(); $fupdate->createForm($mancc); if ($this->param->isPost()) { $param = $this->param->getPost(); $check = new Form_Valid_Nhacungcap($param); if ($check->valid($param)) { $data = array("MaNhaCungCap" => $mancc, "TenNhaCungCap" => $this->param->getParam("ten"), "Sdt" => $this->param->getParam("sdt"), "DiaChi" => $this->param->getParam("diachi"), "Fax" => $this->param->getParam("fax")); $kh = new Model_Nhacungcap(); $kh->update_data($mancc, $data); //echo "<script>window.location.href='".HOST_PROJECT."/index/main/caymoc_detail/true/macaymoc/".$id_cm."/';</script>"; echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/nhacungcap/true/';</script>"; } else { echo $fupdate; echo "<div class='message'>"; foreach ($check->messages as $item) { echo $item . "<br/>"; } echo "</div>"; } } else { echo $fupdate; }
<?php echo $this->headMeta(); echo $this->headLink(); $mahopdong = $this->param->getParam('mahopdong'); $hopdong = new Model_Hopdong(); $myhopdong = $hopdong->getWhere($mahopdong); $updatehd = array('TrangThai' => 1); $hopdong->update_data($myhopdong['MaHopDong'], $updatehd); $ncc = new Model_Nhacungcap(); $myncc = $ncc->getWhere($myhopdong['MaNhaCungCap']); $update = array("No" => $myncc['No'] + $myhopdong['ThanhTien']); $ncc->update_data($myncc['MaNhaCungCap'], $update); $ks = new Model_Khosoi(); $khosoi = $ks->getWhere_khohang($myhopdong['MaKho']); // dung bien flag de kiem tra xem trong kho da co loai soi chua $flag = false; $row = array(); if ($khosoi) { foreach ($khosoi as $item) { if ($item['MaSoi'] == $myhopdong['MaSoi']) { $flag = true; $update = array('SoTanSoi' => $item['SoTanSoi'] + $myhopdong['SoTanSoi']); $ks->update_data($item['MaKhoSoi'], $update); $_redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $_redirector->gotoUrl(HOST_PROJECT . "/index/xem/hopdong/true"); } } } $data = array("MaKhoSoi" => null, "MaSoi" => $myhopdong['MaSoi'], "SoTanSoi" => $myhopdong['SoTanSoi'], "MaKho" => $myhopdong['MaKho']); $ks->insert_kho($data);