Advertisement
convoi

NukeViet or_view.php

Jun 20th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.93 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @Project NUKEVIET 3.x
  5.  * @Author VINADES.,JSC (contact@vinades.vn)
  6.  * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  7.  * @Createdate 2-10-2010 18:49
  8.  */
  9.  
  10. $page_title = $lang_module['order_title'];
  11. $table_name = $db_config['prefix'] . "_" . $module_data . "_orders";
  12.  
  13. $order_id = $nv_Request->get_int( 'order_id', 'post,get', 0 );
  14. $db->sql_query( "UPDATE `" . $table_name . "` SET view = 1 WHERE `order_id`=" . $order_id );
  15.  
  16. $save = $nv_Request->get_string( 'save', 'post', '' );
  17.  
  18. $result = $db->sql_query( "SELECT *  FROM `" . $table_name . "` WHERE `order_id`=" . $order_id );
  19. $data_content = $db->sql_fetchrow( $result, 2 );
  20.  
  21. if( empty( $data_content ) ) Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=order" );
  22.  
  23. if( $save == 1 and intval( $data_content['transaction_status'] ) == -1 )
  24. {
  25.     $order_id = $nv_Request->get_int( 'order_id', 'post', 0 );
  26.     $transaction_status = 0;
  27.     $payment_id = 0;
  28.     $payment_amount = 0;
  29.     $payment_data = "";
  30.     $payment = "";
  31.     $userid = $admin_info['userid'];
  32.    
  33.     $transaction_id = $db->sql_query_insert_id( "INSERT INTO `" . $db_config['prefix'] . "_" . $module_data . "_transaction` (`transaction_id`, `transaction_time`, `transaction_status`, `order_id`, `userid`, `payment`, `payment_id`, `payment_time`, `payment_amount`, `payment_data`) VALUES (NULL, UNIX_TIMESTAMP(), '" . $transaction_status . "', '" . $order_id . "', '" . $userid . "', '" . $payment . "', '" . $payment_id . "', UNIX_TIMESTAMP(), '" . $payment_amount . "', '" . $payment_data . "')" );
  34.    
  35.     if( $transaction_id > 0 )
  36.     {
  37.         $db->sql_query( "UPDATE `" . $db_config['prefix'] . "_" . $module_data . "_orders` SET transaction_status=" . $transaction_status . " , transaction_id = " . $transaction_id . " WHERE `order_id`=" . $order_id );
  38.  
  39.         nv_insert_logs( NV_LANG_DATA, $module_name, 'log_process_product', "order_id " . $order_id, $admin_info['userid'] );
  40.     }
  41.    
  42.     nv_del_moduleCache( $module_name );
  43.     Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=order" );
  44. }
  45.  
  46. $link = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=";
  47.  
  48. $listid = explode( "|", $data_content['listid'] );
  49. $listnum = explode( "|", $data_content['listnum'] );
  50. $listprice = explode( "|", $data_content['listprice'] );
  51. $data_pro = array();
  52. $i = 0;
  53.  
  54. foreach( $listid as $id )
  55. {
  56.     $sql = "SELECT t1.id, t1.listcatid, t1.product_code, t1.publtime, t1." . NV_LANG_DATA . "_title, t1." . NV_LANG_DATA . "_alias, t1." . NV_LANG_DATA . "_note, t1.product_price,t2." . NV_LANG_DATA . "_title FROM `" . $db_config['prefix'] . "_" . $module_data . "_units` AS t2, `" . $db_config['prefix'] . "_" . $module_data . "_rows` AS t1 WHERE t1.product_unit = t2.id AND t1.id =" . $id . "  AND t1.status=1 AND t1.publtime < " . NV_CURRENTTIME . " AND (t1.exptime=0 OR t1.exptime>" . NV_CURRENTTIME . ")";
  57.    
  58.     $result = $db->sql_query( $sql );
  59.    
  60.     list( $id, $_catid, $product_code, $publtime, $title, $alias, $note, $product_price, $unit ) = $db->sql_fetchrow( $result );
  61.     $data_pro[] = array(
  62.         "id" => $id,
  63.         "publtime" => $publtime,
  64.         "title" => $title,
  65.         "alias" => $alias,
  66.         "product_price" => $listprice[$i],
  67.         "product_code" => $product_code,
  68.         "product_unit" => $unit,
  69.         "link_pro" => $link . $global_array_cat[$_catid]['alias'] .  "/" . $alias . "-" . $id,
  70.         "product_number" => $listnum[$i]
  71.     );
  72.     $i++;
  73. }
  74.  
  75. $xtpl = new XTemplate( "or_view.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  76. $xtpl->assign( 'LANG', $lang_module );
  77. $xtpl->assign( 'dateup', date( "d-m-Y", $data_content['order_time'] ) );
  78. $xtpl->assign( 'moment', date( "h:i' ", $data_content['order_time'] ) );
  79. $xtpl->assign( 'DATA', $data_content );
  80. $xtpl->assign( 'order_id', $data_content['order_id'] );
  81.  
  82. $i = 0;
  83. foreach( $data_pro as $pdata )
  84. {
  85.     $xtpl->assign( 'product_code', $pdata['product_code'] );
  86.     $xtpl->assign( 'product_name', $pdata['title'] );
  87.     $xtpl->assign( 'product_number', $pdata['product_number'] );
  88.     $xtpl->assign( 'product_price', FormatNumber( $pdata['product_price'], 2, '.', ',' ) );
  89.     $xtpl->assign( 'product_unit', $pdata['product_unit'] );
  90.     $xtpl->assign( 'link_pro', $pdata['link_pro'] );
  91.     $xtpl->assign( 'pro_no', $i + 1 );
  92.     $bg = ( $i % 2 == 0 ) ? "class=\"bg\"" : "";
  93.     $xtpl->assign( 'bg', $bg );
  94.  
  95.     $xtpl->parse( 'main.loop' );
  96.     $i++;
  97. }
  98. if( ! empty( $data_content['order_note'] ) )
  99. {
  100.     $xtpl->parse( 'main.order_note' );
  101. }
  102. $xtpl->assign( 'order_total', FormatNumber( $data_content['order_total'], 2, '.', ',' ) );
  103. $xtpl->assign( 'unit', $data_content['unit_total'] );
  104.  
  105. // transaction_status: Trang thai giao dich:
  106. // -1 - Giao dich cho duyet
  107. // 0 - Giao dich moi tao
  108. // 1 - Chua thanh toan;
  109. // 2 - Da thanh toan, dang bi tam giu;
  110. // 3 - Giao dich bi huy;
  111. // 4 - Giao dich da hoan thanh thanh cong (truong hop thanh toan ngay hoac thanh toan tam giu nhung nguoi mua da phe chuan)
  112.  
  113. if( $data_content['transaction_status'] == 4 )
  114. {
  115.     $html_payment = $lang_module['history_payment_yes'];
  116. }
  117. elseif( $data_content['transaction_status'] == 3 )
  118. {
  119.     $html_payment = $lang_module['history_payment_cancel'];
  120. }
  121. elseif( $data_content['transaction_status'] == 2 )
  122. {
  123.     $html_payment = $lang_module['history_payment_check'];
  124. }
  125. elseif( $data_content['transaction_status'] == 1 )
  126. {
  127.     $html_payment = $lang_module['history_payment_send'];
  128. }
  129. elseif( $data_content['transaction_status'] == 0 )
  130. {
  131.     $html_payment = $lang_module['history_payment_no'];
  132. }
  133. elseif( $data_content['transaction_status'] == -1 )
  134. {
  135.     $html_payment = $lang_module['history_payment_wait'];
  136. }
  137. else
  138. {
  139.     $html_payment = "ERROR";
  140. }
  141.  
  142. $xtpl->assign( 'payment', $html_payment );
  143.  
  144. if( $data_content['transaction_status'] == -1 )
  145. {
  146.     $xtpl->parse( 'main.onsubmit' );
  147. }
  148.  
  149. if( $data_content['transaction_status'] != "4" ) $xtpl->parse( 'main.onpay' );
  150.  
  151. $xtpl->assign( 'LINK_PRINT', NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=print&order_id=" . $data_content['order_id'] . "&checkss=" . md5( $data_content['order_id'] . $global_config['sitekey'] . session_id() ) );
  152. $xtpl->assign( 'URL_ACTIVE_PAY', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=active_pay&order_id=" . $order_id );
  153. $xtpl->assign( 'URL_BACK', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=or_view&order_id=" . $order_id );
  154.  
  155. $array_data_payment = array();
  156. $sql = "SELECT * FROM `" . $db_config['prefix'] . "_" . $module_data . "_payment` ORDER BY `weight` ASC";
  157. $result = $db->sql_query( $sql );
  158.  
  159. while( $row = $db->sql_fetchrow( $result ) )
  160. {
  161.     $payment = $row['payment'];
  162.     $array_data_payment[$payment] = array(
  163.         'config' => array(),
  164.         'orders_id' => array(),
  165.         'data' => array()
  166.     );
  167.    
  168.     $array_data_payment[$payment]['domain'] = $row['domain'];
  169.     $array_data_payment[$payment]['paymentname'] = $row['paymentname'];
  170.    
  171.     if( file_exists( NV_ROOTDIR . "/modules/" . $module_file . "/payment/" . $payment . ".config.ini" ) )
  172.     {
  173.         $array_data_payment[$payment]['config'] = unserialize( nv_base64_decode( $row['config'] ) );
  174.     }
  175. }
  176.  
  177. // Check lai cac don hang
  178. $checkpayment = $nv_Request->get_string( 'checkpayment', 'post,get', '' );
  179. if( ! empty( $checkpayment ) and $checkpayment == md5( $order_id . session_id() . $global_config['sitekey'] ) )
  180. {
  181.     $order_code = $data_content['order_code'];
  182.     require_once ( NV_ROOTDIR . "/modules/" . $module_file . "/payment/nganluong.class.php" );
  183.     $payment_config = $array_data_payment['nganluong']['config'];
  184.     $nl = new NL_Checkout( $payment_config['checkout_url'], $payment_config['merchant_site'], $payment_config['secure_pass'] );
  185.     $transaction_i = $nl->checkOrder( $payment_config['public_api_url'], $order_code, 0 );
  186.     if( $transaction_i !== false )
  187.     {
  188.         print_r( $transaction_i );
  189.         die();
  190.     }
  191. }
  192.  
  193. $a = 1;
  194. $array_transaction = array();
  195. $result = $db->sql_query( "SELECT * FROM `" . $db_config['prefix'] . "_" . $module_data . "_transaction` WHERE `order_id`=" . $order_id . " ORDER BY `transaction_id` ASC" );
  196.  
  197. if( $db->sql_numrows( $result ) )
  198. {
  199.     $array_payment = array();
  200.     while( $row = $db->sql_fetchrow( $result ) )
  201.     {
  202.         $row['a'] = $a++;
  203.         $row['transaction_time'] = nv_date( "H:i:s d/m/y", $row['transaction_time'] );
  204.         $row['order_id'] = ( ! empty( $row['order_id'] ) ) ? $row['order_id'] : "";
  205.         $row['payment_time'] = ( ! empty( $row['payment_time'] ) ) ? nv_date( "H:i:s d/m/y", $row['payment_time'] ) : "";
  206.         $row['payment_id'] = ( ! empty( $row['payment_id'] ) ) ? $row['payment_id'] : "";
  207.        
  208.         if( ! empty( $row['payment_id'] ) ) $array_payment[] = $row['payment_id'];
  209.        
  210.         $row['payment_amount'] = FormatNumber( $row['payment_amount'], 2, '.', ',' );
  211.        
  212.         if( $row['transaction_status'] == 4 )
  213.         {
  214.             $row['transaction'] = $lang_module['history_payment_yes'];
  215.         }
  216.         elseif( $row['transaction_status'] == 3 )
  217.         {
  218.             $row['transaction'] = $lang_module['history_payment_cancel'];
  219.         }
  220.         elseif( $row['transaction_status'] == 2 )
  221.         {
  222.             $row['transaction'] = $lang_module['history_payment_check'];
  223.         }
  224.         elseif( $row['transaction_status'] == 1 )
  225.         {
  226.             $row['transaction'] = $lang_module['history_payment_send'];
  227.         }
  228.         elseif( $row['transaction_status'] == 0 )
  229.         {
  230.             $row['transaction'] = $lang_module['history_payment_no'];
  231.         }
  232.         elseif( $row['transaction_status'] == -1 )
  233.         {
  234.             $row['transaction'] = $lang_module['history_payment_wait'];
  235.         }
  236.         else
  237.         {
  238.             $row['transaction'] = "ERROR";
  239.         }
  240.         if( $row['userid'] > 0 )
  241.         {
  242.             list( $username ) = $db->sql_fetchrow( $db->sql_query( "SELECT `username` FROM " . NV_USERS_GLOBALTABLE . " WHERE userid=" . $row['userid'] ) );
  243.             $row['payment'] = $username;
  244.             $row['link_user'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=users&" . NV_OP_VARIABLE . "=edit&userid=" . $row['userid'];
  245.         }
  246.         elseif( isset( $array_data_payment[$row['payment']] ) )
  247.         {
  248.             $row['link_user'] = $array_data_payment[$row['payment']]['domain'];
  249.             $row['payment'] = $array_data_payment[$row['payment']]['paymentname'];
  250.         }
  251.         else
  252.         {
  253.             $row['link_user'] = "#";
  254.         }
  255.        
  256.         $xtpl->assign( 'DATA_TRANS', $row );
  257.         $xtpl->parse( 'main.transaction.looptrans' );
  258.     }
  259.    
  260.     if( ! empty( $array_payment ) )
  261.     {
  262.         $xtpl->assign( 'LINK_CHECK_PAYMENT', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op . "&order_id=" . $order_id . "&checkpayment=" . md5( $order_id . session_id() . $global_config['sitekey'] ) );
  263.         $xtpl->parse( 'main.transaction.checkpayment' );
  264.     }
  265.    
  266.     $xtpl->parse( 'main.transaction' );
  267. }
  268.  
  269. $xtpl->parse( 'main' );
  270. $contents = $xtpl->text( 'main' );
  271.  
  272. $set_active_op = "order";
  273.  
  274. include ( NV_ROOTDIR . "/includes/header.php" );
  275. echo nv_admin_theme( $contents );
  276. include ( NV_ROOTDIR . "/includes/footer.php" );
  277.  
  278. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement