/**
  * Updates a particular model.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUbah($id)
 {
     $model = $this->loadModel($id);
     if ($model->status != ReturPenjualan::STATUS_DRAFT) {
         $this->redirect(array('view', 'id' => $model->id));
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $returPenjualanDetail = new ReturPenjualanDetail('search');
     $returPenjualanDetail->unsetAttributes();
     $returPenjualanDetail->setAttribute('retur_penjualan_id', '=' . $id);
     $barang = new Barang('search');
     $barang->unsetAttributes();
     if (isset($_GET['cariBarang'])) {
         $barang->setAttribute('nama', $_GET['namaBarang']);
     }
     /*
      * Grid untuk tampilan pemilihan nomor penjualan/struk
      */
     $penjualanDetail = new PenjualanDetail('search');
     $penjualanDetail->unsetAttributes();
     if (isset($_GET['PenjualanDetail'])) {
         $penjualanDetail->attributes = $_GET['PenjualanDetail'];
     }
     if (isset($_GET['pilih'])) {
         $barcode = $_GET['barcode'] == '' ? 'null' : $_GET['barcode'];
         $qty = $_GET['qty'];
         $penjualanDetail->setAttribute('barcode', '=' . $barcode);
         $penjualanDetail->setAttribute('qty', '>=' . $qty);
     }
     $penjualanDetail->setAttribute('statusPenjualan', '<>0');
     //      $penjualanDetail->setAttribute('customerId', '='.$model->customer_id);
     $this->render('ubah', array('model' => $model, 'returPenjualanDetail' => $returPenjualanDetail, 'barang' => $barang, 'penjualanDetail' => $penjualanDetail));
 }
