Example #1
0
/**
 * Handling ecommerce orders and dispatch
 *
 * @param  AUTO_LINK	The purchase ID.
 * @param  array		Details relating to the product.
 * @param  ID_TEXT	The product.
 */
function handle_product_orders($purchase_id, $details, $product)
{
    require_code('shopping');
    $old_status = $GLOBALS['SITE_DB']->query_value('shopping_order_details', 'dispatch_status', array('order_id' => $purchase_id));
    if ($old_status != $details['ORDER_STATUS']) {
        $GLOBALS['SITE_DB']->query_update('shopping_order_details', array('dispatch_status' => $details['ORDER_STATUS']), array('order_id' => $purchase_id));
        $GLOBALS['SITE_DB']->query_update('shopping_order', array('order_status' => $details['ORDER_STATUS'], 'transaction_id' => $details['txn_id']), array('id' => $purchase_id));
        if ($details['ORDER_STATUS'] == 'ORDER_STATUS_payment_received') {
            purchase_done_staff_mail($purchase_id);
        }
        // TODO: Suspect this is never called ?!? admin_orders.php runs it's own update_stock, and dispatching is not a part of the core eCommerce framework
        if ($details['ORDER_STATUS'] == 'ORDER_STATUS_dispatched') {
            update_stock($purchase_id);
            //Update stock after dispatch
        }
    }
}
Example #2
0
 // Check if the payment_status is Completed
 if ($fielddata['payment_status'] == "Completed") {
     // Check if txn_id has not been previously processed
     $needle = $fielddata['txn_id'];
     // Assign needle to $needle for pre PHP 4.2
     $stored_trans = transaction("all", $itemdata, $fielddata, "ES_processing");
     // Get all transactions (limit to 3 day window in future?)
     if (!in_array($needle, $stored_trans)) {
         // Check if receiver_email is your Primary PayPal e-mail
         $this_trans = transaction($fielddata['custom'], null, null, "ES_processing");
         // Get the specific transaction
         if ($fielddata['receiver_email'] == $this_trans['receiver_email'] || $fielddata['business'] == $this_trans['receiver_email'] || $fielddata['receiver_email'] == $paypal_primary_email || $fielddata['business'] == $paypal_primary_email || $this_trans['receiver_email'] == $paypal_primary_email || $this_trans['business'] == $paypal_primary_email) {
             // Check if totals and currency used are as expected
             if ($this_trans['mc_gross'] == $fielddata['mc_gross'] && $this_trans['mc_currency'] == $fielddata['mc_currency']) {
                 transaction("update", $itemdata, $fielddata, "ES_processing");
                 $stock_updated = update_stock($fielddata['txn_id'], $fielddata['custom']);
                 !$stock_updated ? fwrite($log, "\n " . EASYSHOP_VAL_06 . ":" . $fielddata['custom'] . "\n \n") : fwrite($log, "\n " . EASYSHOP_VAL_07 . " \n \n");
                 // Message: Stock update failed with session id OR Stock updated successfully
             } else {
                 // Totals or currency doesn't match - user intervention required - update monitor - send admin email?
                 $fielddata['payment_status'] = "EScheck_totals_" . $fielddata['payment_status'];
                 transaction("FORCE_NEW", $itemdata, $fielddata);
                 fwrite($log, "\n " . EASYSHOP_VAL_08 . ":" . $fielddata['mc_gross'] . "\n \n");
                 // mc_gross doesn't match rxd mc_gross
                 // Totals or currency doesn't match - user intervention required - update monitor - send admin email?
             }
         } else {
             // Receiver e-mail doesn't match - could be fraudulent - update monitor - send admin email?
             $fielddata['payment_status'] = "EScheck_rxemail_" . $fielddata['payment_status'];
             transaction("FORCE_NEW", $itemdata, $fielddata);
             if ($fielddata['receiver_email'] == "") {
Example #3
0
 /**
  * Function to dispatch an order
  *
  * @return tempcode	The interface.
  */
 function dispatch()
 {
     $title = get_page_title('ORDER_STATUS_dispatched');
     $id = get_param_integer('id');
     $GLOBALS['SITE_DB']->query_update('shopping_order', array('order_status' => 'ORDER_STATUS_dispatched'), array('id' => $id), '', 1);
     $GLOBALS['SITE_DB']->query_update('shopping_order_details', array('dispatch_status' => 'ORDER_STATUS_dispatched'), array('order_id' => $id));
     //There may be more than one items to update status
     require_code('shopping');
     update_stock($id);
     $add_note_url = build_url(array('page' => '_SELF', 'type' => 'order_act', 'action' => 'add_note', 'last_act' => 'dispatched', 'id' => $id), get_module_zone('admin_orders'));
     return redirect_screen($title, $add_note_url, do_lang_tempcode('SUCCESS'));
 }
     //echo $data;
     create($data);
     $data_id = mysql_insert_id();
     // simpan jurnal
     $harga_total = get_total($data_id);
     create_journal($data_id, "purchase.php?page=form&id=", 2, $harga_total['total'], $i_code, '', $i_branch_id);
     //add_stock($i_item_id, $i_branch_id, $i_qty);
     update_detail($data_id, $_SESSION['user_id']);
     $query_item = select_detail_tmp($data_id);
     while ($row_item = mysql_fetch_array($query_item)) {
         //echo $row_item['transaction_production_detail_id'];
         //Minus stock
         $select_stock = select_stock($row_item['branch_id'], $row_item['item_id']);
         $stock_plus = $select_stock['item_stock_qty'] + $row_item['purchase_detail_qty'];
         //echo $stock_plus;
         update_stock($row_item['branch_id'], $row_item['item_id'], $stock_plus);
     }
     header("Location: purchase.php?page=list&did=1");
     break;
 case 'edit':
     extract($_POST);
     $id = get_isset($_GET['id']);
     $i_date = get_isset($i_date);
     $i_date = format_back_date($i_date);
     $i_item_id = get_isset($i_stock_id);
     $i_harga = get_isset($i_harga);
     $i_qty = get_isset($i_qty);
     //$i_total = get_isset($i_total);
     $i_supplier = get_isset($i_supplier);
     $i_branch_id = get_isset($i_branch_id);
     $i_code = get_isset($i_code);
<?php

if ($access != 'VALID') {
    header('location:../../index.php');
}
include_once 'model/shop/fonctions_boutique.php';
$paniers = panier_lire();
if (isset($_POST['tell'])) {
    $num = uniqid();
    if (commande_enregistrer($_SESSION['id'], $_POST['tell'], $_POST['prenomf'], $_POST['nomf'], $_POST['villef'], $_POST['postalf'], $_POST['adressef'], $_POST['mailf'], $_POST['noml'], $_POST['prenoml'], $_POST['villel'], $_POST['postall'], $_POST['adressel'])) {
        $id = lire_dernierecommande()['idcommande'];
        foreach ($paniers as $panier) {
            commande_produit_enregistrer($id, $panier['id'], $panier['qt'], $panier['taille']);
            update_stock($panier['id'], $panier['qt']);
        }
        $retour = "Votre commande a bien été enregistrée";
        panier_vider();
    } else {
        $retour = "Il y a eu une erreur lors de l'enregistrement de votre commande";
    }
}
$title = 'Confirmation de la commande';
include_once 'view/retour.php';
         $transaction_production_id = mysql_insert_id();
         update_detail($transaction_production_id, $_SESSION['user_id']);
         $query_item = select_item($transaction_production_id);
         while ($row_item = mysql_fetch_array($query_item)) {
             //echo $row_item['transaction_production_detail_id'];
             //Minus stock
             $select_stock = select_stock($row_item['branch_id'], $row_item['item_id']);
             $stock_minus = $select_stock['item_stock_qty'] - $row_item['transaction_production_detail_qty'];
             update_stock($row_item['branch_id'], $row_item['item_id'], $stock_minus);
         }
     } else {
         update_production($row_id, $i_hasil);
         //plus stock
         $select_stock2 = select_stock($i_cabang, $i_item);
         $stock_plus = $select_stock2['item_stock_qty'] + $i_hasil;
         update_stock($i_cabang, $i_item, $stock_plus);
     }
     header("Location: transaksi_produksi.php");
     break;
 case 'edit_price':
     $id = get_isset($_GET['id']);
     $qty = get_isset($_GET['qty']);
     $price = get_isset($_GET['price']);
     $total = $qty * $price;
     $data = "transaction_production_detail_qty = '{$qty}',\n\t\t\t\ttransaction_production_detail_price = '{$price}',\n\t\t\t\ttransaction_production_detail_total= '{$total}'\n\t\t\t\t\n\t\t";
     update_config("transaction_production_details", $data, "transaction_production_detail_id", $id);
     break;
 case 'edit_qty':
     //echo "test";
     $id = get_isset($_GET['id']);
     $qty = get_isset($_GET['qty']);
<?php

if ($access != 'VALID') {
    header('location:../../index.php');
}
include_once 'model/shop/fonctions_boutique.php';
$paniers = panier_lire();
if (isset($_POST['tell'])) {
    $num = uniqid();
    if (commande_enregistrer($num, $_SESSION['id'], $_POST['tell'], $_POST['prenomf'], $_POST['nomf'], $_POST['villef'], $_POST['postalf'], $_POST['adressef'], $_POST['mailf'], $_POST['noml'], $_POST['prenoml'], $_POST['villel'], $_POST['postall'], $_POST['adressel'])) {
        foreach ($paniers as $panier) {
            commande_produit_enregistrer($num, $panier['id'], $panier['qt'], $panier['taille']);
            update_stock($panier['id'], $panier('qt'));
        }
        $retour = "Votre commande a bien été enregistrée";
        panier_vider();
    } else {
        $retour = "Il y a eu une erreur lors de l'enregistrement de votre commande";
    }
}
$title = 'Confirmation de la commande';
include_once 'view/retour.php';
     $branch_id = $_SESSION['branch_id'];
     $data = "'',\n\t\t\t\t\t'{$i_code}',\t\n\t\t\t\t\t'{$i_date}',\n\t\t\t\t\t'{$i_pabrik}',\n\t\t\t\t\t'{$i_cabang}',\n\t\t\t\t\t'{$branch_id}'\n\t\t\t\t\t\n\t\t\t\t";
     create_config("transaction_internals", $data);
     $transaction_internal_id = mysql_insert_id();
     update_detail($transaction_internal_id, $_SESSION['user_id']);
     $query_item = select_item($transaction_internal_id);
     while ($row_item = mysql_fetch_array($query_item)) {
         //echo $row_item['transaction_internal_detail_id'];
         //pabrik
         $select_stock_pabrik = select_stock($row_item['pabrik_branch_id'], $row_item['item_id']);
         $stock_pabrik = $select_stock_pabrik['item_stock_qty'] - $row_item['transaction_internal_detail_qty'];
         update_stock($row_item['pabrik_branch_id'], $row_item['item_id'], $stock_pabrik);
         //cabang
         $select_stock_cabang = select_stock($row_item['cabang_branch_id'], $row_item['item_id']);
         $stock_cabang = $select_stock_cabang['item_stock_qty'] + $row_item['transaction_internal_detail_qty'];
         update_stock($row_item['cabang_branch_id'], $row_item['item_id'], $stock_cabang);
     }
     header("Location: transaksi_internal.php");
     break;
 case 'edit_price':
     $id = get_isset($_GET['id']);
     $qty = get_isset($_GET['qty']);
     $price = get_isset($_GET['price']);
     $total = $qty * $price;
     $data = "transaction_internal_detail_qty = '{$qty}',\n\t\t\t\ttransaction_internal_detail_price = '{$price}',\n\t\t\t\ttransaction_internal_detail_total= '{$total}'\n\t\t\t\t\n\t\t";
     update_config("transaction_internal_details", $data, "transaction_internal_detail_id", $id);
     break;
 case 'edit_qty':
     $id = get_isset($_GET['id']);
     $qty = get_isset($_GET['qty']);
     $price = get_isset($_GET['price']);
Example #9
0
             // simpan transaksi
             create_config("transactions", $data);
             $transaction_id = mysql_insert_id();
             $get_table_name = get_table_name($table_id);
             // simpan jurnal
             create_journal($transaction_id, "", 1, $i_grand_total, "Meja " . $get_table_name, $i_bank_id, $_SESSION['branch_id']);
             $query_detail = mysql_query("select * \n\t\t\t\t\t\t\t\tfrom transaction_tmp_details a\n\t\t\t\t\t\t\t\twhere a.transaction_id = '" . $row['transaction_id'] . "'\n\t\t\t\t\t\t\t\t");
             while ($row_detail = mysql_fetch_array($query_detail)) {
                 // simpan transaksi detail
                 $data_detail = "'',\n\t\t\t\t\t\t\t\t\t'{$transaction_id}',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['menu_id'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_original_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_margin_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_price_discount'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_grand_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_qty'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_total'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_compliment_status'] . "'\n\t\t\t\t\t\t\t\t\t";
                 create_config("transaction_details", $data_detail);
                 $query_item = mysql_query("select *\n\t\t\t\t\t\t\t\tfrom menu_recipes a\n\t\t\t\t\t\t\t\twhere a.menu_id = '" . $row_detail['menu_id'] . "'\n\t\t\t\t\t\t\t\t");
                 while ($row_item = mysql_fetch_array($query_item)) {
                     // update stok bahan
                     $new_stock = $row_detail['transaction_detail_qty'] * $row_item['item_qty'];
                     update_stock($branch_id, $row_item['item_id'], $new_stock);
                 }
             }
             // hapus tmp
             delete_tmp($table_id);
             // hapus widget_tmp
             delete_widget_tmp($table_id);
         }
         //include '../views/order/print.php';
         header("location: print.php?transaction_id={$transaction_id}");
     }
     break;
 case 'cancel_order':
     $table_id = $_GET['table_id'];
     $building_id = $_GET['building_id'];
     // hapus transaction_tmp_details