Example #1
0
<?php

//membuat variabel didalam fungsi
function hitung()
{
    $nilaix = 5;
    $nilaiy = 20;
    echo "jumlah =" . ($nilaix + $nilaiy);
    echo "<br />";
}
function luashitung()
{
    // mengenal variabel local
    $luas = $nilaix * $nilaiy;
    echo $luas;
}
// memanggil fungsi
hitung();
echo "luas =";
luashitung();
Example #2
0
     if (isset($_POST['supplierId'])) {
         echo json_encode(getInterval($link, $_POST['supplierId']));
     }
     break;
 case 'tambahrpo':
     $rpoId = tambahRpo($link, $_POST['param']);
     tambahRpoDetail($link, $rpoId, $_POST['param']['supplier_id']);
     header('location:input.php?id=' . $rpoId);
     break;
 case 'hitung':
     $poId = $_POST['poId'];
     $barcode = $_POST['barcode'];
     /*
      * Ambil hasil perhitungan untuk avg daily sales dan saran order
      */
     $hasil = hitung($link, $poId, $barcode);
     /*
      * Update po detail dengan nilai hasil perhitungan
      */
     mysqli_query($link, "update purchase_order_detail set avg_daily_sales={$hasil['avg_daily_sales']}, saran_order={$hasil['saran_order']}" . " where purchase_order_id={$poId} and barcode='{$barcode}'") or die('Gagal update po #' . $poId . ', error: ' . mysqli_error($link));
     /*
      * Kembalikan hasil perhitungan + status sukses
      */
     echo json_encode(array_merge(array('sukses' => true), $hasil));
     break;
 case 'order':
     echo json_encode(order($link, $_POST['poId'], $_POST['barcode'], $_POST['qty']));
     break;
 case 'hapus':
     echo json_encode(hapus($link, $_POST['poId'], $_POST['barcode']));
     break;