first commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
$list = [] ;
|
||||
|
||||
$query = '' ;
|
||||
$mysqli_category = $mysqli->query( "SELECT a.category_id, b.title FROM rms_bill_category a
|
||||
LEFT JOIN rms_bill_category_translation b ON ( a.category_id = b.category_id )
|
||||
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
|
||||
|
||||
if ( $mysqli_category->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$items = [] ;
|
||||
$mysqli_item = $mysqli->query( "SELECT a.item_id, a.category_id, a.min_amount, a.max_amount, a.is_reference1, a.is_reference2, a.is_reference3, a.is_reference4, a.file, b.title, b.content, b.reference1, b.reference2, b.reference3, b.reference4 FROM rms_bill_item a
|
||||
LEFT JOIN rms_bill_item_translation b ON ( a.item_id = b.item_id )
|
||||
WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' ORDER BY a.sortable ASC" ) ;
|
||||
if ( $mysqli_item->num_rows > 0 ){
|
||||
while ( $row_item = $mysqli_item->fetch_assoc() ){
|
||||
$row_item['title'] = dataFilter( $row_item['title'] ) ;
|
||||
$row_item['content'] = dataFilter( $row_item['content'] ) ;
|
||||
$row_item['file'] = ( $row_item['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row_item['file'] : '' ) ;
|
||||
$items[$row_item['category_id']][] = $row_item ;
|
||||
}
|
||||
}
|
||||
|
||||
while ( $row_category = $mysqli_category->fetch_assoc() ){
|
||||
$row_category['id'] = dataFilter( $row_category['category_id'] ) ;
|
||||
$row_category['title'] = dataFilter( $row_category['title'] ) ;
|
||||
$row_category['items'] = ( $items[$row_category['category_id']] != null ? $items[$row_category['category_id']] : [] ) ;
|
||||
$list[] = $row_category ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data['list'] = $list ;
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '300' ;
|
||||
|
||||
$bill_id = $array['bill_id'] ;
|
||||
$amount = $array['amount'] ;
|
||||
|
||||
if ( $bill_id != '' && $amount > 0 ){
|
||||
$status = '250' ;
|
||||
|
||||
$amount = numberFormat( $amount, 2 ) ;
|
||||
|
||||
if ( $staff_info['staff_wallet'] >= $amount ){
|
||||
$status = '201' ;
|
||||
|
||||
$select_bill = $mysqli->query( "SELECT a.bill_id, a.reference1, a.reference2, a.reference3, a.reference4, b.biller_code, b.min_amount, b.max_amount FROM staff_rms_bill a
|
||||
LEFT JOIN rms_bill_item b ON ( a.item_id = b.item_id )
|
||||
WHERE a.deleted_at IS NULL AND b.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.bill_id = '".$bill_id."' LIMIT 1" ) ;
|
||||
if ( $select_bill->num_rows > 0 ){
|
||||
$status = 'rms-39' ;
|
||||
|
||||
$row_bill = $select_bill->fetch_assoc() ;
|
||||
|
||||
if ( $amount >= $row_bill['min_amount'] && $amount <= $row_bill['max_amount'] ){
|
||||
|
||||
$status = '203' ;
|
||||
|
||||
if ( $mysqli->query( "INSERT INTO staff_rms_bill_order
|
||||
( `branch_id`, `staff_id`, `bill_id`, `biller_code`, `cashier_id`, `reference1`, `reference2`, `reference3`, `reference4`, `amount` ) VALUES
|
||||
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$bill_id."', '".$row_bill['biller_code']."', '".RMSLOCATION."', '".$row_bill['reference1']."', '".$row_bill['reference2']."', '".$row_bill['reference3']."', '".$row_bill['reference4']."', '".$amount."' )" ) ){
|
||||
// update sonumber
|
||||
$order_id = $mysqli->insert_id ;
|
||||
$sonumber = 'BO'.strPad( 6, $order_id ) ;
|
||||
|
||||
$mysqli->query( "UPDATE staff_rms_bill_order SET sonumber = '".$sonumber."' WHERE order_id = '".$order_id."'" ) ;
|
||||
|
||||
$rms_content = [
|
||||
'referenceId' => $sonumber,
|
||||
'billerCode' => $row_bill['biller_code'],
|
||||
'billReferenceNo1' => $row_bill['reference1'],
|
||||
'billReferenceNo2' => $row_bill['reference2'],
|
||||
'billReferenceNo3' => $row_bill['reference3'],
|
||||
'billReferenceNo4' => $row_bill['reference4'],
|
||||
'amount' => $amount
|
||||
] ;
|
||||
$rms_call = rmsCall( 'bill/initiate', $rms_content ) ;
|
||||
saveLog( 'rms-api', 'Intiate Bill Order', $rms_content, $rms_call ) ;
|
||||
|
||||
if ( $rms_call['respCode'] == '00' ){
|
||||
$status = '298' ;
|
||||
|
||||
// deduct the wallet first
|
||||
$remark = 'You have been deducted the wallet from bill order '.$row_bill['reference1'].' (' . $sonumber . ')' ;
|
||||
$walletdeduct = walletMovement( 'staff_rms_bill_order', $order_id, 'minus', 'normal', $staff_info['staff_id'], -($amount), $remark ) ;
|
||||
|
||||
if ( $walletdeduct ){
|
||||
$status = '200' ;
|
||||
|
||||
// update status
|
||||
$mysqli->query( "UPDATE staff_rms_bill_order SET
|
||||
rms_accountname = '".$rms_call['billAccountName']."',
|
||||
rms_instruction = '".$rms_call['instruction']."',
|
||||
rms_authorizationtoken = '".$rms_call['authorizationToken']."',
|
||||
status = 'pending'
|
||||
WHERE order_id = '".$order_id."'" ) ;
|
||||
}
|
||||
|
||||
}else{
|
||||
$status = 'rms-'.$rms_call['respCode'] ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
$mysqli_bill = $mysqli->query( "SELECT a.bill_id FROM staff_rms_bill a
|
||||
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.bill_id = '".$array['bill_id']."'" ) ;
|
||||
|
||||
if ( $mysqli_bill->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$mysqli->query( "UPDATE staff_rms_bill SET
|
||||
deleted_at = '".TODAYDATE."'
|
||||
WHERE bill_id = '".$array['bill_id']."'" ) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
$query = "SELECT a.sonumber, a.biller_code, a.reference1, a.reference2, a.reference3, a.reference4, a.amount, a.status, a.created_at, b.title, c.file FROM staff_rms_bill_order a
|
||||
LEFT JOIN staff_rms_bill b ON ( a.bill_id = b.bill_id )
|
||||
LEFT JOIN rms_bill_item c ON ( b.item_id = c.item_id )
|
||||
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.order_id = '".$array['id']."'" ;
|
||||
$mysqli_query = $mysqli->query( $query . " LIMIT 1" ) ;
|
||||
|
||||
if ( $mysqli_query->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$row = $mysqli_query->fetch_assoc() ;
|
||||
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row['file'] : '' ) ;
|
||||
$data['list'] = $row ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
|
||||
$searchfilter = $array['searchfilter'] ;
|
||||
|
||||
$search_query = '' ;
|
||||
if ( $array['search'] != '' ){
|
||||
$search_query .= " AND ( a.sonumber LIKE '%".$array['search']."%' OR a.reference1 LIKE '%".$array['search']."%' OR b.title LIKE '%".$array['search']."%' )" ;
|
||||
}
|
||||
switch ( $searchfilter ){
|
||||
case 'pending' :
|
||||
$search_query .= " AND a.status IN ( 'new', 'pending', 'progress' )" ;
|
||||
break ;
|
||||
case 'confirmed' :
|
||||
$search_query .= " AND a.status IN ( 'confirmed' )" ;
|
||||
break ;
|
||||
case 'cancelled' :
|
||||
$search_query .= " AND a.status IN ( 'cancelled', 'failed' )" ;
|
||||
break ;
|
||||
}
|
||||
|
||||
$query = "SELECT a.order_id, a.sonumber, a.biller_code, a.reference1, a.reference2, a.reference3, a.reference4, a.amount, a.status, a.created_at, b.title, c.file FROM staff_rms_bill_order a
|
||||
LEFT JOIN staff_rms_bill b ON ( a.bill_id = b.bill_id )
|
||||
LEFT JOIN rms_bill_item c ON ( b.item_id = c.item_id )
|
||||
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' " . $search_query ;
|
||||
$mysqli_query = $mysqli->query( $query . " ORDER BY a.order_id DESC LIMIT " . getLimit( $current ) ) ;
|
||||
|
||||
if ( $mysqli_query->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
$list = [] ;
|
||||
while ( $row = $mysqli_query->fetch_assoc() ){
|
||||
$row['created_at'] = resetDateFormat( $row['created_at'] ) ;
|
||||
$row['order_status'] = ( checkExists( $row['status'] ) != '' ? $row['status'] : '' ) ;
|
||||
$row['file'] = ( $row['file'] != '' ? PATH.'uploads/RmsBillItem/b/'.$row['file'] : '' ) ;
|
||||
$list[] = $row ;
|
||||
}
|
||||
|
||||
$data['list'] = $list ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '201' ;
|
||||
$list = [] ;
|
||||
|
||||
$mysqli_bill = $mysqli->query( "SELECT a.bill_id, a.item_id, a.title, a.reference1, a.reference2, a.reference3, a.reference4, a.created_at, b.is_reference1, b.is_reference2, b.is_reference3, b.is_reference4, c.reference1 as reference1_title, c.reference2 as reference2_title, c.reference3 as reference3_title, c.reference4 as reference4_title FROM staff_rms_bill a
|
||||
LEFT JOIN rms_bill_item b ON ( a.item_id = b.item_id )
|
||||
LEFT JOIN rms_bill_item_translation c ON ( b.item_id = c.item_id )
|
||||
WHERE a.deleted_at IS NULL AND a.staff_id = '".$staff_info['staff_id']."' AND a.item_id = '".$array['item_id']."' AND b.deleted_at IS NULL AND b.status = 'active' AND c.lang = '".$array['lang']."'" ) ;
|
||||
|
||||
if ( $mysqli_bill->num_rows > 0 ){
|
||||
|
||||
$status = '200' ;
|
||||
|
||||
while ( $row_bill = $mysqli_bill->fetch_assoc() ){
|
||||
$list[] = $row_bill ;
|
||||
}
|
||||
}
|
||||
|
||||
$data['list'] = $list ;
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '300' ;
|
||||
|
||||
$item_id = $array['item_id'] ;
|
||||
$title = $array['title'] ;
|
||||
$reference1 = $array['reference1'] ;
|
||||
$reference2 = $array['reference2'] ;
|
||||
$reference3 = $array['reference3'] ;
|
||||
$reference4 = $array['reference4'] ;
|
||||
|
||||
if ( $array['item_id'] != '' && $array['title'] != '' ){
|
||||
$status = '201' ;
|
||||
|
||||
$select_item = $mysqli->query( "SELECT is_reference1, is_reference2, is_reference3, is_reference4 FROM rms_bill_item
|
||||
WHERE deleted_at IS NULL AND status = 'active' AND item_id = '".$item_id."' LIMIT 1" ) ;
|
||||
|
||||
if ( $select_item->num_rows > 0 ){
|
||||
$status = '300' ;
|
||||
|
||||
$row_item = $select_item->fetch_assoc() ;
|
||||
|
||||
$is_error = 0 ;
|
||||
if ( $row_item['is_reference1'] == 'yes' && $reference1 == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference2'] == 'yes' && $reference2 == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference3'] == 'yes' && $reference3 == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference4'] == 'yes' && $reference4 == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
|
||||
if ( $is_error == 0 ){
|
||||
$status = '203' ;
|
||||
|
||||
if ( $mysqli->query( "INSERT INTO staff_rms_bill
|
||||
( `branch_id`, `staff_id`, `item_id`, `title`, `reference1`, `reference2`, `reference3`, `reference4` ) VALUES
|
||||
( '".$array['branch_id']."', '".$staff_info['staff_id']."', '".$array['item_id']."', '".$array['title']."', '".$array['reference1']."', '".$array['reference2']."', '".$array['reference3']."', '".$array['reference4']."' )" ) ){
|
||||
$status = '200' ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
$must_login = true ;
|
||||
$require_path = '../../../' ;
|
||||
$require_sub = '../../' ;
|
||||
require( $require_sub.'header.php' ) ;
|
||||
|
||||
if ( $boolean_login ){
|
||||
$status = '300' ;
|
||||
|
||||
$item_id = $array['item_id'] ;
|
||||
$lists = $array['lists'] ;
|
||||
|
||||
if ( $item_id != '' && count( $array['lists'] ) > 0 ){
|
||||
$status = '201' ;
|
||||
|
||||
$select_item = $mysqli->query( "SELECT is_reference1, is_reference2, is_reference3, is_reference4 FROM rms_bill_item
|
||||
WHERE deleted_at IS NULL AND status = 'active' AND item_id = '".$item_id."' LIMIT 1" ) ;
|
||||
|
||||
if ( $select_item->num_rows > 0 ){
|
||||
$status = '300' ;
|
||||
|
||||
$row_item = $select_item->fetch_assoc() ;
|
||||
|
||||
$is_error = 0 ;
|
||||
foreach ( $lists as $k => $v ){
|
||||
if ( $row_item['is_reference1'] == 'yes' && $v['reference1'] == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference2'] == 'yes' && $v['reference2'] == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference3'] == 'yes' && $v['reference3'] == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
if ( $row_item['is_reference4'] == 'yes' && $v['reference4'] == '' ){
|
||||
$is_error++ ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_error == 0 ){
|
||||
$status = '203' ;
|
||||
|
||||
$is_update = false ;
|
||||
foreach ( $lists as $k => $v ){
|
||||
if ( $mysqli->query( "UPDATE staff_rms_bill SET
|
||||
title = '".$v['title']."',
|
||||
reference1 = '".$v['reference1']."',
|
||||
reference2 = '".$v['reference2']."',
|
||||
reference3 = '".$v['reference3']."',
|
||||
reference4 = '".$v['reference4']."'
|
||||
WHERE bill_id = '".$v['bill_id']."'" ) ){
|
||||
$is_update = true ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_update ){
|
||||
$status = '200' ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require( $require_sub.'footer.php' ) ;
|
||||
?>
|
||||
Reference in New Issue
Block a user