当前位置: 首页>>代码示例>>PHP>>正文


PHP Customer::primary方法代码示例

本文整理汇总了PHP中Customer::primary方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::primary方法的具体用法?PHP Customer::primary怎么用?PHP Customer::primary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer::primary方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * {inheritdoc}
  */
 public static function show($where = [], $sort = false)
 {
     $db = static::db();
     $join_primary = Customer::primary();
     $sql = sprintf('SELECT a.*, b.nama_lengkap, b.alamat, b.kota, b.telp FROM %1$s a LEFT JOIN %2$s b USING (%3$s)', static::table(), Customer::table(), $join_primary);
     if (!empty($where)) {
         if (isset($where[static::$primary])) {
             $where['a.' . static::$primary] = $where[static::$primary];
             unset($where[static::$primary]);
         }
         if (isset($where[$join_primary])) {
             $where['b.' . $join_primary] = $where[$join_primary];
             unset($where[$join_primary]);
         }
         $where = $db->_parseWhere($where);
         $sql .= ' %s';
     }
     return $db->query($sql, $where);
 }
开发者ID:gaiius,项目名称:tokonlen,代码行数:22,代码来源:Order.class.php

示例2: checkout

 public function checkout()
 {
     if (!User::current('id')) {
         redirect('login');
     }
     if ($items = session('cart-items')) {
         $userId = User::current('id');
         $userKey = User::primary();
         $custKey = Customer::primary();
         $pelanggan = Customer::show([$userKey => $userId])->fetchOne();
         $order = [$userKey => $userId, $custKey => $pelanggan->{$custKey}, 'tanggal' => date('Y-m-d'), 'produk' => $items, 'belanja' => post('belanja'), 'kurir' => post('kurir'), 'ongkir' => post('ongkir'), 'bayar' => 0, 'kembali' => 0];
         if (!$order['ongkir'] && !$order['kurir']) {
             setAlert('error', 'Estimasi ongkos kirim belum ada, pastikan field kurir sudah diisi.');
             return redirect('cart');
         }
         $order['total'] = $order['belanja'] + $order['ongkir'];
         if ($return = Order::add($order)) {
             session('cart-items', '');
             setAlert('success', ['Terima kasih telah berbelanja di ' . conf('app.title') . '.', 'Segeralah melakukan pembayaran agar pesanan anda dapat secepatnya kami proses.']);
         } else {
             setAlert('error', 'Terjadi kesalahan dalam penghapusan order');
             return redirect('cart');
         }
     }
     if (User::loggedin()) {
         return redirect('admin-shop/orders/form/' . $return);
     }
     return redirect('shop');
 }
开发者ID:bachors,项目名称:tokonlen,代码行数:29,代码来源:function.php

示例3: orders

 public function orders($do = '', $id = '')
 {
     $this->data['heading'] = 'Administrasi: Pembelian';
     switch ($do) {
         case 'form':
             if (post('submit')) {
                 $userKey = User::primary();
                 $customerKey = Customer::primary();
                 $productKey = Product::primary();
                 $order = [$userKey => 1, 'status' => post('status') ?: 0];
                 if ($tanggal = post('tanggal')) {
                     $order['tanggal'] = formatTanggal($tanggal, 'Y-m-d');
                 } else {
                     $order['tanggal'] = date('Y-m-d');
                 }
                 try {
                     $upload = new Upload('pembayaran');
                     $order['pembayaran'] = $upload->doUpload();
                 } catch (Exception $e) {
                     setAlert('error', $e->getMessage());
                 }
                 if ($id_pelanggan = post($customerKey)) {
                     $order[$customerKey] = $id_pelanggan;
                 } else {
                     $pengguna = ['username' => post('username'), 'email' => post('email'), 'level' => 0, 'aktif' => 1];
                     $pelanggan = ['nama_lengkap' => post('nama_lengkap'), 'alamat' => post('alamat'), 'kota' => post('kota'), 'telp' => post('telp')];
                     if ($password = post('password') and $password == post('passconf')) {
                         $pengguna['password'] = $password;
                     }
                     if ($id_pengguna = User::add($pengguna)) {
                         $pelanggan[$userKey] = $id_pengguna;
                     }
                     if ($id_pengguna and $id_pelanggan = Customer::add($pelanggan)) {
                         $order[$customerKey] = $id_pelanggan;
                     }
                 }
                 if ($produks = post($productKey)) {
                     $produk_qty = post('produk_qty');
                     $produk_arr = [];
                     foreach ($produks as $i => $produk_id) {
                         $produk_arr[$produk_id] = $produk_qty[$i];
                     }
                     $order['produk'] = serialize($produk_arr);
                 }
                 if ($ongkir = post('ongkir') and $kurir = post('kurir')) {
                     $order['ongkir'] = $ongkir;
                     $order['kurir'] = $kurir;
                 }
                 if ($belanja = post('belanja') and $total = post('total')) {
                     $order['belanja'] = $belanja;
                     $order['total'] = $total;
                 }
                 if ($order['status'] === 0) {
                     $order['potongan'] = post('potongan') ?: 0;
                     $order['bayar'] = post('bayar') ?: 0;
                     $order['kembali'] = post('kembali') ?: 0;
                     if ($order['kembali'] < 0) {
                         $order['kembali'] = 0;
                     }
                     if ($order['bayar'] > 0) {
                         $order['status'] = 1;
                     }
                 }
                 if ($resi = post('resi')) {
                     $order['resi'] = $resi;
                 }
                 if (Order::save($order, $id)) {
                     if ($id) {
                         setAlert('success', 'Berhasil memperbarui data order <b>' . $order['nama'] . '</b>');
                     } else {
                         setAlert('success', 'Berhasil menambahkan order <b>' . $order['nama'] . '</b>');
                     }
                     return redirect('admin-shop/orders');
                 }
                 setAlert('error', 'Terjadi kesalahan dalam penyimpanan order');
                 return redirect($this->uri->path());
             }
             $order_data = $id ? Order::show($id)->fetchOne() : [];
             if (!User::is('admin') and ($order_data and $order_data->{$customerKey} != User::current($customerKey))) {
                 return redirect('admin-shop/orders');
             }
             $this->data['data'] = $order_data;
             return $this->render('order-form', $this->data);
             break;
         case 'delete':
             if (Order::del([Order::primary() => $id])) {
                 setAlert('success', 'Order berhasil terhapus');
             } else {
                 setAlert('error', 'Terjadi kesalahan dalam penghapusan order');
             }
             return redirect('admin-shop/orders');
             break;
         default:
             $filter = !User::is('admin') ? [Customer::primary() => User::current('id_pelanggan')] : [];
             $this->data['data'] = Order::show($filter, get('sort'));
             return $this->render('order-table', $this->data);
             break;
     }
 }
