=8) {
echo "";
sleep(2);
header ("Location:/login/logout.php");
exit;
}
if(isset($_REQUEST["page"]))
$page=$_REQUEST["page"];
else
$page=1; // 1·Î ¼³Á¤ÇØ¾ß ÇÔ
if(isset($_REQUEST["mode"])) //modify_form¿¡¼ È£ÃâÇÒ °æ¿ì
$mode=$_REQUEST["mode"];
else
$mode="";
if(isset($_REQUEST["num"]))
$num=$_REQUEST["num"];
else
$num="";
if(isset($_REQUEST["search"])) //¼öÁ¤ ¹öưÀ» Ŭ¸¯Çؼ È£ÃâÇß´ÂÁö üũ
$search=$_REQUEST["search"];
else
$search="";
if(isset($_REQUEST["find"])) //¼öÁ¤ ¹öưÀ» Ŭ¸¯Çؼ È£ÃâÇß´ÂÁö üũ
$find=$_REQUEST["find"];
else
$find="";
if(isset($_REQUEST["process"])) //¼öÁ¤ ¹öưÀ» Ŭ¸¯Çؼ È£ÃâÇß´ÂÁö üũ
$process=$_REQUEST["process"];
else
$process="Àüü";
$fromdate=$_REQUEST["fromdate"];
$todate=$_REQUEST["todate"];
if(isset($_REQUEST["regist_state"])) // µî·ÏÇϸé 1·Î ¼³Á¤ Á¢¼ö»óÅÂ
$regist_state=$_REQUEST["regist_state"];
else
$regist_state="1";
$con_num=$_REQUEST["con_num"];
$item_outdate=$_REQUEST["outdate"];
$item_indate=$_REQUEST["indate"];
$item_orderman=$_REQUEST["orderman"];
$item_outworkplace=$_REQUEST["outworkplace"];
$item_outputplace=$_REQUEST["outputplace"];
$item_phone=$_REQUEST["phone"];
$item_receiver=$_REQUEST["receiver"];
$item_comment=$_REQUEST["comment"];
$root=$_REQUEST["root"];
$steel=$_REQUEST["steel"];
$motor=$_REQUEST["motor"];
$delivery=$_REQUEST["delivery"];
$regist_state=$_REQUEST["regist_state"];
$item_file_0 = $_REQUEST["file_name_0"];
$item_file_1 = $_REQUEST["file_name_1"];
$item_file_2 = $_REQUEST["file_name_2"];
$item_file_3 = $_REQUEST["file_name_3"];
$item_file_4 = $_REQUEST["file_name_4"];
$copied_file_0 = $_REQUEST["file_copied_0"];
$copied_file_1 = $_REQUEST["file_copied_1"];
$copied_file_2 = $_REQUEST["file_copied_2"];
$copied_file_3 = $_REQUEST["file_copied_3"];
$copied_file_4 = $_REQUEST["file_copied_4"];
$files = $_FILES["upfile"]; //÷ºÎÆÄÀÏ
$count = count($files["name"]);
if($count>0)
{
$upload_dir = '../uploads/output/'; //¹°¸®Àû ÀúÀåÀ§Ä¡ outputÆú´õ
/* $file[0]="";
$file[1]="";
*/
for ($i=0; $i<$count; $i++)
{
$upfile_name[$i] = $files["name"][$i]; //±³Àç 190ÆäÀÌÁö ÂüÁ¶
$upfile_tmp_name[$i] = $files["tmp_name"][$i];
$upfile_type[$i] = $files["type"][$i];
$upfile_size[$i] = $files["size"][$i];
$upfile_error[$i] = $files["error"][$i];
$file = explode(".", $upfile_name[$i]);
$file_name = $file[0];
$file_ext = $file[1];
if (!$upfile_error[$i])
{
$new_file_name = date("Y_m_d_H_i_s");
$new_file_name = $new_file_name."_".$i;
$copied_file_name[$i] = $new_file_name.".".$file_ext;
$uploaded_file[$i] = $upload_dir . $copied_file_name[$i];
if( $upfile_size[$i] > 12000000 ) {
print("
");
exit;
}
if (!move_uploaded_file($upfile_tmp_name[$i], $uploaded_file[$i]) )
{
print("");
exit;
}
}
}
}
require_once("../lib/mydb.php");
$pdo = db_connect();
/*=======================================
=
= 1. $mode=="modify" ÆÄÀÏ UPDATE ?
=
=======================================*/
IF ($mode=="modify")
{
$num_checked = count($_REQUEST['del_file']);
$position = $_REQUEST['del_file'];
for($i=0; $i<$num_checked; $i++) // delete checked item
{
$index = $position[$i];
$del_ok[$index] = "y";
}
try{
$sql = "SELECT * FROM chandj.output WHERE num=?"; // get target record
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1,$num,PDO::PARAM_STR);
$stmh->execute();
$row = $stmh->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $Exception) {
$pdo->rollBack();
print "¿À·ù: ".$Exception->getMessage();
}
for ($i=0; $i<$count; $i++)
{
$field_org_name = "file_name_".$i;
$field_real_name = "file_copied_".$i;
$org_name_value = $upfile_name[$i];
$org_real_value = $copied_file_name[$i];
if ($del_ok[$i] == "y")
{
$delete_field = "file_copied_".$i;
$delete_name = $row[$delete_field];
$delete_path = $upload_dir . $delete_name;
unlink($delete_path);
try{
$pdo->beginTransaction();
$sql = "UPDATE chandj.output SET $field_org_name = ?, $field_real_name = ? WHERE num=?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $org_name_value, PDO::PARAM_STR);
$stmh->bindValue(2, $org_real_value, PDO::PARAM_STR);
$stmh->bindValue(3, $num, PDO::PARAM_STR);
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "¿À·ù: ".$Exception->getMessage();
}
}//if_end
else
{
if (!$upfile_error[$i])
{
try{
$pdo->beginTransaction();
$sql = "UPDATE chandj.output SET $field_org_name = ?, $field_real_name = ? WHERE num=?";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $org_name_value, PDO::PARAM_STR);
$stmh->bindValue(2, $org_real_value, PDO::PARAM_STR);
$stmh->bindValue(3, $num, PDO::PARAM_STR);
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "¿À·ù: ".$Exception->getMessage();
}
}
}//else_end
}//for_end
/* print "Á¢¼Ó¿Ï·á" ; */
/*================================================
=
= A. output Å×ÀÌºí ¼öÁ¤
=
=================================================*/
$sql = "UPDATE chandj.output SET outdate=:outdate, indate=:indate, orderman=:orderman, outworkplace=:outworkplace, outputplace=:outputplace, receiver=:receiver, phone=:phone, comment=:comment, con_num=:con_num, root=:root, steel=:steel, motor=:motor, ";
$sql .= " delivery=:delivery, regist_state=:regist_state WHERE num=:num LIMIT 1";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(':outdate', $_REQUEST['outdate'], PDO::PARAM_STR);
$stmh->bindValue(':indate', $_REQUEST['indate'], PDO::PARAM_STR);
$stmh->bindValue(':orderman', $_REQUEST['orderman'], PDO::PARAM_STR);
$stmh->bindValue(':outworkplace', $_REQUEST['outworkplace'], PDO::PARAM_STR);
$stmh->bindValue(':outputplace', $_REQUEST['outputplace'], PDO::PARAM_STR);
$stmh->bindValue(':receiver', $_REQUEST['receiver'], PDO::PARAM_STR);
$stmh->bindValue(':phone', $_REQUEST['phone'], PDO::PARAM_STR);
$stmh->bindValue(':comment', $_REQUEST['comment'], PDO::PARAM_STR);
$stmh->bindValue(':con_num', $_REQUEST['con_num'], PDO::PARAM_INT);
$stmh->bindValue(':root', $_REQUEST['root'], PDO::PARAM_STR);
$stmh->bindValue(':steel', $_REQUEST['steel'], PDO::PARAM_STR);
$stmh->bindValue(':motor', $_REQUEST['motor'], PDO::PARAM_STR);
$stmh->bindValue(':delivery', $_REQUEST['delivery'], PDO::PARAM_STR);
$stmh->bindValue(':regist_state', $_REQUEST['regist_state'], PDO::PARAM_STR);
$stmh->bindValue(':num', $_REQUEST['num'], PDO::PARAM_INT); //°íÀ¯Å°°ªÀÌ °°³ª?ÀÇ Àǹ̷Π?·Î numÀ¸·Î ¸ÂÃç¾ß ÇÕ´Ï´Ù. where ±¸¹®
$result = $stmh->execute();
//echo "RESULT1:" . $result;
//echo "OK1";
/*====================================================
=
= B. orderlist Å×ÀÌºí ¼öÁ¤
=
=====================================================*/
$sql2 = " UPDATE chandj.orderlist SET outdate=:outdate, indate=:indate, outworkplace=:outworkplace, comment=:comment WHERE outputnum=:outputnum ";
$stmt = $pdo->prepare($sql2);
$stmt->bindParam(':outdate', $_REQUEST['outdate'], PDO::PARAM_STR);
$stmt->bindParam(':indate', $_REQUEST['indate'], PDO::PARAM_STR);
$stmt->bindParam(':outworkplace', $_REQUEST['outworkplace'], PDO::PARAM_STR);
$stmt->bindParam(':comment', $_REQUEST['comment'], PDO::PARAM_STR);
$stmt->bindParam(':outputnum' , $_REQUEST['num'], PDO::PARAM_INT);
$result2 = $stmt->execute();
//echo "RESULT2:" . $result2;
//echo "OK2";
/*====================================================
=
= C. egiorderlist Å×ÀÌºí ¼öÁ¤
=
=====================================================*/
$sql3 = " UPDATE chandj.egiorderlist SET outdate=:outdate, indate=:indate, outworkplace=:outworkplace, comment=:comment WHERE outputnum=:outputnum ";
$stmt = $pdo->prepare($sql3);
$stmt->bindParam(':outdate', $_REQUEST['outdate'], PDO::PARAM_STR);
$stmt->bindParam(':indate', $_REQUEST['indate'], PDO::PARAM_STR);
$stmt->bindParam(':outworkplace', $_REQUEST['outworkplace'], PDO::PARAM_STR);
$stmt->bindParam(':comment', $_REQUEST['comment'], PDO::PARAM_STR);
$stmt->bindParam(':outputnum' , $_REQUEST['num'], PDO::PARAM_INT);
$result3 = $stmt->execute();
//echo "RESULT3:" . $result3;
//echo "OK3";
}
ELSE
{
/*=======================================
=
= 2. INSERT
=
=======================================*/
// µ¥ÀÌÅÍ ½Å±Ô µî·ÏÇÏ´Â ±¸°£
try{
$pdo->beginTransaction();
$sql = "insert into chandj.output(outdate, indate, orderman, outworkplace, outputplace, receiver, phone, comment, con_num, root, steel, motor,";
$sql .= "file_name_0, file_name_1, file_name_2,file_name_3,file_name_4, file_copied_0, file_copied_1, file_copied_2, file_copied_3, file_copied_4, delivery, regist_state)";
$sql .= "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,";// ÃÑ 24°³ ·¹ÄÚµå Ãß°¡
$sql .= "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmh = $pdo->prepare($sql);
$stmh->bindValue(1, $item_outdate, PDO::PARAM_STR);
$stmh->bindValue(2, $item_indate, PDO::PARAM_STR);
$stmh->bindValue(3, $item_orderman, PDO::PARAM_STR);
$stmh->bindValue(4, $item_outworkplace, PDO::PARAM_STR);
$stmh->bindValue(5, $item_outputplace, PDO::PARAM_STR);
$stmh->bindValue(6, $item_receiver, PDO::PARAM_STR);
$stmh->bindValue(7, $item_phone, PDO::PARAM_STR);
$stmh->bindValue(8, $item_comment, PDO::PARAM_STR);
$stmh->bindValue(9, $con_num, PDO::PARAM_STR);
$stmh->bindValue(10, $root, PDO::PARAM_STR);
$stmh->bindValue(11, $steel, PDO::PARAM_STR);
$stmh->bindValue(12, $motor, PDO::PARAM_STR);
$stmh->bindValue(13, $upfile_name[0], PDO::PARAM_STR);
$stmh->bindValue(14, $upfile_name[1], PDO::PARAM_STR);
$stmh->bindValue(15, $upfile_name[2], PDO::PARAM_STR);
$stmh->bindValue(16, $upfile_name[3], PDO::PARAM_STR);
$stmh->bindValue(17, $upfile_name[4], PDO::PARAM_STR);
$stmh->bindValue(18, $copied_file_name[0], PDO::PARAM_STR);
$stmh->bindValue(19, $copied_file_name[1], PDO::PARAM_STR);
$stmh->bindValue(20, $copied_file_name[2], PDO::PARAM_STR);
$stmh->bindValue(21, $copied_file_name[3], PDO::PARAM_STR);
$stmh->bindValue(22, $copied_file_name[4], PDO::PARAM_STR);
$stmh->bindValue(23, $delivery, PDO::PARAM_STR);
$stmh->bindValue(24, $regist_state, PDO::PARAM_STR);
$stmh->execute();
$pdo->commit();
} catch (PDOException $Exception) {
$pdo->rollBack();
print "¿À·ù: ".$Exception->getMessage();
}
}
?>