// makhohang la ma cua kho moc se nhap
 $makhohang = $this->param->getParam("mykhohang");
 //ma moc la ma cay moc
 $mamoc = $this->param->getParam("mamoc");
 $caymoc = new Model_Caymoc();
 $caymocrow = $caymoc->getWhere($mamoc);
 $khosoi = new Model_Khosoi();
 $khosoirow = $khosoi->getWhere($caymocrow['MaKhoSoi']);
 if ($caymocrow['SoKgSoi'] / 1000 > $khosoirow['SoTanSoi']) {
     echo "<div class='message'>";
     echo "Trong kho chỉ còn " . $khosoirow['SoTanSoi'] * 1000 . "kg sợi! Xin vui lòng sửa số kg sợi hoặc nhập thêm!";
     echo "</div>";
 } else {
     // update kho moc cho cay moc
     $update = array("MaKhoMoc" => $makhohang);
     $caymoc->update_data($mamoc, $update);
     //update so kg cho kho soi
     $updatekho = array('SoTanSoi' => $khosoirow['SoTanSoi'] - $caymocrow['SoKgSoi'] / 1000);
     $khosoi->update_data($khosoirow['MaKhoSoi'], $updatekho);
     $khomoc = new Model_KhoMoc();
     $khomocrow = $khomoc->getWhere_khohang($makhohang);
     if ($khomocrow) {
         $makhomoc = "";
         foreach ($khomocrow as $item) {
             if ($item['MaVai'] == $caymocrow['MaVai']) {
                 $makhomoc = $item['MaKhoMoc'];
             }
         }
         if ($makhomoc != "") {
             $updatemoc = array("SoCayMoc" => $khomocrow['SoCayMoc'] + 1, "TongSoMet" => $khomocrow['TongSoMet'] + $caymocrow['SoMetVai']);
             $khomoc->update_data($makhomoc, $updatemoc);
Example #2
0
        $button = "<a class ='thembutton' href='" . HOST_PROJECT . "/index/xem/taoctp/true/option/them/mamoc/" . $mamoc . "/malonhuom/" . $item['MaLoNhuom'] . "'/>Chọn</a>";
        $subcontent = array($item['TenLoNhuom'], $item['NgayNhuom'], $maurow['TenMau'], $button);
        $content[] = $subcontent;
    }
    $table = $data->createTable($title, $content, "500px");
    echo $table;
} else {
    $lonhuomall = $lonhuom->getWhere($malonhuom);
    $title = array("Tên Lô Nhuộm", "Ngày Nhuộm", "Màu");
    $content = array();
    foreach ($lonhuomall as $item) {
        $maurow = $mau->getWhereIdMau($item['MaMau']);
        $subcontent = array($item['TenLoNhuom'], $item['NgayNhuom'], $maurow['TenMau']);
        $content[] = $subcontent;
    }
    $table = $data->createTable($title, $content, "400px");
    echo $table;
    $form = new Form_Formmoi_Caythanhpham();
    if ($this->param->isPost()) {
        $sometvai = $this->param->getPost("sometvai");
        $data = array("MaCTP" => null, "SoMetVai" => $sometvai);
        $ctp = new Model_Caythanhpham();
        $ctp->insert_ctp($data);
        $mactp = $ctp->getMaxIndex();
        $update = array("MaCTP" => $mactp, "MaLoNhuom" => $malonhuom);
        $cm->update_data($caymoc['MaMoc'], $update);
        echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/caythanhpham/true/';</script>";
    } else {
        echo $form;
    }
}
         // them cay tp
         $malonhuom = $param['malonhuom'];
         $formtp->createForm($malonhuom);
         $formtp->populate($param);
         echo $formtp;
         echo "nhap dung";
         foreach ($param as $key => $item) {
             if ($num->isValid($key)) {
                 // them vao caytp
                 $mydata = array('MaCTP' => null, 'SoMetVai' => $item, 'MaKhoTP' => $param['khotp']);
                 $caytp->insert($mydata);
                 //update caymoc
                 $maxindex = $caytp->getMaxIndex();
                 $caymocrow = $caymoc->getWhere($key);
                 $update = array('MaLoNhuom' => $param['malonhuom'], 'MaCTP' => $maxindex);
                 $caymoc->update_data($key, $update);
                 echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/caythanhpham/true';</script>";
             }
         }
         $lonhuom->update_data($param['malonhuom'], array('TrangThai' => 1));
         unset($mysession->checked);
     } else {
         $malonhuom = $param['malonhuom'];
         $formtp->createForm($malonhuom);
         $formtp->populate($param);
         echo $formtp;
         echo "<div class='long_message' style='margin:auto !important;width:400px !important;'>";
         echo $message;
         echo "</div>";
     }
 }