示例#2
0
 /**
  * Store a newly created resource in storage.
  * POST /invoice
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::to('invoice')->withErrors($validator)->withInput(Input::all());
     } else {
         $invoice = new Invoice();
         $invoice->no_inv = Input::get('no_inv');
         $invoice->tgl_inv = Input::get('tgl_inv');
         $invoice->no_PO = Input::get('no_PO');
         $invoice->ship_by = Input::get('ship_by');
         $invoice->pay_method = Input::get('pay_method');
         $invoice->no_rek = Input::get('no_rek');
         $invoice->pelabuhan = Input::get('pelabuhan');
         $invoice->carrier = Input::get('carrier');
         $invoice->save();
         $SPPB = Barang::join('detil_SPPB', 'barang.kode_barang', '=', 'detil_SPPB.kode_barang')->join('SPPB', 'detil_SPPB.no_SPPB', '=', 'SPPB.no_SPPB')->join('PO', 'SPPB.no_SPPB', '=', 'PO.no_SPPB')->where('no_PO', Input::get('no_PO'))->selectRaw('barang.kode_barang as barang, jml_pesan as pesan')->get();
         foreach ($SPPB as $key => $value) {
             $barang = Barang::find($value->barang);
             $barang->jml_barang = $barang->jml_barang - $value->pesan;
             $barang->save();
         }
         Session::flash('message', 'Successfully created invoice!');
         return Redirect::to('invoice');
     }
 }
示例#3
0
 public static function stok($id)
 {
     $barang = DB::table('bahan')->where('id', $id)->first();
     if (!$barang) {
         $barang = Barang::find($id);
         return $barang->stok;
     }
     return $barang->stok;
 }
示例#4
0
 public function actionCekBarcode()
 {
     if ($_POST['cekharga'] && isset($_POST['barcode'])) {
         $barang = Barang::model()->find('barcode=:barcode', array(':barcode' => $_POST['barcode']));
         $return = ['sukses' => false, 'error' => ['code' => 500, 'msg' => 'Barang tidak ditemukan']];
         if (!is_null($barang)) {
             $return = ['sukses' => true, 'barcode' => $barang->barcode, 'nama' => $barang->nama, 'harga' => $barang->getHargaJual()];
         }
         $this->renderJSON($return);
     }
 }
示例#5
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aBarang instanceof Persistent) {
             $this->aBarang->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aBarang = null;
 }
示例#6
0
 public function dataBarang()
 {
     $term = Input::get('term');
     $data = Barang::distinct()->where('nama', 'LIKE', '%' . $term . '%')->groupBy('id')->take(25)->get();
     $result = [];
     foreach ($data as $barang) {
         if (strpos(Str::lower($barang), $term) !== false) {
             $result[] = ['value' => $barang->nama, 'id' => $barang->id, 'harga' => $barang->harga, 'harga_agenresmi' => $barang->harga_agenresmi, 'harga_agenlepas' => $barang->harga_agenlepas, 'stok' => $barang->stok, 'berat' => $barang->berat];
         }
     }
     return Response::json($result);
 }
示例#7
0
 public function simpan2()
 {
     $detilSTTB = new DetilSTTB();
     $detilSTTB->no_STTB = Input::get('noSTTB');
     $detilSTTB->kode_barang = Input::get('kd_brg');
     $detilSTTB->jml_beli = Input::get('jml_beli');
     $detilSTTB->ket = Input::get('ket');
     $detilSTTB->save();
     $barang = Barang::find(Input::get('kd_brg'));
     $barang->jml_barang = $barang->jml_barang + Input::get('jml_beli');
     $barang->save();
     $brg = array('confirm' => 'succes');
     Session::flash('message', 'Successfully created STTB!');
 }
 /**
  * Display the specified category.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $sortBy = Input::get('sortBy');
     $order = Input::get('orderBy');
     // $category = Barang::with('category')->where('kategori_id','=',$id)->get();
     if ($sortBy && $order) {
         $barangs = Barang::with('category')->where('kategori_id', '=', $id)->orderBy($sortBy, $order)->paginate(25);
     } else {
         $barangs = Barang::with('category')->where('kategori_id', '=', $id)->orderBy('id', 'desc')->paginate(25);
     }
     $category = Category::find($id);
     $totalBarangs = Barang::with('category')->where('kategori_id', '=', $id)->count();
     $stok = ['0' => 'Kosong', '1' => 'Ada'];
     return View::make('admin.categories.show', compact('order', 'sortBy', 'totalBarangs', 'barangs', 'category', 'stok'));
 }
示例#9
0
 public function inputBarangKeCetak()
 {
     if (!empty($this->barcode)) {
         $barang = Barang::model()->find('barcode=:barcode', array(':barcode' => $this->barcode));
         if (!is_null($barang)) {
             $label = new LabelRakCetak();
             $label->barang_id = $barang->id;
             try {
                 $label->save();
                 return 1;
             } catch (Exception $exc) {
                 return 0;
             }
         }
     }
     if (!empty($this->profilId || !empty($this->rakId) || !empty($this->dari))) {
         $sqlProfil = '';
         $sqlRak = '';
         $sqlDari = '';
         if (!empty($this->profilId)) {
             $sqlProfil = "JOIN supplier_barang sp ON barang.id = sp.barang_id AND sp.supplier_id = :supplierId";
         }
         if (!empty($this->rakId)) {
             $sqlRak = "WHERE rak_id = :rakId";
         }
         if (!empty($this->dari)) {
             $sqlDari = "JOIN\n                        barang_harga_jual bhj ON barang.id = bhj.barang_id\n                            AND bhj.updated_at >= :dari";
         }
         /* Menambahkan barang yang belum ada di tabel label_rak_cetak */
         $tabelCetak = LabelRakCetak::model()->tableName();
         $userId = Yii::app()->user->id;
         $sql = "INSERT IGNORE INTO {$tabelCetak} (barang_id, updated_by)\n                SELECT \n                    barang.id, {$userId}\n                FROM\n                    barang\n                    {$sqlDari}\n                    {$sqlProfil}\n                {$sqlRak}";
         $command = Yii::app()->db->createCommand($sql);
         if (!empty($this->profilId)) {
             $command->bindValue(':supplierId', $this->profilId);
         }
         if (!empty($this->rakId)) {
             $command->bindValue(':rakId', $this->rakId);
         }
         if (!empty($this->dari)) {
             $command->bindValue(':dari', date_format(date_create_from_format('d-m-Y H:i', $this->dari), 'Y-m-d H:i:s'));
         }
         return $command->execute();
     }
 }
