<?php
        session_cache_expire(1440);
        session_start();
        session_name("insys");
        include "include/config.php";
        include "include/functions.php";
        include "class/UctVw.php";

	$ssql=" SELECT d.ftitem_code, c.ftso_no, IFNULL(SUM(d.fnqty),0) AS ttldo, IFNULL(SUM(d.fnqty_base),0) AS ttldo_base
                FROM txdelivery_order_hdr c
                INNER JOIN txdelivery_order_det d ON c.ftdo_no = d.ftdo_no
                WHERE  (c.fnstatus = 1 OR c.fnstatus = 2)
                GROUP BY  d.ftitem_code,c.ftso_no
                ORDER BY c.ftso_no ";
        
	$rs1=mysql_query($ssql);

        pr("sql 1 : {$ssql}");

	while($r1=mysql_fetch_assoc($rs1)) {

                    $ssql2="update txsales_order_det
                            set fnqty_accept ={$r1['ttldo']},
                                fnqty_accept_base ={$r1['ttldo_base']}
                            where ftso_no = '{$r1['ftso_no']}'
                                AND ftitem_code='{$r1['ftitem_code']}'
                            ";

                    mysql_query($ssql2);
                    pr("sql 2 : {$ssql2}");

	}

       

        pr("*** SELESAI ***");
        
?>