Example #4
0
<?php

echo $this->headMeta();
echo $this->headLink();
$id_ctp = $this->param->getParam('mactp');
$ctp = new Model_Caythanhpham();
$caythanhpham = $ctp->getWhere($id_ctp)[0];
if ($caythanhpham['MaKho'] != null) {
    echo "<div class='long_message'>";
    echo "Không thể xóa cây thành phẩm đã nhập vào kho hàng!";
    echo "</div>";
} else {
    $cm = new Model_Caymoc();
    $caymoc = $cm->getWhere_ctp($id_ctp);
    $mamoc = $caymoc['MaMoc'];
    $update = array("MaCTP" => null);
    $cm->update_data($mamoc, $update);
    $ctp->delete_ctp($id_ctp);
    $caymoc1 = $cm->getWhere($mamoc);
    if (array_key_exists('option', $this->param->getParams())) {
        echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/caythanhpham/true';</script>";
    } else {
        echo "<script>window.location.href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $caymoc1['MaHopDong'] . "/right/lonhuom/malonhuom/" . $caymoc1['MaLoNhuom'] . "/';</script>";
    }
}
Example #5
0
<?php

echo $this->headMeta();
echo $this->headLink();
$id_cm = $this->param->getParam('macaymoc');
$id_hopdong = $this->param->getParam('mahopdong');
$fupdate = new Form_Update_Caymoc();
$fupdate->createForm($id_cm);
if ($this->param->isPost()) {
    $param = $this->param->getPost();
    $check = new Form_Valid_Caymoc($param);
    if ($check->valid($param)) {
        $data = array("MaMoc" => $id_cm, "TenCayMoc" => $this->param->getParam("tencaymoc"), "SoMetVai" => $this->param->getParam("sometvai"), "SoLuongCayMoc" => $this->param->getParam("soluong"), "MaLoaiVai" => $this->param->getParam("maloaivai"));
        $kh = new Model_Caymoc();
        $kh->update_data($id_cm, $data);
        //echo "<script>window.location.href='".HOST_PROJECT."/index/main/caymoc_detail/true/macaymoc/".$id_cm."/';</script>";
        if (array_key_exists('option', $this->param->getParams())) {
            echo "<script>window.location.href='" . HOST_PROJECT . "/index/xem/caymoc/true';</script>";
        } else {
            echo "<script>window.location.href='" . HOST_PROJECT . "/index/main/hopdong_detail/true/mahopdong/" . $id_hopdong . "/right/caymoc/macaymoc/" . $id_cm . "/';</script>";
        }
    } else {
        echo $fupdate;
        echo "<div class='message'>";
        foreach ($check->messages as $item) {
            echo $item . "<br/>";
        }
        echo "</div>";
    }
} else {
    echo $fupdate;
Example #6
0
<?php

echo $this->headMeta();
echo $this->headLink();
$mamoc = $this->param->getParam('mamoc');
$caymoc = new Model_Caymoc();
$caymocrow = $caymoc->getWhere($mamoc);
$updatecm = array('TrangThai' => 1);
$caymoc->update_data($caymocrow['MaMoc'], $updatecm);
$khosoi = new Model_Khosoi();
$khosoirow = $khosoi->getWhere_khohang($caymocrow['MaKho']);
$loaivai = new Model_Loaivai();
$loaivairow = $loaivai->getWhere($caymocrow['MaVai']);
//     $loaisoi = new Model_Loaisoi();
//     $loaisoirow = $loaisoi->getWhere($loaivairow['MaSoi']);
// dung bien flag de kiem tra xem trong kho da co loai soi chua
$flag = false;
$row = array();
if ($khosoirow) {
    foreach ($khosoirow as $item) {
        if ($item['MaSoi'] == $loaivairow['MaSoi']) {
            $flag = true;
            $update = array('SoTanSoi' => $item['SoTanSoi'] + $caymocrow['SoKgSoi'] / 1000);
            $khosoi->update_data($item['MaKhoSoi'], $update);
            $_redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
            $_redirector->gotoUrl(HOST_PROJECT . "/index/xem/caymoc/true");
        }
    }
}