示例#10
0
 public function reportKartuStok()
 {
     if (!empty($this->barcode)) {
         $barang = Barang::model()->find('barcode=:barcode', [':barcode' => $this->barcode]);
         if (!is_null($barang)) {
             $this->barangId = $barang->id;
         }
     }
     $dari = date_format(date_create_from_format('d-m-Y', $this->dari), 'Y-m-d');
     $sampai = date_format(date_create_from_format('d-m-Y', $this->sampai), 'Y-m-d');
     $tempTableName = $this->tempTableName();
     $sqlSelect = "\n            SELECT \n                *\n            FROM\n                (SELECT \n                    sd.id,\n                    :kodeSo kode,\n                    (sd.qty_sebenarnya - sd.qty_tercatat) qty,\n                    0 harga_beli,\n                    so.nomor,\n                    so.tanggal\n            FROM\n                stock_opname_detail sd\n            JOIN stock_opname so ON sd.stock_opname_id = so.id AND DATE_FORMAT(so.tanggal, '%Y-%m-%d') BETWEEN :dari AND :sampai\n            WHERE\n                sd.barang_id = :barangId\n                    AND sd.qty_sebenarnya != sd.qty_tercatat UNION SELECT \n                    pd.id,\n                    :kodePembelian kode,\n                    pd.qty,\n                    pd.harga_beli,\n                    pembelian.nomor,\n                    pembelian.tanggal\n            FROM\n                pembelian_detail pd\n            JOIN pembelian ON pd.pembelian_id = pembelian.id AND DATE_FORMAT(pembelian.tanggal, '%Y-%m-%d') BETWEEN :dari AND :sampai\n            WHERE\n                pd.barang_id = :barangId UNION SELECT \n                rd.id, :kodeReturPembelian kode, rd.qty, ib.harga_beli, retur.nomor, retur.tanggal\n            FROM\n                retur_pembelian_detail rd\n            JOIN inventory_balance ib ON rd.inventory_balance_id = ib.id\n                AND ib.barang_id = :barangId\n            JOIN retur_pembelian retur ON rd.retur_pembelian_id = retur.id \n                AND DATE_FORMAT(retur.tanggal, '%Y-%m-%d') BETWEEN :dari AND :sampai\n            UNION SELECT \n                    hpp.id,\n                    :kodePenjualan tipe,\n                    hpp.qty,\n                    hpp.harga_beli,\n                    penjualan.nomor,\n                    penjualan.tanggal\n            FROM\n                harga_pokok_penjualan hpp\n            JOIN penjualan_detail pd ON hpp.penjualan_detail_id = pd.id\n                AND pd.barang_id = :barangId\n            JOIN penjualan ON pd.penjualan_id = penjualan.id \n                AND DATE_FORMAT(penjualan.tanggal, '%Y-%m-%d') BETWEEN :dari AND :sampai\n            UNION SELECT \n                rd.id, :kodeReturPenjualan tipe, rd.qty, 0 harga_beli, retur.nomor, retur.tanggal\n            FROM\n                retur_penjualan_detail rd\n            JOIN penjualan_detail pd ON rd.penjualan_detail_id = pd.id\n                AND pd.barang_id = :barangId\n            JOIN retur_penjualan retur ON rd.retur_penjualan_id = retur.id\n                AND DATE_FORMAT(retur.tanggal, '%Y-%m-%d') BETWEEN :dari AND :sampai) t1\n            ORDER BY tanggal            \n                ";
     $sql = " \n            CREATE TEMPORARY TABLE IF NOT EXISTS \n            {$tempTableName} (\n              `local_id` int(10) UNSIGNED DEFAULT NULL,\n              `tipe` varchar(45) DEFAULT NULL,\n              `qty` int(11) DEFAULT NULL,\n              `harga_beli` decimal(18,2) DEFAULT NULL,\n              `nomor` varchar(45) DEFAULT NULL,\n              `tanggal` datetime DEFAULT NULL)\n              ENGINE=MEMORY \n            AS (\n            {$sqlSelect}\n            )    ";
     Yii::app()->db->createCommand("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}")->execute();
     $command = Yii::app()->db->createCommand($sql);
     $command->execute([':barangId' => $this->barangId, ':kodeSo' => KodeDokumen::SO, ':kodePembelian' => KodeDokumen::PEMBELIAN, ':kodeReturPembelian' => KodeDokumen::RETUR_PEMBELIAN, ':kodePenjualan' => KodeDokumen::PENJUALAN, ':kodeReturPenjualan' => KodeDokumen::RETUR_PENJUALAN, ':dari' => $dari, ':sampai' => $sampai]);
     $com = Yii::app()->db->createCommand()->from($tempTableName);
     $comBalance = Yii::app()->db->createCommand("\n            SELECT \n                SUM(qty) total\n            FROM\n                (SELECT \n                    5 tipe, SUM(sd.qty_sebenarnya - sd.qty_tercatat) qty\n                FROM\n                    stock_opname_detail sd\n                JOIN stock_opname so ON sd.stock_opname_id = so.id AND DATE_FORMAT(so.tanggal, '%Y-%m-%d') < :dari\n                WHERE\n                    sd.barang_id = :barangId\n                        AND sd.qty_sebenarnya != sd.qty_tercatat UNION SELECT \n                    1 tipe, SUM(pd.qty)\n                FROM\n                    pembelian_detail pd\n                JOIN pembelian ON pd.pembelian_id = pembelian.id AND DATE_FORMAT(pembelian.tanggal, '%Y-%m-%d') < :dari\n                WHERE\n                    pd.barang_id = :barangId UNION SELECT \n                    2 tipe, 0-SUM(rd.qty) qty\n                FROM\n                    retur_pembelian_detail rd\n                JOIN inventory_balance ib ON rd.inventory_balance_id = ib.id\n                    AND ib.barang_id = :barangId\n                JOIN retur_pembelian retur ON rd.retur_pembelian_id = retur.id \n                    AND DATE_FORMAT(retur.tanggal, '%Y-%m-%d') < :dari\n                UNION SELECT \n                    3 tipe, 0-SUM(hpp.qty) qty\n                FROM\n                    harga_pokok_penjualan hpp\n                JOIN penjualan_detail pd ON hpp.penjualan_detail_id = pd.id\n                    AND pd.barang_id = :barangId\n                JOIN penjualan ON pd.penjualan_id = penjualan.id \n                    AND DATE_FORMAT(penjualan.tanggal, '%Y-%m-%d') < :dari\n                UNION SELECT \n                    4 tipe, SUM(rd.qty) qty\n                FROM\n                    retur_penjualan_detail rd\n                JOIN penjualan_detail pd ON rd.penjualan_detail_id = pd.id\n                    AND pd.barang_id = :barangId\n                JOIN retur_penjualan retur ON rd.retur_penjualan_id = retur.id\n                    AND DATE_FORMAT(retur.tanggal, '%Y-%m-%d') < :dari) AS t1\n                 ")->queryRow(true, [':dari' => $dari, 'barangId' => $this->barangId]);
     $report = ['balance' => $comBalance['total'], 'detail' => $com->queryAll()];
     return $report;
 }
