1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<?php $formid = "Order"; require_once "inc/configure.php";
//vdump($_REQUEST); //exit;
require_once "inc/ord_dtl_func.php";
$ord_refid = (int) filter_var($_REQUEST['ord_refid'], FILTER_SANITIZE_STRING); $refid = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING);
if( $_POST['action']=="ord_disd_split" && !empty($ord_refid) && !empty($refid) ){ //vdump($_REQUEST); exit; //$qty = (int) filter_var($_REQUEST['qty'], FILTER_SANITIZE_STRING); $qtyperjc = (int) filter_var($_REQUEST['qtyperjc'], FILTER_SANITIZE_STRING); $createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
$sql = "SELECT * from ord_dtl where refid = :refid and main_refid = :ord_refid"; $sth = $dbh->prepare($sql);
$sth->execute( array(':refid'=>$refid, ':ord_refid'=>$ord_refid) ); //echo $sth->getSQL( ); $row = $sth->fetch(); if(!empty($row['chkinordroute_refid'])){ myerror(INVALID.WS.REQUEST); exit; } $qty = $row['qty']; //calculate split portion if($qty>$qtyperjc){ $split = array(); $ratio = array(); for($remain=$qty; $remain>0; $remain-=$qtyperjc){ if($remain > $qtyperjc){ $split[] = $qtyperjc; $ratio[] = $qtyperjc/$qty; } else{ $split[] = $remain; $ratio[] = $remain/$qty; } } //vdump($ratio); } //exit; $dbh->beginTransaction(); splitOrderDetail($refid, $split, $ratio); $dbh->commit(); updateMainValue($ord_refid);
//exit; header("Location: ord_disd_modifyform.php?refid=$ord_refid&msg=Saved."); print "Saved."; exit; } myerror("Invalid Request");
?>
|