开发者ID:tommyputranto,项目名称:tokonlen,代码行数:99,代码来源:AdminShop.class.php

示例4: customers

 public function customers($do = '', $id = '')
 {
     $this->data['heading'] = 'Administrasi: Pelanggan';
     switch ($do) {
         case 'form':
             if (post('submit')) {
                 $error = [];
                 $pengguna = [];
                 if (!$id) {
                     // Jika ini adalah create submision maka, aktifkan pengguna.
                     $pengguna['aktif'] = 1;
                 } else {
                     // Jika merupakan update submission maka ambil data pengguna yang sudah ada.
                     $user = Customer::show([Customer::primary() => $id])->fetchOne();
                 }
                 // Jika username berbeda dengan yang sebelumnya
                 if ($username = post('username') and $username != $user->username) {
                     $pengguna['username'] = $username;
                 }
                 // Jika email berbeda dengan yang sebelumnya
                 if ($email = post('email') and $email !== $user->email) {
                     $pengguna['email'] = $email;
                 }
                 // Jika password bernilai sama dengan passconf
                 if ($password = post('password') and $password == post('passconf')) {
                     $pengguna['password'] = md5($password);
                 }
                 $pelanggan = ['nama_lengkap' => post('nama_lengkap'), 'alamat' => post('alamat'), 'telp' => post('telp')];
                 if ($userId = User::save($pengguna, $id)) {
                     $pelanggan[User::primary()] = $id ?: $userId;
                     if (Customer::save($pelanggan, $id)) {
                         if ($id) {
                             setAlert('success', 'Berhasil memperbarui data pelanggan <b>' . $pelanggan['nama'] . '</b>');
                         } else {
                             setAlert('success', 'Berhasil menambahkan pelanggan <b>' . $pelanggan['nama'] . '</b>');
                         }
                     } else {
                         setAlert('error', 'Data yang anda masukan masih sama, tidak ada update data');
                     }
                 } else {
                     setAlert('notice', 'Data yang anda masukan masih sama, tidak ada update data');
                 }
                 return redirect('admin-shop/customers');
             }
             if ($id) {
                 $this->data['data'] = Customer::show([Customer::primary() => $id])->fetchOne();
             }
             return $this->render('customer-form', $this->data);
             break;
         case 'delete':
             if (Customer::del([Customer::primary() => $id])) {
                 setAlert('success', 'Pelanggan berhasil terhapus');
             } else {
                 setAlert('error', 'Terjadi kesalahan dalam penghapusan pelanggan');
             }
             return redirect('admin-shop/customers');
             break;
         default:
             $this->data['data'] = Customer::show();
             return $this->render('customer-table', $this->data);
             break;
     }
 }
开发者ID:FaddliLWibowo,项目名称:tokonlen,代码行数:63,代码来源:AdminShop.class.php

示例5: Harga

            <div class="control-group">
                <label class="label" for="password">Password</label>
                <div class="control-input">
                    <input type="password" required name="password" id="password" class="small">
                    <input type="password" required name="passconf" id="passconf" class="small">
                </div>
            </div>
        </fieldset>

    <?php 
if ($data and User::is('admin')) {
    ?>
        <fieldset>
            <legend>Belanjaan</legend>
            <?php 
    $orders = Order::show(['a.' . Customer::primary() => $data->id_pelanggan]);
    ?>
            <table class="data">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Tanggal</th>
                        <th>Status</th>
                        <th>Total Harga (Rp.)</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                <?php 
    if ($orders->count() > 0) {
        foreach ($orders->fetch(false) as $order) {
开发者ID:tommyputranto,项目名称:tokonlen,代码行数:31,代码来源:customer-form.php


注:本文中的Customer::primary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。