2/9/2016
 -->
 <?php 
require_once '../model/model.php';
require_once '../model/pemesanan.php';
require_once '../model/peminjaman.php';
require_once '../model/barang.php';
$Model = new Model();
$pemesananModel = new Pemesanan();
$peminjamanModel = new Peminjaman();
if (isset($_GET['id_barang']) && isset($_GET['id_user'])) {
    $id_barang = $Model->getFromLink($_GET['id_barang']);
    $id_user = $Model->getFromLink($_GET['id_user']);
    $listpemesanan = $pemesananModel->get($id_barang, $id_user);
    $status = "sedang dipinjam";
    date_default_timezone_set('Asia/Jakarta');
    $datetime = date('Y-m-d h:i:s', time());
    foreach ($listpemesanan as $pemesanan) {
        if (is_null($pemesanan['tangggal_akhir'])) {
            $tgl_peminjaman = $datetime;
        } else {
            $tgl_peminjaman = $pemesanan['tangggal_akhir'];
        }
        $peminjamanModel->add($pemesanan['id_barang'], $pemesanan['id_user'], $status, $tgl_peminjaman);
    }
    $pemesananModel->delete($id_barang, $id_user);
    $barangModel = new Barang();
    $barangModel->dipinjam($id_barang);
}
header("Location: ../view/pemesanan.php");
exit;
示例#12
0
 /**
  * Display a listing of the resource.
  * GET /site
  *
  * @return Response
  */
 public function index()
 {
     $data = array('barang' => Barang::where('jml_barang', '<=', '100')->get(), 'user' => User::all());
     return View::make('index', $data);
     //
 }
 /**
  * Cari Barang untuk autocomplete.
  * @param int $profilId Profil ID
  * @param text $term Text yang akan di cari
  */
 public function actionCariBarang($profilId, $term)
 {
     $q = new CDbCriteria();
     $q->join = 'JOIN supplier_barang sp ON sp.barang_id = t.id';
     $q->addCondition("concat(barcode, nama) like :term");
     $q->addCondition("sp.supplier_id=:profilId");
     $q->order = 'nama';
     $q->params = [':term' => "%{$term}%", ':profilId' => $profilId];
     $barangs = Barang::model()->aktif()->findAll($q);
     $r = array();
     foreach ($barangs as $barang) {
         $r[] = array('label' => $barang->nama, 'value' => $barang->barcode);
     }
     $this->renderJSON($r);
 }
