function dataDeal_add() { global $_SESSION, $_GET, $_POST, $db; $tablename = "stockoutmain"; $childtablename = "stockoutdetail"; $Columns = returntablecolumn($tablename); $ChildColumns = returntablecolumn($childtablename); //print_R($ChildColumns);print "<HR>"; //print_R($Columns);print "<HR>"; $sql = ""; $FieldArray = array(); $ValueArray = array(); for ($i = 0; $i < sizeof($Columns); $i++) { $Element = $Columns[$i]; $Value = $_POST[$Element]; if ($Value != "") { array_push($FieldArray, $Element); switch ($Element) { case 'amt': case 'payamt': case 'factpayamt': case 'noFaxAmt': $Value = ereg_replace(',', '', $Value); $Value = (double) $Value; break; } array_push($ValueArray, $Value); } } //print_R($FieldArray); //单据不流转时,采用的方法 global $SYSTEM_STOP_FLOW; if ($SYSTEM_STOP_FLOW == 1) { array_push($FieldArray, "flowState"); array_push($ValueArray, 1); } //print_R($FieldArray); $FieldText = join(',', $FieldArray); $ValueText = join("','", $ValueArray); //形成主表SQL插入 $sql = "insert into {$tablename} ( {$FieldText} ) values ( '" . $ValueText . "' );"; $rs = $db->Execute($sql); $MainID = $db->Insert_ID(); ////print $sql."<BR>"; //print_R($Columns); //######################################################################### //从表字段插入SQL语句形成################################################## //######################################################################### $sql = ""; $MaxValue = 10; if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 20; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 30; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 40; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 50; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 60; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 70; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 80; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 90; } if ($_POST['productid_id_' . $MaxValue] != "") { $MaxValue = 100; } //明细列表 //$MainID = 9;//主键值 for ($m = 0; $m < $MaxValue; $m++) { $FieldArray = array(); $ValueArray = array(); //明细单项判断 if ($_POST['productid_id_' . $m] != "") { //明细SQL语句形成 for ($i = 0; $i < sizeof($ChildColumns); $i++) { $Element = TRIM($ChildColumns[$i]); if ($Element == "productid") { $Element = "productid_id"; } if ($m == 0) { $Value = $_POST[$Element]; } else { if ($Element == "stockoutfactnum") { $Value = $_POST["plannum_" . $m]; } else { $Value = $_POST[$Element . "_" . $m]; } } if ($Value != "") { array_push($FieldArray, $ChildColumns[$i]); array_push($ValueArray, $Value); } } $FieldText = join(',', $FieldArray); $ValueText = join("','", $ValueArray); //形成主表SQL插入 $sql = "insert into {$childtablename} ( " . $FieldText . ",mainrowid ) values ( '" . $ValueText . "','" . $MainID . "' );"; $rs = $db->Execute($sql); ////print $sql."<BR>"; } } //print_R($FieldArray); //流转操作自动化 global $SYSTEM_STOP_FLOW; if ($SYSTEM_STOP_FLOW == 1 && $MainID != "") { StockOutToStore($MainID, 1); } }
<?php require_once 'lib.inc.php'; $sessionkey = returnSessKey(); $GLOBAL_SESSION = returnsession(); $SUNSHINE_USER_NAME = $_SESSION['SUNSHINE_USER_NAME']; $SUNSHINE_USER_NAME = 'admin'; if ($_GET['action'] == "edit_default2") { //print_R($_GET); //StockOutToStore($_GET['ROWID'],$_POST['flowState']); } if ($_GET['action'] == "edit_default2_data") { //print_R($_POST);print_R($_GET); StockOutToStore($_GET['ROWID'], $_POST['flowState']); //exit; } //默认操作 $filetablename = 'stockoutmain'; $parse_filename = 'stockoutmainflow'; require_once 'include.inc.php'; systemhelpContent("出库操作管理说明", '100%'); //功能函数区 //第一:把入库单据转换为库存 function StockOutToStore($Rowid, $flowState) { global $db; if ($Rowid == "") { exit; } $MainTable = "stockoutmain"; $DetailTable = "stockoutdetail";