示例#14
0
 public function actionCariBarang($term)
 {
     $q = new CDbCriteria();
     $q->addCondition("barcode like :term OR nama like :term");
     $q->order = 'nama';
     $q->params = [':term' => "%{$term}%"];
     $barangs = Barang::model()->findAll($q);
     $r = array();
     foreach ($barangs as $barang) {
         $r[] = array('label' => $barang->nama, 'value' => $barang->barcode, 'id' => $barang->id, 'stok' => is_null($barang->stok) ? 'null' : $barang->stok, 'harga' => $barang->hargaJual);
     }
     $this->renderJSON($r);
 }
<section id="hotframe" style="margin-top: 58px; margin-left: 295px; min-height: 680px; width:80%">
    <div id="hot">
        <script src="assets/js/chartupload.js">
</script>
<div id="judul"><h2 style="color: #ef1100">       
        <a style="margin-left: 130px" >Tambah Barang</a> 
        </h2>
    
</div>

<br>
<form action="../controller/InputMultiDataBarang2.php" method="POST">
<table class="list" style="width: 80%">
    <?php 
require_once '../model/barang.php';
$barangModel = new Barang();
$listbarang = $barangModel->getAllAda();
if (!empty($listbarang)) {
    ?>
        <tr class="headerlist" >
            <td>Nama Barang</td>
            <td >Lokasi</td>
            <td>Status</td>
            <td>Jumlah_rusak</td>
            <td>Maintenis</td>
        </tr>
        <?php 
} else {
    ?>
        <h2>Barang kosong</h2>
        <?php 
 public function actionSimpantambah()
 {
     $Detaildinas = new Sadetail();
     if ($Detaildinas->load(Yii::$app->request->post()) && $Detaildinas->validate()) {
         $hsl = \Yii::$app->request->post();
         $kdro = $hsl['Sadetail']['KD_SA'];
         $kdBarang = $hsl['Sadetail']['KD_BARANG'];
         $nmBarang = Barang::findOne(['KD_BARANG' => $kdBarang]);
         $kdUnit = $hsl['Sadetail']['UNIT'];
         $rqty = $hsl['Sadetail']['RQTY'];
         $note = $hsl['Sadetail']['NOTE'];
         /*
          * Detail Request Order
          **/
         $Detaildinas->KD_SA = $kdro;
         $Detaildinas->CREATED_AT = date('Y-m-d H:i:s');
         $Detaildinas->NM_BARANG = $nmBarang->NM_BARANG;
         $Detaildinas->KD_BARANG = $kdBarang;
         $Detaildinas->UNIT = $kdUnit;
         $Detaildinas->RQTY = $rqty;
         $Detaildinas->NOTE = $note;
         $Detaildinas->STATUS = 0;
         $Detaildinas->dinasve();
         return $this->redirect(['index?SalesorderSearch[KD_SA]=' . $kdro]);
     } else {
         return $this->redirect(['index']);
     }
 }
<!-- 
dibuat oleh gazandi cahyadarma
2/9/2016
 -->
 <?php 
require_once '../model/model.php';
require_once '../model/barang.php';
$Model = new Model();
$barangModel = new Barang();
if (isset($_GET['id_barang'])) {
    $id = $Model->getFromLink($_GET['id_barang']);
    $status = $Model->getFromLink($_GET['status']);
    switch ($status) {
        case "ada":
            $barangModel->rusak($id);
            break;
        case "rusak":
            $barangModel->diperbaiki($id);
            break;
        case "diperbaiki":
            $barangModel->ada($id);
            break;
        default:
            break;
    }
}
header("Location: ../view/barang.php");
exit;
示例#18
0
				<div class="panel-body">
					<div class="table-responsive">
						<table class="table table-striped table-bordered table-hover" id="dataTables-example">
							<thead>
								<tr>
									<th>Nama Barang</th>
									<th>Harga</th>
									<th>Foto</th>
									<th>Detail</th>
									<th>Aksi</th>
								</tr>
							</thead>
							<tbody>
								<?php 
                $sql = "SELECT * FROM `barang`";
                $barang = Barang::getBarang($sql);
                foreach ($barang as $data => $r) {
                    echo "\n\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t<td>{$r['1']}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t<td>{$r['3']}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t<td>{$r['4']}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t<td>{$r['5']}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t<td width=130px><a href='?p=barang-edit-{$r['0']}' style='width: 60px' class='btn btn-success'>Edit</a> <a href='?p=barang-delete-{$r['0']}' style='width: 60px' class='btn btn-danger'>Hapus</a> </td>\n\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t";
                }
                ?>
	
							</tbody>
						</table>
					</div>
					
				</div>
			</div>
			<!--End Advanced Tables -->
		</div>
	</div>
<?php 
示例#19
0
 public static function tipe($id)
 {
     $barang = Barang::find($id);
     if (!$barang) {
         return false;
     }
     return $barang->kategori_id;
 }
 public function show($id)
 {
     $barang = Barang::find($id)->formula;
     $formula = Formula::select('formula', 'qty')->where('barang_id', $id)->get();
     return View::make('admin.formulas.show', compact('formula', 'barang'));
 }
示例#21
0
 public function pricelist($id)
 {
     $barangs = Barang::all();
     return View::make('admin.barangs.cetak', compact('barangs', 'id'));
 }
示例#22
0
 public function actionSetInAktif($id)
 {
     $return = array('sukses' => false);
     if (isset($_POST['barangid'])) {
         $pk = $_POST['barangid'];
         $barang = Barang::model()->findByPk($pk);
         Barang::model()->updateByPk($pk, array('status' => Barang::STATUS_TIDAK_AKTIF));
         $return = array('sukses' => true);
     }
     $this->renderJSON($return);
 }
示例#23
0
 public function dataForm()
 {
     $cr = new CDbCriteria();
     $cr->condition = 'rak_id = :rakId';
     $cr->params = [':rakId' => $this->rakId];
     if ($this->kategoriId > 0) {
         $cr->addCondition('kategori_id = :kategoriId');
         $cr->params = [':kategoriId' => $this->kategoriId, ':rakId' => $this->rakId];
     }
     switch ($this->sortBy) {
         case self::SORT_BY_NAMA_ASC:
             $cr->order = 'nama';
             break;
         case self::SORT_BY_NAMA_DSC:
             $cr->order = 'nama desc';
             break;
         case self::SORT_BY_BARCODE_ASC:
             $cr->order = 'barcode';
             break;
         case self::SORT_BY_BARCODE_DSC:
             $cr->order = 'barcode desc';
             break;
     }
     return Barang::model()->findAll($cr);
 }
示例#24
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Barang the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Barang::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#25
0
 public function gantiCustomer($customer)
 {
     $transaction = $this->dbConnection->beginTransaction();
     try {
         if (!$this->saveAttributes(array('profil_id' => $customer->id))) {
             throw new Exception('Gagal ubah customer', 500);
         }
         $alamat1 = !empty($customer->alamat1) ? $customer->alamat1 : '';
         $alamat2 = !empty($customer->alamat2) ? '<br>' . $customer->alamat2 : '';
         $alamat3 = !empty($customer->alamat3) ? '<br>' . $customer->alamat3 : '';
         /* Ambil data detail */
         $penjualanDetails = PenjualanDetail::model()->findAll('penjualan_id=:penjualanId', array('penjualanId' => $this->id));
         /* Hapus dan re-insert */
         $tabelPenjualanDiskon = PenjualanDiskon::model()->tableName();
         $tabelPenjualanDetail = PenjualanDetail::model()->tableName();
         Yii::app()->db->createCommand("\n                    DELETE {$tabelPenjualanDiskon}\n                    FROM {$tabelPenjualanDiskon}\n                    INNER JOIN {$tabelPenjualanDetail} ON {$tabelPenjualanDiskon}.penjualan_detail_id = {$tabelPenjualanDetail}.id\n                    WHERE {$tabelPenjualanDetail}.penjualan_id=:penjualanId\n                        ")->bindValues(array(':penjualanId' => $this->id))->execute();
         PenjualanDetail::model()->deleteAll('penjualan_id=:penjualanId', array('penjualanId' => $this->id));
         foreach ($penjualanDetails as $detail) {
             $barang = Barang::model()->findByPk($detail->barang_id);
             $this->tambahBarangProc($barang, $detail->qty);
         }
         $transaction->commit();
         return array('sukses' => true, 'nama' => $customer->nama, 'nomor' => $customer->nomor, 'address' => $alamat1 . $alamat2 . $alamat3);
     } catch (Exception $ex) {
         $transaction->rollback();
         return array('sukses' => false, 'error' => array('msg' => $ex->getMessage(), 'code' => $ex->getCode()));
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Barang $obj A Barang object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         BarangPeer::$instances[$key] = $obj;
     }
 }
 /**
  * Filter the query by a related Barang object
  *
  * @param   Barang|PropelObjectCollection $barang The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 DetailTransaksiQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByBarang($barang, $comparison = null)
 {
     if ($barang instanceof Barang) {
         return $this->addUsingAlias(DetailTransaksiPeer::ID_BARANG, $barang->getId(), $comparison);
     } elseif ($barang instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(DetailTransaksiPeer::ID_BARANG, $barang->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByBarang() only accepts arguments of type Barang or PropelCollection');
     }
 }
示例#28
0
		<label>Obat</label>
		<table class="table table-bordered">
			<thead>
				<th>No.</th>
				<th>Nama Obat</th>
				<th>Harga</th>
				<th>Diskon</th>
				<th>Jumlah</th>
				<th></th>
			</thead>
			<tbody>
				<tr ng-repeat="obat in obatCollection">
					<td>{{$index+1}}</td>
					<td width="60%">
						<?php 
$obat = Barang::model()->findAll();
?>
						<select ng-change="updateObat($index, obat.id_obat, obat.jumlah)" ng-model="obat.id_obat">
							<option value="">--- Pilih ---</option>
							<?php 
for ($i = 0; $i < count($obat); $i++) {
    echo '<option value="' . $obat[$i]['id_barang'] . '">' . $obat[$i]['nama_barang'] . ' - Rp. ' . number_format($obat[$i]['harga_jual'], 2, ',', '.') . '</option>';
}
?>
						</select>
					</td>
					<td>
						{{obat.harga}}
					</td>
					<td>
						{{obat.diskon}}
 /**
  * Filter the query by a related Barang object
  *
  * @param   Barang|PropelObjectCollection $barang  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 KategoriQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByBarang($barang, $comparison = null)
 {
     if ($barang instanceof Barang) {
         return $this->addUsingAlias(KategoriPeer::ID, $barang->getIdKategori(), $comparison);
     } elseif ($barang instanceof PropelObjectCollection) {
         return $this->useBarangQuery()->filterByPrimaryKeys($barang->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByBarang() only accepts arguments of type Barang or PropelCollection');
     }
 }
示例#30
0
 public function ambilBarangNamaPerSupplier($supplierId)
 {
     return Yii::app()->db->createCommand()->select('b.id, b.nama, b.barcode')->from($this->tableName() . ' sb')->join(Barang::model()->tableName() . ' b', 'b.id=sb.barang_id')->where('supplier_id=:supplierId and b.status=1', array(':supplierId' => $supplierId))->order('b.nama')->queryAll();
 }