UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:38:25";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:08:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:08:26', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:39:52";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:09:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 00:09:52', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:39:52";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:09:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 00:09:53', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:40:59";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:10:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 00:10:59', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2111,6,1,1772,6,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 00:10:59',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6376';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 6, 1772, 0, 0
                    , 430.00, 6, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-6, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "6*2024-05-31*430.00," WHERE transferproductid = 8812;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '6', '6', '1', '8812', 'تحويل منتجات من المخزن', 'storemovementController.php', '6.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '6', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6364';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 1, 1772, 0, 0
                    , 430.00, 6, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '1', '6', '0', '8812', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '6', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1773', '10', '2024-06-10', '1', '0','2111',null,null,'2024-06-10 00:10:59',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6375';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 6, 1773, 0, 0
                    , 430.00, 10, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-05-31*430.00," WHERE transferproductid = 8813;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '6', '10', '1', '8813', 'تحويل منتجات من المخزن', 'storemovementController.php', '10.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '10', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6365';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 1, 1773, 0, 0
                    , 430.00, 10, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '1', '10', '0', '8813', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '10', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('6', '1', '1771', '9', '2024-06-10', '1', '0','2111',null,null,'2024-06-10 00:10:59',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6374';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 6, 1771, 0, 0
                    , 430.00, 9, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-9, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "9*2024-05-31*430.00," WHERE transferproductid = 8814;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '6', '9', '1', '8814', 'تحويل منتجات من المخزن', 'storemovementController.php', '9.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6363';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-31', 1, 1771, 0, 0
                    , 430.00, 9, 0, 0, 1, '2024-06-10 00:10:59')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+9, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 00:10:59' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '1', '9', '0', '8814', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '9', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:40:59";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:10:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 00:10:59', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:43:42";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:13:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:13:42', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:49:18";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:19:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:19:18', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:49:51";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:19:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:19:51', '1', 'add', '156.210.101.227', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6355';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1766', '1', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '15', '1', '2024-06-10','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:49:53";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:19:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:19:53', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:50:20";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:20:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:20:20', '1', 'add', '156.210.101.227', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6354';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '1', '15', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '15', '1', '2024-06-10','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:50:22";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:20:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:20:22', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:52:03";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:22:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:22:03', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:53:13";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:23:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 00:23:13', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:53:27";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:23:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 00:23:27', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 20:54:17";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:24:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:24:17', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:06:53";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:36:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:36:53', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:07:31";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:37:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:37:31', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:07:44";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:37:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:37:44', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '390', productSellAllPrice = '430.00', productSellUnitPrice = '480.00', productSellHalfPrice = '440.00', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '302.63',meanbuyprice_withDiscount = '302.63' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 00:38:05',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 00:38:05', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '390.00', productSellAllPrice = '390', productSellUnitPrice = '390', productSellHalfPrice = '390', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '302.63',meanbuyprice_withDiscount = '302.63' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 00:38:20',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 00:38:20', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '390.00', productSellAllPrice = '390.00', productSellUnitPrice = '390.00', productSellHalfPrice = '400', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '302.63',meanbuyprice_withDiscount = '302.63' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 00:38:27',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 00:38:27', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '390.00', productSellAllPrice = '390.00', productSellUnitPrice = '470', productSellHalfPrice = '400.00', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '302.63',meanbuyprice_withDiscount = '302.63' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 00:38:41',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 00:38:41', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:08:59";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:39:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:39:00', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:10:06";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:40:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:40:06', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:11:43";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:41:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:41:43', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:21:33";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:51:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:51:33', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:21:33";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:51:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:51:33', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:22:02";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:52:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:52:02', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE product SET productName = 'ع 4 مشجر', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01751',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '500.00',lastbuyprice_withDiscount = '500',meanbuyprice = '450.00',meanbuyprice_withDiscount = '450' , productbuypricereal = '500.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.00' , buypart_precentage = '12.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1751';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1751, 1,'2024-06-10 00:53:10',1)
                ON DUPLICATE KEY UPDATE productid = 1751, edited = 1, sysdate = '2024-06-10 00:53:10', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:23:38";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:53:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 00:53:38', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:24:03";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:54:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:54:03', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:24:51";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:54:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:54:51', '1', 'add', '156.210.101.227', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '1', '11', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-11.00', '0', '1', '2024-06-10','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:24:53";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:54:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:54:53', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:25:55";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:55:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:55:55', '1', 'add', '156.210.101.227', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6286';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1751', '1', '23', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '23', '1', '2024-06-10','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:25:57";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:55:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-06-10 00:55:57', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:26:44";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 00:56:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 00:56:44', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:34:18";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:04:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:04:18', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:34:42";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:04:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:04:42', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:35:01";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:05:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:05:01', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:36:16";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:06:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:06:16', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:36:28";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:06:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:06:28', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:36:59";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:06:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:06:59', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:37:09";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:07:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:07:09', '1', 'editsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:45:02";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:15:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:15:03', '1', 'update', '156.210.101.227', '', 'DESKTOP');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 17418 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 17418 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 17418;
UPDATE sellbill SET  sellbillsysdate = '2024-06-10 01:15:03', userid = '1',delbyuserid = '1', conditions = '1'  WHERE sellbillid = '17418';
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 422.50, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 422.50
                where sellbilldetailid = 51633;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-06-10', 8479.0603039712, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,21,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8479.0603039712, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-21
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8479.0603039712, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8479.0603039712, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '90', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '21', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '69.00', '90', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 51634;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1755, '2024-06-10', 8075.2955275917, 8200, 8200
                    , 8200, 8200, 8200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8075.2955275917, sellCostBuyPrice =sellCostBuyPrice-8200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8075.2955275917, 8200, 8200
                    , 8200, 8200, 8200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8075.2955275917, sellCostBuyPrice =sellCostBuyPrice-8200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6304';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1755', '1', '20', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '20', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 51635;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1777, '2024-06-10', 10479.104428828, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,31,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-10479.104428828, sellCostBuyPrice =sellCostBuyPrice-11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-31
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 10479.104428828, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-10479.104428828, sellCostBuyPrice =sellCostBuyPrice-11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6391';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1777', '1', '31', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '31', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51636;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 6572.9149643188, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6572.9149643188, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 6572.9149643188, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6572.9149643188, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '92', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '20', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '72.00', '92', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 375.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 375.00
                where sellbilldetailid = 51637;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1687, '2024-06-10', 8206.753826878, 8740, 8740
                    , 8625, 8740, 8625, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,23,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8206.753826878, sellCostBuyPrice =sellCostBuyPrice-8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8625
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8625
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-23
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8206.753826878, 8740, 8740
                    , 8625, 8740, 8625, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8206.753826878, sellCostBuyPrice =sellCostBuyPrice-8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8625
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8625
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6126';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '1', '23', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '23', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51638;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-06-10', 11150.480743041, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,25,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-11150.480743041, sellCostBuyPrice =sellCostBuyPrice-11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-25
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11150.480743041, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-11150.480743041, sellCostBuyPrice =sellCostBuyPrice-11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '25', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6322';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '1', '25', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '25', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51639;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 6572.9149643188, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6572.9149643188, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 6572.9149643188, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6572.9149643188, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '44', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6340';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '1', '20', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '24.00', '44', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51640;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 8450.8906684099, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8450.8906684099, sellCostBuyPrice =sellCostBuyPrice-9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8450.8906684099, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8450.8906684099, sellCostBuyPrice =sellCostBuyPrice-9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '-19', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '5618';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '20', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-39.00', '-19', '1', '2024-06-09 00:05:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-3 where id = 19169;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51641;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1642, '2024-06-10', 9718.5242686714, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,23,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9718.5242686714, sellCostBuyPrice =sellCostBuyPrice-10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-23
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9718.5242686714, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-9718.5242686714, sellCostBuyPrice =sellCostBuyPrice-10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '5966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '1', '23', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '23', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51642;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1781, '2024-06-10', 8479.0603039712, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,21,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8479.0603039712, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-21
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8479.0603039712, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8479.0603039712, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '109', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '21', '0', '17418', 'تعديل فاتورة مبيعات', 'sellbillController.php', '88.00', '109', '1', '2024-06-09 00:05:20','0','0');
CALL clientInUse(414,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '414';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('414','86185.00','86185.00','1','تعديل فاتورة مبيعات','17418', '0', '2024-06-09 00:05:20', '1', 'sellbillController.php', 'تعديل فاتورة مبيعات', '86185', '0', null, '0', null, null,'', '0','1','1','86185','1');
UPDATE client SET  inUse = 0 where clientid = 414;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 86185, 91385, 92535
                    , 91687.5, 92535, 91687.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-86185, sellCostBuyPrice =sellCostBuyPrice-91385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-92535, sellCostMeanBuyPrice = sellCostMeanBuyPrice-91687.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-92535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-91687.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (414, '2024-06-10', 86185, 91385, 92535
                    , 91687.5, 92535, 91687.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-86185, sellCostBuyPrice =sellCostBuyPrice-91385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-92535, sellCostMeanBuyPrice = sellCostMeanBuyPrice-91687.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-92535, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-91687.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 86185, 91385, 92535
                    , 91687.5, 92535, 91687.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-86185, netSellCostBuyPrice = netSellCostBuyPrice-91385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-92535
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-91687.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-92535
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-91687.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 17418 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 17418 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
CALL clientInUse(414,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-09 00:05:20', '06664c790ece27', '414', '0.00', '85035', '5600', '1', '90635', '85035', '0', '85035', '1', '2024-06-09 00:05:20', '', '1', '0', 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', '1', '1', '3', '0', 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', '224', '17418', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00');
UPDATE client SET  clientdebt = '85035', userid = '1' WHERE clientid = '414';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('414','0.00','85035','0','اضافة فاتورة مبيعات (معدله)','17450', '85035', '2024-06-10 01:15:03', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '85035', '0', null, '0', null, null,'', '0','1','1','1','1');
UPDATE client SET  inUse = 0 where clientid = 414;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01749', '17450', '1', '1749', '21.00', '430.00', '9030', '0', '', '0', '2024-06-10 01:15:03', '1749', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 422.50, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 422.50
                where sellbilldetailid = 51717;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-06-10', 9030, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 21, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+21
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9030, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '69', userid = '1', storedetaildate = '2024-06-10 01:15:03' WHERE storedetailid = '6283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '21', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '90.00', '69', '1', '2024-06-10 01:15:03','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01783', '17450', '1', '1783', '20', '430', '8600', '0', '', '0', '2024-06-10 01:15:03', '1783', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51718;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1783, '2024-06-10', 8600, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8600, sellCostBuyPrice =sellCostBuyPrice+8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8600, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8600, sellCostBuyPrice =sellCostBuyPrice+8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 01:15:04' WHERE storedetailid = '6404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1783', '1', '20', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '20.00', '0', '1', '2024-06-10 01:15:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('360','01785', '17450', '1', '1785', '31', '360', '11160', '0', '', '0', '2024-06-10 01:15:04', '1785', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 51719;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-06-10', 11160, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 31, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11160, sellCostBuyPrice =sellCostBuyPrice+11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+31
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11160, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11160, sellCostBuyPrice =sellCostBuyPrice+11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '106', userid = '1', storedetaildate = '2024-06-10 01:15:04' WHERE storedetailid = '6406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '1', '31', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '137.00', '106', '1', '2024-06-10 01:15:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17450', '1', '1770', '20.00', '350.00', '7000', '0', '', '0', '2024-06-10 01:15:04', '1770', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51720;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '72', userid = '1', storedetaildate = '2024-06-10 01:15:04' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '20', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '92.00', '72', '1', '2024-06-10 01:15:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('380','01782', '17450', '1', '1782', '23', '380', '8740', '0', '', '0', '2024-06-10 01:15:04', '1782', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 51721;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1782, '2024-06-10', 8740, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 23, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8740, sellCostBuyPrice =sellCostBuyPrice+8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+23
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8740, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8740, sellCostBuyPrice =sellCostBuyPrice+8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 01:15:04' WHERE storedetailid = '6403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1782', '1', '23', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '23.00', '0', '1', '2024-06-10 01:15:04','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01784', '17450', '1', '1784', '25', '475', '11875', '0', '', '0', '2024-06-10 01:15:04', '1784', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51722;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1784, '2024-06-10', 11875, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 25, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11875, sellCostBuyPrice =sellCostBuyPrice+11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+25
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11875, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11875, sellCostBuyPrice =sellCostBuyPrice+11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2024-06-10 01:15:05' WHERE storedetailid = '6405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1784', '1', '25', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '55.00', '30', '1', '2024-06-10 01:15:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01761', '17450', '1', '1761', '20.00', '350.00', '7000', '0', '', '0', '2024-06-10 01:15:05', '1761', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51723;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-06-10 01:15:05' WHERE storedetailid = '6340';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '1', '20', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '44.00', '24', '1', '2024-06-10 01:15:05','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17450', '1', '1581', '20.00', '450.00', '9000', '0', '', '0', '2024-06-10 01:15:05', '1581', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51724;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 9000, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9000, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-39', userid = '1', storedetaildate = '2024-06-10 01:15:05' WHERE storedetailid = '5618';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '20', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-19.00', '-39', '1', '2024-06-10 01:15:06','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 19169;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('456.52','01642', '17450', '1', '1642', '23.00', '400', '9200', '0', '', '0', '2024-06-10 01:15:06', '1642', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','19169-3,');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51725;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1642, '2024-06-10', 9200, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 23, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9200, sellCostBuyPrice =sellCostBuyPrice+10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+23
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9200, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9200, sellCostBuyPrice =sellCostBuyPrice+10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 01:15:06' WHERE storedetailid = '5966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '1', '23', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '23.00', '0', '1', '2024-06-10 01:15:06','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01781', '17450', '1', '1781', '21.00', '430.00', '9030', '0', '', '0', '2024-06-10 01:15:06', '1781', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51726;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1781, '2024-06-10', 9030, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 21, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+21
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9030, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '88', userid = '1', storedetaildate = '2024-06-10 01:15:06' WHERE storedetailid = '6402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '21', '1', '17450', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '109.00', '88', '1', '2024-06-10 01:15:07','0','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '85035', '85035', '2024-06-10', '1', '0', '0', '2024-06-10 01:15:07','تم اضافة فاتورة مبيعات ( اجل )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10483', '484', '85035', '','0');
UPDATE accountstree SET name = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', customName = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-08', itemtype2 = '1', theValue = '85035', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '484';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10483', '16', '85035', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '501538', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
UPDATE sellbill SET sellbilldate = '2024-06-09 00:05:20', sellbillserial = '06664c790ece27', sellbillclientid = '414', sellbilltotaldeptbefor = '0.00', sellbilltotaldeptafter = '85035.00', sellbilldiscount = '5600', sellbilldiscounttype = '1', sellbilltotalbill = '90635.00', sellbillaftertotalbill = '85035.00', sellbilltotalpayed = '0.00', sellbillfinalbill = '85035.00', sellbillstoreid = '1', sellbillsysdate = '2024-06-09 00:05:20',comment = '', userid = '1', conditions = '0', sellbillclientname = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', sellbillsaveid = '1', sellbildirectpayment = '1', billnameid = '3', sellerid = '0', tempclientName = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', sellQuantity = '224.00' , dailyentryid = '10483',obygyVisitId = '0',onlineOrderId = '0',delbyuserid = '1',delivery = '0',totalafterdelivery = '85035',billReservation='0',billReservationDate='0000-00-00',visaAccountId = '0',cashPayed = '0',visaPayed = '0',isBankAccountTransfer = '0',extraDiscountPer='0',extraDiscountVal='0',taxOfDiscountPer='0',taxOfDiscountVal='0',taxBillNumber='0',collectionType = '0',collectionDate='0000-00-00' WHERE sellbillid = '17450';
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+85035, sellCostBuyPrice =sellCostBuyPrice+91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (414, '2024-06-10', 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+85035, sellCostBuyPrice =sellCostBuyPrice+91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+85035, netSellCostBuyPrice = netSellCostBuyPrice+91785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+92935
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+92202.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+92935
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+92202.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 17418 and newid=17450 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:45:07";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:15:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:15:07', '1', 'editprint', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 21:53:36";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:23:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 01:23:37', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:02:37";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:32:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 01:32:37', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:02:42";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:32:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:32:43', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:04:47";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:34:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 01:34:48', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:05:00";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:35:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 01:35:01', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE product SET productName = 'W 03', productDescription = '', productCatId = '1', productBuyPrice = '280', productSellAllPrice = '210.00', productSellUnitPrice = '250.00', productSellHalfPrice = '230.00', productDate = '2022-05-09', conditions = '0', userId = '1', limitamount = '0', parcode = '01014',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '248.75',meanbuyprice_withDiscount = '248.75' , productbuypricereal = '210.00' , buypricereal_precentage = '5.00' , buytotal_precentage = '5.00' , buyhalf_precentage = '15.00' , buypart_precentage = '25.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1014';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1014, 1,'2024-06-10 01:35:27',1)
                ON DUPLICATE KEY UPDATE productid = 1014, edited = 1, sysdate = '2024-06-10 01:35:27', userid = 1;
UPDATE product SET productName = 'W 03', productDescription = '', productCatId = '1', productBuyPrice = '280.00', productSellAllPrice = '280', productSellUnitPrice = '280', productSellHalfPrice = '280', productDate = '2022-05-09', conditions = '0', userId = '1', limitamount = '0', parcode = '01014',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '248.75',meanbuyprice_withDiscount = '248.75' , productbuypricereal = '210.00' , buypricereal_precentage = '5.00' , buytotal_precentage = '5.00' , buyhalf_precentage = '15.00' , buypart_precentage = '25.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1014';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1014, 1,'2024-06-10 01:35:36',1)
                ON DUPLICATE KEY UPDATE productid = 1014, edited = 1, sysdate = '2024-06-10 01:35:36', userid = 1;
UPDATE product SET productName = 'W 03', productDescription = '', productCatId = '1', productBuyPrice = '280.00', productSellAllPrice = '280.00', productSellUnitPrice = '280.00', productSellHalfPrice = '290', productDate = '2022-05-09', conditions = '0', userId = '1', limitamount = '0', parcode = '01014',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '248.75',meanbuyprice_withDiscount = '248.75' , productbuypricereal = '210.00' , buypricereal_precentage = '5.00' , buytotal_precentage = '5.00' , buyhalf_precentage = '15.00' , buypart_precentage = '25.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1014';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1014, 1,'2024-06-10 01:35:42',1)
                ON DUPLICATE KEY UPDATE productid = 1014, edited = 1, sysdate = '2024-06-10 01:35:42', userid = 1;
UPDATE product SET productName = 'W 03', productDescription = '', productCatId = '1', productBuyPrice = '280.00', productSellAllPrice = '280.00', productSellUnitPrice = '360', productSellHalfPrice = '290.00', productDate = '2022-05-09', conditions = '0', userId = '1', limitamount = '0', parcode = '01014',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '235.00',lastbuyprice_withDiscount = '235',meanbuyprice = '248.75',meanbuyprice_withDiscount = '248.75' , productbuypricereal = '210.00' , buypricereal_precentage = '5.00' , buytotal_precentage = '5.00' , buyhalf_precentage = '15.00' , buypart_precentage = '25.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1014';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1014, 1,'2024-06-10 01:35:53',1)
                ON DUPLICATE KEY UPDATE productid = 1014, edited = 1, sysdate = '2024-06-10 01:35:53', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:07:19";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:37:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:37:19', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:16:28";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:46:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 01:46:28', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '390.00', productSellUnitPrice = '470.00', productSellHalfPrice = '400.00', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '366.32',meanbuyprice_withDiscount = '366.32' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 01:46:40',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 01:46:40', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '366.32',meanbuyprice_withDiscount = '366.32' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 01:46:50',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 01:46:50', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '366.32',meanbuyprice_withDiscount = '366.32' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 01:46:55',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 01:46:55', userid = 1;
UPDATE product SET productName = 'ص 13', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '500', productSellHalfPrice = '440.00', productDate = '2024-03-13', conditions = '0', userId = '1', limitamount = '0', parcode = '01634',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '366.32',meanbuyprice_withDiscount = '366.32' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '11.63',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1634';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1634, 1,'2024-06-10 01:47:09',1)
                ON DUPLICATE KEY UPDATE productid = 1634, edited = 1, sysdate = '2024-06-10 01:47:09', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:19:45";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:49:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:49:45', '1', 'addAndRetuen', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066662d8b27aeb
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(403,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 01:32:43', '066662d8b27aeb', '403', '46695.00', '11435', '2550', '1', '37810', '35260', '0', '-35260', '1', '2024-06-10 01:49:45', '', '1', '0', 'سنتر محمد فاروق','1', '1', '5', '0', 'سنتر محمد فاروق', '102', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '11435', userid = '1' WHERE clientid = '403';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('403','46695.00','35260','1','اضافة فاتورة مردوات مبيعات','5923', '11435', '2024-06-10 01:49:45', '1', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '35260', '0', null, '0', null, null,'', '0','1','1','35260','1');
UPDATE client SET  inUse = 0 where clientid = 403;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('400.00', '00945', '5923', '1', '945', '20', '280.00', '5600', '0', '', '0', '0', '945', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 200.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 200.00, meanbuyprice_withDiscount = 300.00
                where returnsellbilldetailid = 12787;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (945, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 5977.6778629992, 8000, 4000, 6000
                    , 4000, 6000, 0, 0, 20)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+5977.6778629992, returnSellCostBuyPrice = returnSellCostBuyPrice+8000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6000
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+20;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 5977.6778629992, 8000, 4000, 6000
                    , 4000, 6000, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+5977.6778629992, returnSellCostBuyPrice = returnSellCostBuyPrice+8000, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4000
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6000, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4000
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6000
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '2999';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('945', '1', '20', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '20', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('280.00', '01014', '5923', '1', '1014', '7', '280.00', '1960', '0', '', '0', '0', '1014', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 235.00 , meanbuyprice = 248.75, lastbuyprice_withDiscount = 235.00, meanbuyprice_withDiscount = 248.75
                where returnsellbilldetailid = 12788;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1014, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2092.1872520497, 1960, 1645, 1741.25
                    , 1645, 1741.25, 0, 0, 7)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+2092.1872520497, returnSellCostBuyPrice = returnSellCostBuyPrice+1960, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1645
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1741.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1645
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1741.25
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+7;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2092.1872520497, 1960, 1645, 1741.25
                    , 1645, 1741.25, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+2092.1872520497, returnSellCostBuyPrice = returnSellCostBuyPrice+1960, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1645
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1741.25, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1645
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1741.25
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '3485';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1014', '1', '7', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '7', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('410.00', '01679', '5923', '1', '1679', '5', '410.00', '2050', '0', '', '0', '0', '1679', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where returnsellbilldetailid = 12789;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1679, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2188.2570748479, 2050, 2050, 2050
                    , 2050, 2050, 0, 0, 5)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+2188.2570748479, returnSellCostBuyPrice = returnSellCostBuyPrice+2050, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2050
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2050, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2050
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2050
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+5;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 2188.2570748479, 2050, 2050, 2050
                    , 2050, 2050, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+2188.2570748479, returnSellCostBuyPrice = returnSellCostBuyPrice+2050, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+2050
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+2050, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+2050
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+2050
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '6090';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1679', '1', '5', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '10.00', '15', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('440.00', '01578', '5923', '1', '1578', '14', '440.00', '6160', '0', '', '0', '0', '1578', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
                where returnsellbilldetailid = 12790;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1578, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 6575.4456492991, 6160, 6160, 6160
                    , 6160, 6160, 0, 0, 14)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+6575.4456492991, returnSellCostBuyPrice = returnSellCostBuyPrice+6160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+6160
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6160, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+6160
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6160
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+14;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 6575.4456492991, 6160, 6160, 6160
                    , 6160, 6160, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+6575.4456492991, returnSellCostBuyPrice = returnSellCostBuyPrice+6160, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+6160
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6160, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+6160
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6160
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '5615';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '1', '14', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '2.00', '16', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01635', '5923', '1', '1635', '10', '430.00', '4300', '0', '', '0', '0', '1635', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 12791;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1635, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4590.002644803, 4300, 4300, 4300
                    , 4300, 4300, 0, 0, 10)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4590.002644803, returnSellCostBuyPrice = returnSellCostBuyPrice+4300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+10;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4590.002644803, 4300, 4300, 4300
                    , 4300, 4300, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4590.002644803, returnSellCostBuyPrice = returnSellCostBuyPrice+4300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4300
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '5951';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '1', '10', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '13.00', '23', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('280.00', '01709', '5923', '1', '1709', '15', '280', '4200', '0', '', '0', '0', '1709', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 280.00 , meanbuyprice = 280.00, lastbuyprice_withDiscount = 280.00, meanbuyprice_withDiscount = 280.00
                where returnsellbilldetailid = 12792;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1709, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4483.2583972494, 4200, 4200, 4200
                    , 4200, 4200, 0, 0, 15)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4483.2583972494, returnSellCostBuyPrice = returnSellCostBuyPrice+4200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+15;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4483.2583972494, 4200, 4200, 4200
                    , 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4483.2583972494, returnSellCostBuyPrice = returnSellCostBuyPrice+4200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '6179';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1709', '1', '15', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '15', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01634', '5923', '1', '1634', '18', '430.00', '7740', '0', '', '0', '0', '1634', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 366.32, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 366.32
                where returnsellbilldetailid = 12793;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1634, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 8262.0047606453, 7740, 18, 6593.76
                    , 18, 6593.76, 0, 0, 18)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+8262.0047606453, returnSellCostBuyPrice = returnSellCostBuyPrice+7740, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+18
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6593.76, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+18
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6593.76
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+18;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 8262.0047606453, 7740, 18, 6593.76
                    , 18, 6593.76, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+8262.0047606453, returnSellCostBuyPrice = returnSellCostBuyPrice+7740, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+18
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+6593.76, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+18
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+6593.76
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '171', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '5933';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '1', '18', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '153.00', '171', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('460.00', '01660', '5923', '1', '1660', '9', '460.00', '4140', '0', '', '0', '0', '1660', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
                where returnsellbilldetailid = 12794;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1660, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4419.2118487173, 4140, 4140, 4140
                    , 4140, 4140, 0, 0, 9)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4419.2118487173, returnSellCostBuyPrice = returnSellCostBuyPrice+4140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4140
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+9;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 4419.2118487173, 4140, 4140, 4140
                    , 4140, 4140, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+4419.2118487173, returnSellCostBuyPrice = returnSellCostBuyPrice+4140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+4140
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+4140, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+4140
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+4140
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '6040';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1660', '1', '9', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '9', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('400.00', '01661', '5923', '1', '1661', '3', '400.00', '1200', '0', '', '0', '0', '1661', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where returnsellbilldetailid = 12795;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1661, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1280.9309706427, 1200, 1200, 1200
                    , 1200, 1200, 0, 0, 3)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+1280.9309706427, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+3;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1280.9309706427, 1200, 1200, 1200
                    , 1200, 1200, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+1280.9309706427, returnSellCostBuyPrice = returnSellCostBuyPrice+1200, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1200, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1200
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '6041';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '1', '3', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-5.00', '-2', '1', '2024-06-10 01:49:45','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('460.00', '01681', '5923', '1', '1681', '1', '460.00', '460', '0', '', '0', '0', '1681', '0.00', '0','1','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
                where returnsellbilldetailid = 12796;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1681, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 491.02353874636, 460, 460, 460
                    , 460, 460, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+491.02353874636, returnSellCostBuyPrice = returnSellCostBuyPrice+460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+460
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+460, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+460
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+460
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 491.02353874636, 460, 460, 460
                    , 460, 460, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+491.02353874636, returnSellCostBuyPrice = returnSellCostBuyPrice+460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+460
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+460, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+460
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+460
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 01:49:45' WHERE storedetailid = '6092';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '1', '1', '0', '5923', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-1.00', '0', '1', '2024-06-10 01:49:45','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 35260, 40210, 28173, 36845.01
                    , 28173, 36845.01, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+35260, returnSellCostBuyPrice = returnSellCostBuyPrice+40210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+28173
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+36845.01, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+28173
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+36845.01
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (403, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 35260, 40210, 28173, 36845.01
                    , 28173, 36845.01, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+35260, returnSellCostBuyPrice = returnSellCostBuyPrice+40210, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+28173
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+36845.01, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+28173
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+36845.01
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -35260, -40210, -28173
                    , -36845.01, -28173, -36845.01, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-35260, netSellCostBuyPrice = netSellCostBuyPrice+-40210
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-28173
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-36845.01
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-28173
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-36845.01
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066662d8b27aeb and sellbillId = 5923 and returnsellbillId = 5923
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:19:46";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:49:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 01:49:46', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:26:37";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:56:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:56:37', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:27:54";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:57:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:57:54', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2112,1,8,1781,1,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 01:57:55',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '87', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, -1, 0, 0, 1, '2024-06-10 01:57:55')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:57:55' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-06-10*430.00," WHERE transferproductid = 8815;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '1', '1', '8815', 'تحويل منتجات من المخزن', 'storemovementController.php', '88.00', '87', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1781', '8', '1', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 8, 1781, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-06-10 01:57:55')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:57:55' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '8', '1', '0', '8815', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '1', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '1581', '12', '2024-06-10', '1', '0','2112',null,null,'2024-06-10 01:57:55',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-51', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1581, 0, 0
                    , 450.00, -12, 0, 0, 1, '2024-06-10 01:57:55')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:57:55' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-06-10*450.00," WHERE transferproductid = 8816;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '1', '8816', 'تحويل منتجات من المخزن', 'storemovementController.php', '-39.00', '-51', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5768';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 8, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 01:57:55')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:57:55' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '8', '12', '0', '8816', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '24.00', '36', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:27:55";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:57:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:57:55', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:28:24";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:58:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:58:24', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:28:46";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:58:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:58:47', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2113,8,1,1781,1,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 01:58:47',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6407';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 8, 1781, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-06-10 01:58:47')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:58:47' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-06-10*430.00," WHERE transferproductid = 8817;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '8', '1', '1', '8817', 'تحويل منتجات من المخزن', 'storemovementController.php', '1.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '88', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-06-10 01:58:47')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:58:47' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '1', '0', '8817', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '87.00', '88', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('8', '1', '1581', '12', '2024-06-10', '1', '0','2113',null,null,'2024-06-10 01:58:47',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5768';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-25', 8, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 01:58:47')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-12, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:58:47' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-04-25*450.00," WHERE transferproductid = 8818;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '8', '12', '1', '8818', 'تحويل منتجات من المخزن', 'storemovementController.php', '36.00', '24', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '-39', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-25', 1, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 01:58:47')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:58:47' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '0', '8818', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '-51.00', '-39', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:28:47";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:58:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:58:47', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:28:58";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:58:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:58:58', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:28:58";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:58:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:58:58', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:29:27";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:59:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:59:27', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2114,1,8,1781,22,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 01:59:27',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '66', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, -22, 0, 0, 1, '2024-06-10 01:59:27')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:59:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-06-10*430.00," WHERE transferproductid = 8819;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '22', '1', '8819', 'تحويل منتجات من المخزن', 'storemovementController.php', '88.00', '66', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6407';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 8, 1781, 0, 0
                    , 430.00, 22, 0, 0, 1, '2024-06-10 01:59:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:59:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '8', '22', '0', '8819', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '22', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '1581', '12', '2024-06-10', '1', '0','2114',null,null,'2024-06-10 01:59:27',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-51', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1581, 0, 0
                    , 450.00, -12, 0, 0, 1, '2024-06-10 01:59:27')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:59:27' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-06-10*450.00," WHERE transferproductid = 8820;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '1', '8820', 'تحويل منتجات من المخزن', 'storemovementController.php', '-39.00', '-51', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5768';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 8, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 01:59:27')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 01:59:27' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '8', '12', '0', '8820', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '24.00', '36', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:29:27";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 01:59:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 01:59:28', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:30:11";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 02:00:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 02:00:11', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:30:11";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 02:00:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 02:00:11', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:31:47";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 02:01:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 02:01:47', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2115,1,7,1781,20,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 02:01:48',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '46', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, -20, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-06-10*430.00," WHERE transferproductid = 8821;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '20', '1', '8821', 'تحويل منتجات من المخزن', 'storemovementController.php', '66.00', '46', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1781', '7', '20', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 7, 1781, 0, 0
                    , 430.00, 20, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '7', '20', '0', '8821', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1577', '15', '2024-06-10', '1', '0','2115',null,null,'2024-06-10 02:01:48',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '89', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5614';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1577, 0, 0
                    , 450.00, -15, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-06-10*450.00," WHERE transferproductid = 8822;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '1', '15', '1', '8822', 'تحويل منتجات من المخزن', 'storemovementController.php', '104.00', '89', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6160';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 7, 1577, 0, 0
                    , 450.00, 15, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '7', '15', '0', '8822', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '2.00', '17', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1583', '26', '2024-06-10', '1', '0','2115',null,null,'2024-06-10 02:01:48',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '121', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5620';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1583, 0, 0
                    , 370.00, -26, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyprice = 370.00,
                        buyQuantity =buyQuantity+-26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2024-06-10*370.00," WHERE transferproductid = 8823;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '1', '26', '1', '8823', 'تحويل منتجات من المخزن', 'storemovementController.php', '147.00', '121', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1583', '7', '26', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 7, 1583, 0, 0
                    , 370.00, 26, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '7', '26', '0', '8823', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '26', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1581', '12', '2024-06-10', '1', '0','2115',null,null,'2024-06-10 02:01:48',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-63', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1581, 0, 0
                    , 450.00, -12, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-06-10*450.00," WHERE transferproductid = 8824;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '1', '8824', 'تحويل منتجات من المخزن', 'storemovementController.php', '-51.00', '-63', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '33', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5745';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 7, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 02:01:48')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 02:01:48' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '7', '12', '0', '8824', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '21.00', '33', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-09 22:31:48";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 02:01:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 02:01:48', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:23:45";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:23:50";
UPDATE user SET loginip = "197.35.219.98", lastactivetime = "2024-06-10 09:53:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 09:53:50', '4', '', '197.35.219.98', '', 'DESKTOP');
UPDATE programsettings SET companyname = 'GT4', address = 'المنصورة', specializtion = 'jh', phone = '01002019235', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '471502e62c0be89a8d90663028144a83.jpg', roundnumbers = '0', saveprinting = '1', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-06-10',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE programsettings SET companyname = 'GT4', address = 'المنصورة', specializtion = 'jh', phone = '01002019235', faxnumber = '0502232923', email = 'mrabozied@gt4it.com', website = 'www.gt4host.com', logo = '471502e62c0be89a8d90663028144a83.jpg', roundnumbers = '0', saveprinting = '1', deptprinting = '0', printingpapersize = '0', userid = '1', showPreviousPrice = '0', parcode = '0', priceing = '0', lastprice = '0', searchvalue = '1', updateproductprice = '0', allowfinsldelete = '0', updateclientprice = '0', `partition` = '0', taxcard = '332', commercialregistration = '3213123312', costcenter = '1', clinic = '1', workshop = '1', transport = '1', manufacturing = '0', masterCopy = '0' , dailyentrydate = '2020-04-18' ,updatefiledate = '2024-06-10',workerbetweenstores = '1',workshoptimeout = '24',drivertimeout = '3',currancy = 'جنيه',serial='9c2d4cf4cf5d4e24d5070164705832c3a5d1287f641a2960e48e04ae57a2ad0a5441322ca7cf34efd63003fdb348adbd0b61197c7c87d8dd5bc298c352482bc6',allowdateedit = '0', clientcode = '1' ,clientserial = '1',timezone = 'Africa/Cairo' , expiredate ='1' , production ='1' , description='1' , service ='1' , date='1' , limitamount = '0' , measuringunit = '1' , print_amount = '0' , billid = '0' , precentages = '1' , realprice = '1' ,delegate_seller = '0' , storeserial = '1' ,clientfieldrequired ='0' , clientcodname='0' , colortype = '0' , nakdyOnly = '0' , nakdyKashf = '0' , discount_pres_direct = '0' , general_discount = '0' , sells_return = '0' ,scunitname ='0',vatValue = '0.00',syncstructure = '1',showPrevPrices = '0',isOpticProg='1',reportsPlusHours = '2' , showM5zon = '1',restaurantStoreId = '1',restuarantPrintTimeout = '8',sumSameProductForStore = '0', editAllPrice = '1', isCafe = '0' ,isRestaurent = '0' ,productDays = '0',thereIsRestTax = '0',restTaxVal = '0',restPrintLang = '0',taxNameFlag = '0',parcodeDigits = '5' ,specializedParcodeDigits = '7', clientDefaultDebtLimit = '10000' , clientDefaultDebtLimitControl = '0',usedParcode = '0' ,productbycodeimage = '' ,commentClient='تعليق على العميل ',Inventoryevaluation='first',Profitevaluation='first' , delivery='-2',premiums = '0',operationnumEdit = '0',noOfDecimalPlaces = '2',unReviewBills = '0', unReviewBillsPass = '123',billReviewNote = '',tamweenBakery = '0',three_months = '0',six_months = '0',twelve_months = '0',eighteen_months = '0',twentyfour_months = '0',thirty_months = '0',sixthirty_months = '0',fortytwo_months = '0',fortyeight_months = '0',mandobCollectionRatio='0',takeAwayClient = '0',restaurantServiceOn = ',-2,-1,1,',earlyrepayment = '0',visaPay = '0',headerPrint='',headerPrintSand='',printSand='0',makeDailyEntry='0',clientShowTawla='0',billRest='1',suppIsClientToo='0',isCarBill='0',expensesproduct='1',projectshownew='1',showparcode='0',changeBuyPriceChangeSellInBuyBillCtrl = '0',changeBuyPriceChangeSellInProductCtrl = '0',inventoryvaluation = '1',showBillCollectionSearch='0' WHERE programsettingsid = '1';
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:23:54";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:24:22";
UPDATE user SET loginip = "197.35.219.98", lastactivetime = "2024-06-10 09:54:22", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 09:54:22', '4', 'addsellBill', '197.35.219.98', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:37:32";
UPDATE user SET loginip = "197.32.255.184", lastactivetime = "2024-06-10 10:07:32", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 10:07:32', '3', '', '197.32.255.184', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:37:32";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 06:37:36";
UPDATE user SET loginip = "197.32.255.184", lastactivetime = "2024-06-10 10:07:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 10:07:36', '3', 'addsellBill', '197.32.255.184', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 09:21:31";
UPDATE user SET loginip = "154.183.51.243", lastactivetime = "2024-06-10 12:51:31", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 12:51:32', '8', '', '154.183.51.243', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 09:21:36";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 09:21:44";
UPDATE user SET loginip = "154.183.51.243", lastactivetime = "2024-06-10 12:51:44", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 12:51:44', '8', 'addsellBill', '154.183.51.243', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 09:32:58";
UPDATE user SET loginip = "154.183.51.243", lastactivetime = "2024-06-10 13:02:59", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 13:02:59', '8', 'addsellBill', '154.183.51.243', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 10:26:40";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 10:27:00";
UPDATE user SET loginip = "197.192.234.25", lastactivetime = "2024-06-10 13:57:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 13:57:01', '7', '', '197.192.234.25', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 10:27:02";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 10:27:49";
UPDATE user SET loginip = "197.192.234.25", lastactivetime = "2024-06-10 13:57:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 13:57:50', '7', 'addsellBill', '197.192.234.25', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:01:39";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 14:31:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 14:31:40', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:01:41";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:14:26";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 14:44:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 14:44:27', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:14:27";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:36:28";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:06:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:06:28', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:36:30";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:06:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:06:30', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:36:50";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:06:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:06:51', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:39:56";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:09:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:09:56', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:41:20";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:11:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:11:20', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =25840
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '67545' , clientdate = '2024-06-10 15:11:20', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('401','72545.00','5000','1','ايصال تحصيل (( قبض من عميل ))','25840', '67545', '2024-06-10 15:09:56', '1', 'clientPayedDeptController.php', '   ليد الشيخ عبد اللطيف 28/5/2024', '5000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '404870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('399870.00','5000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '25840', '404870', '2024-06-10 15:11:22', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000', '5000', '2024-06-10', '1', '0', '0', '2024-06-10 15:11:22','اضافة ايصال سداد للعميل سنتر النهار','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10484', '54', '5000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '212564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10484', '472', '5000', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-47000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
UPDATE clientdebtchange SET clientid = '401', clientdebtchangebefore = '72545.00', clientdebtchangeamount = '5000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '25840', clientdebtchangeafter = '67545.00', clientdebtchangedate = '2024-06-10 15:09:56', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ليد الشيخ عبد اللطيف 28/5/2024', totalOperationCost = '5000.00',discount='', reciptid=null, dailyentryid = '10484',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '25840';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =25840 -clientdebtchangeId = 25840
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:41:24";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:11:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:11:24', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:41:27";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:11:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:11:29', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:41:29";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:11:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:11:29', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:42:14";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:12:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:12:16', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =25841
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '62545' , clientdate = '2024-06-10 15:12:16', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('401','67545.00','5000','1','ايصال تحصيل (( قبض من عميل ))','25841', '62545', '2024-06-10 15:11:29', '1', 'clientPayedDeptController.php', '   ليد الشيخ عبد اللطيف 5/6/2024', '5000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '409870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('404870.00','5000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '25841', '409870', '2024-06-10 15:12:16', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000', '5000', '2024-06-10', '1', '0', '0', '2024-06-10 15:12:16','اضافة ايصال سداد للعميل سنتر النهار','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10485', '54', '5000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '217564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10485', '472', '5000', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-52000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
UPDATE clientdebtchange SET clientid = '401', clientdebtchangebefore = '67545.00', clientdebtchangeamount = '5000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '25841', clientdebtchangeafter = '62545.00', clientdebtchangedate = '2024-06-10 15:11:29', userid = '1', tablename = 'clientPayedDeptController.php', comment = '   ليد الشيخ عبد اللطيف 5/6/2024', totalOperationCost = '5000.00',discount='', reciptid=null, dailyentryid = '10485',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '25841';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =25841 -clientdebtchangeId = 25841
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:42:17";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:12:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:12:18', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:42:21";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:12:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:12:21', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:42:26";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:12:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:12:29', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:42:36";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:12:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:12:37', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:43:39";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:13:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:13:39', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:43:52";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:13:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:13:53', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:44:09";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:14:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:14:12', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 11:44:24";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:14:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:14:25', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:04:32";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:34:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:34:32', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:04:38";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:34:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:34:39', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:05:30";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:35:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:35:30', '1', 'remove', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete - with clientdebtchangeId =25840
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '67545', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
UPDATE clientdebtchange SET del='1' WHERE clientdebtchangeid = '25840';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid, del,dailyentryid , num , billid ,paytype,seller,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('401','62545.00','5000.00','0','الغاء سداد ديون عميل','25840', '67545', '2024-06-10 15:35:31', '1', 'clientPayedDeptController.php', '', '5000', '0', null, '1', '10484', null, null,'','0','1','1','1','1');
UPDATE save SET  savecurrentvalue = '404870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('409870.00','5000', '1', '1', 'الغاء سداد ديون عميل', '25842', '404870', '2024-06-10 15:35:31', '1',  'clientPayedDeptController.php','0','');
UPDATE dailyentry SET totalcreditor = '5000.00', totaldebtor = '5000.00', thedate = '2024-06-10', userid = '1', `condition` = '0', reverseofid = '-10', dDateTime = '2024-06-10 15:11:22', entryComment = 'اضافة ايصال سداد للعميل سنتر النهار', fromFlag = '1',related='0' WHERE id = '10484';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000.00', '5000.00', '2024-06-10', '1', '0', '10484', '2024-06-10 15:35:31','تم عكس القيد رقم 10484 ','1','0','0');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10486', '54', '5000.00', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '212564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10486', '472', '5000.00', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-47000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete end - with clientdebtchangeId =25840
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:05:32";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:35:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:35:33', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:05:35";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:35:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:35:35', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:05:42";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:35:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:35:43', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:06:05";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:36:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:36:07', '1', 'remove', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete - with clientdebtchangeId =25841
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '72545', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
UPDATE clientdebtchange SET del='1' WHERE clientdebtchangeid = '25841';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid, del,dailyentryid , num , billid ,paytype,seller,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('401','67545.00','5000.00','0','الغاء سداد ديون عميل','25841', '72545', '2024-06-10 15:36:08', '1', 'clientPayedDeptController.php', '', '5000', '0', null, '1', '10485', null, null,'','0','1','1','1','1');
UPDATE save SET  savecurrentvalue = '399870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('404870.00','5000', '1', '1', 'الغاء سداد ديون عميل', '25843', '399870', '2024-06-10 15:36:08', '1',  'clientPayedDeptController.php','0','');
UPDATE dailyentry SET totalcreditor = '5000.00', totaldebtor = '5000.00', thedate = '2024-06-10', userid = '1', `condition` = '0', reverseofid = '-10', dDateTime = '2024-06-10 15:12:16', entryComment = 'اضافة ايصال سداد للعميل سنتر النهار', fromFlag = '1',related='0' WHERE id = '10485';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000.00', '5000.00', '2024-06-10', '1', '0', '10485', '2024-06-10 15:36:08','تم عكس القيد رقم 10485 ','1','0','0');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10487', '54', '5000.00', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '207564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10487', '472', '5000.00', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-42000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController delete end - with clientdebtchangeId =25841
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:06:09";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:36:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:36:09', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:06:12";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:36:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:36:13', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:06:15";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:36:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:36:15', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:08:21";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:38:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:38:21', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =25844
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '67545' , clientdate = '2024-06-10 15:38:21', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('401','72545.00','5000','1','ايصال تحصيل (( قبض من عميل ))','25844', '67545', '2024-05-28  15:35:16', '1', 'clientPayedDeptController.php', '  ليد الشيخ عبد اللطيف ', '5000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '404870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('399870.00','5000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '25844', '404870', '2024-06-10 15:38:21', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000', '5000', '2024-06-10', '1', '0', '0', '2024-06-10 15:38:22','اضافة ايصال سداد للعميل سنتر النهار','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10488', '54', '5000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '212564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10488', '472', '5000', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-47000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
UPDATE clientdebtchange SET clientid = '401', clientdebtchangebefore = '72545.00', clientdebtchangeamount = '5000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '25844', clientdebtchangeafter = '67545.00', clientdebtchangedate = '2024-05-28 15:35:16', userid = '1', tablename = 'clientPayedDeptController.php', comment = '  ليد الشيخ عبد اللطيف ', totalOperationCost = '5000.00',discount='', reciptid=null, dailyentryid = '10488',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '25844';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =25844 -clientdebtchangeId = 25844
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:08:23";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:38:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:38:23', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:08:25";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:38:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:38:25', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:08:38";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:38:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:38:38', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:09:32";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:39:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:39:33', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add - with modelid =25845
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(401,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '62545' , clientdate = '2024-06-10 15:39:33', userid = '1' WHERE clientid = '401';
UPDATE client SET  inUse = 0 where clientid = 401;
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('401','67545.00','5000','1','ايصال تحصيل (( قبض من عميل ))','25845', '62545', '2024-06-05  15:35:39', '1', 'clientPayedDeptController.php', 'ليد الشيخ عبد اللطيف   ', '5000', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '409870',  userid = '1' WHERE saveid = '1';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('404870.00','5000', '0', '1', 'ايصال تحصيل (( قبض من عميل ))', '25845', '409870', '2024-06-10 15:39:34', '1',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5000', '5000', '2024-06-10', '1', '0', '0', '2024-06-10 15:39:34','اضافة ايصال سداد للعميل سنتر النهار','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10489', '54', '5000', '','0');
UPDATE accountstree SET name = 'الخزنة الرئيسية', customName = 'الخزنة الرئيسية', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2018-04-21', itemtype2 = '1', theValue = '217564', theOrder = '0', layingOrder = '1221',reportid = '2' WHERE id = '54';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10489', '472', '5000', '','0');
UPDATE accountstree SET name = 'سنتر النهار', customName = 'سنتر النهار', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-03-07', itemtype2 = '1', theValue = '-52000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '472';
UPDATE clientdebtchange SET clientid = '401', clientdebtchangebefore = '67545.00', clientdebtchangeamount = '5000.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '25845', clientdebtchangeafter = '62545.00', clientdebtchangedate = '2024-06-05 15:35:39', userid = '1', tablename = 'clientPayedDeptController.php', comment = 'ليد الشيخ عبد اللطيف   ', totalOperationCost = '5000.00',discount='', reciptid=null, dailyentryid = '10489',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '25845';
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- clientPayedDeptController add end - with modelid =25845 -clientdebtchangeId = 25845
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:09:34";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:39:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:39:35', '1', 'sucess', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:09:37";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:39:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-06-10 15:39:38', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:10:08";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:40:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:40:09', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:10:18";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:40:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:40:18', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:20:24";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:50:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:50:24', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:20:47";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:50:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 15:50:48', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:28:13";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 15:58:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 15:58:13', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 8;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:38:35";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:08:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:08:36', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:38:36";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:08:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:08:37', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:39:55";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:09:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:09:56', '1', 'addAndRetuen', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06666fad59a0b9
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(413,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 16:08:37', '06666fad59a0b9', '413', '15015.00', '19215', '0', '1', '4200', '4200', '0', '4200', '1', '2024-06-10 16:09:56', '', '1', '0', 'سنتر الفيروز', '1', '1', '3', '0', 'سنتر الفيروز', '12' ,'0','','','','','-1','0','0','0','0','0','4200','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '19215', userid = '1' WHERE clientid = '413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','15015.00','4200','0','اضافة فاتورة مبيعات','17451', '19215', '2024-06-10 16:09:56', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4200', '0', null, '0', null, null,'', '0','1','1','4200','1');
UPDATE client SET  inUse = 0 where clientid = 413;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17451', '1', '1770', '12', '350.00', '4200', '0', '', '0', '2024-06-10 16:09:57', '1770', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51727;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 12, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+12
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '60', userid = '1', storedetaildate = '2024-06-10 16:09:57' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '12', '1', '17451', 'اضافة فاتورة مبيعات', 'sellbillController.php', '72.00', '60', '1', '2024-06-10 16:09:57','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (413, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 4200, 4200, 4200
                    , 4200, 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4200, netSellCostBuyPrice = netSellCostBuyPrice+4200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06666fad59a0b9 and sellbillId = 17451 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:39:58";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:09:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:09:59', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:40:49";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:10:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:10:49', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:41:08";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:11:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:11:08', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:41:31";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:11:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:11:31', '1', 'editsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:42:04";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:12:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:12:04', '1', 'update', '156.210.101.227', '', 'DESKTOP');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 17451 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 17451 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 17451;
UPDATE sellbill SET  sellbillsysdate = '2024-06-10 16:12:04', userid = '1',delbyuserid = '1', conditions = '1'  WHERE sellbillid = '17451';
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51727;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,12,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-4200, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-12
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-4200, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '72', userid = '1', storedetaildate = '2024-06-10 16:12:05' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '12', '0', '17451', 'تعديل فاتورة مبيعات', 'sellbillController.php', '60.00', '72', '1', '2024-06-10 16:08:37','0','0');
CALL clientInUse(413,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '15015', userid = '1' WHERE clientid = '413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','19215.00','4200.00','1','تعديل فاتورة مبيعات','17451', '15015', '2024-06-10 16:08:37', '1', 'sellbillController.php', 'تعديل فاتورة مبيعات', '4200', '0', null, '0', null, null,'', '0','1','1','4200','1');
UPDATE client SET  inUse = 0 where clientid = 413;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-4200, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (413, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-4200, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 4200, 4200, 4200
                    , 4200, 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-4200, netSellCostBuyPrice = netSellCostBuyPrice-4200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-4200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-4200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-4200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-4200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 17451 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 17451 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
CALL clientInUse(413,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 16:08:37', '06666fad59a0b9', '413', '15015.00', '18915', '300', '1', '4200', '3900', '0', '3900', '1', '2024-06-10 16:08:37', '', '1', '0', 'سنتر الفيروز', '1', '1', '3', '0', 'سنتر الفيروز', '12', '17451', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00');
UPDATE client SET  clientdebt = '18915', userid = '1' WHERE clientid = '413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','15015.00','3900','0','اضافة فاتورة مبيعات (معدله)','17452', '18915', '2024-06-10 16:12:05', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '3900', '0', null, '0', null, null,'', '0','1','1','1','1');
UPDATE client SET  inUse = 0 where clientid = 413;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17452', '1', '1770', '12.00', '350.00', '4200', '0', '', '0', '2024-06-10 16:12:06', '1770', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51728;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 12, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+12
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '60', userid = '1', storedetaildate = '2024-06-10 16:12:07' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '12', '1', '17452', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '72.00', '60', '1', '2024-06-10 16:12:07','0','0');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '3900', '3900', '2024-06-10', '1', '0', '0', '2024-06-10 16:12:07','تم اضافة فاتورة مبيعات ( اجل )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10490', '483', '3900', '','0');
UPDATE accountstree SET name = 'سنتر الفيروز', customName = 'سنتر الفيروز', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-05', itemtype2 = '1', theValue = '-6100', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '483';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10490', '16', '3900', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '505438', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
UPDATE sellbill SET sellbilldate = '2024-06-10 16:08:37', sellbillserial = '06666fad59a0b9', sellbillclientid = '413', sellbilltotaldeptbefor = '15015.00', sellbilltotaldeptafter = '18915.00', sellbilldiscount = '300', sellbilldiscounttype = '1', sellbilltotalbill = '4200.00', sellbillaftertotalbill = '3900.00', sellbilltotalpayed = '0.00', sellbillfinalbill = '3900.00', sellbillstoreid = '1', sellbillsysdate = '2024-06-10 16:08:37',comment = '', userid = '1', conditions = '0', sellbillclientname = 'سنتر الفيروز', sellbillsaveid = '1', sellbildirectpayment = '1', billnameid = '3', sellerid = '0', tempclientName = 'سنتر الفيروز', sellQuantity = '12.00' , dailyentryid = '10490',obygyVisitId = '0',onlineOrderId = '0',delbyuserid = '1',delivery = '0',totalafterdelivery = '3900',billReservation='0',billReservationDate='0000-00-00',visaAccountId = '0',cashPayed = '0',visaPayed = '0',isBankAccountTransfer = '0',extraDiscountPer='0',extraDiscountVal='0',taxOfDiscountPer='0',taxOfDiscountVal='0',taxBillNumber='0',collectionType = '0',collectionDate='0000-00-00' WHERE sellbillid = '17452';
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3900, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (413, '2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3900, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 3900, 4200, 4200
                    , 4200, 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3900, netSellCostBuyPrice = netSellCostBuyPrice+4200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 17451 and newid=17452 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:42:09";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:12:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:12:09', '1', 'editprint', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:42:32";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:12:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:12:32', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:42:40";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:12:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:12:40', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:44:32";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:14:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:14:33', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:45:02";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:15:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:15:03', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:45:24";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:15:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:15:24', '1', 'editsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:45:53";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:15:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:15:54', '1', 'update', '156.210.101.227', '', 'DESKTOP');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 17452 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 17452 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 17452;
UPDATE sellbill SET  sellbillsysdate = '2024-06-10 16:15:54', userid = '1',delbyuserid = '1', conditions = '1'  WHERE sellbillid = '17452';
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51728;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,12,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3900, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-12
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3900, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '72', userid = '1', storedetaildate = '2024-06-10 16:15:54' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '12', '0', '17452', 'تعديل فاتورة مبيعات', 'sellbillController.php', '60.00', '72', '1', '2024-06-10 16:08:37','0','0');
CALL clientInUse(413,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '15015', userid = '1' WHERE clientid = '413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','18915.00','3900.00','1','تعديل فاتورة مبيعات','17452', '15015', '2024-06-10 16:08:37', '1', 'sellbillController.php', 'تعديل فاتورة مبيعات', '3900', '0', null, '0', null, null,'', '0','1','1','3900','1');
UPDATE client SET  inUse = 0 where clientid = 413;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3900, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (413, '2024-06-10', 3900, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-3900, sellCostBuyPrice =sellCostBuyPrice-4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice-4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 3900, 4200, 4200
                    , 4200, 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-3900, netSellCostBuyPrice = netSellCostBuyPrice-4200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-4200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-4200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-4200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-4200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 17452 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 17452 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
CALL clientInUse(413,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 16:08:37', '06666fad59a0b9', '413', '15015.00', '19215', '0', '1', '4200', '4200', '0', '4200', '1', '2024-06-10 16:08:37', '', '1', '0', 'سنتر الفيروز', '1', '1', '3', '0', 'سنتر الفيروز', '12', '17452', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00');
UPDATE client SET  clientdebt = '19215', userid = '1' WHERE clientid = '413';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('413','15015.00','4200','0','اضافة فاتورة مبيعات (معدله)','17453', '19215', '2024-06-10 16:15:55', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '4200', '0', null, '0', null, null,'', '0','1','1','1','1');
UPDATE client SET  inUse = 0 where clientid = 413;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17453', '1', '1770', '12.00', '350.00', '4200', '0', '', '0', '2024-06-10 16:15:56', '1770', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51729;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 12, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+12
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '60', userid = '1', storedetaildate = '2024-06-10 16:15:57' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '12', '1', '17453', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '72.00', '60', '1', '2024-06-10 16:15:57','0','0');
UPDATE dailyentry SET totalcreditor = '3900.00', totaldebtor = '3900.00', thedate = '2024-06-10', userid = '1', `condition` = '0', reverseofid = '-10', dDateTime = '2024-06-10 16:12:07', entryComment = 'تم اضافة فاتورة مبيعات ( اجل )', fromFlag = '1',related='0' WHERE id = '10490';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '3900.00', '3900.00', '2024-06-10', '1', '0', '10490', '2024-06-10 16:15:57','تم عكس القيد رقم 10490 ','1','0','0');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10491', '483', '3900.00', '','0');
UPDATE accountstree SET name = 'سنتر الفيروز', customName = 'سنتر الفيروز', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-05', itemtype2 = '1', theValue = '-10000', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '483';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10491', '16', '3900.00', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '501538', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4200', '4200', '2024-06-10', '1', '0', '10490', '2024-06-10 16:15:57','تم اضافة فاتورة مبيعات ( اجل )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10492', '483', '4200', '','0');
UPDATE accountstree SET name = 'سنتر الفيروز', customName = 'سنتر الفيروز', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-05', itemtype2 = '1', theValue = '-5800', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '483';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10492', '16', '4200', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '505738', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
UPDATE sellbill SET sellbilldate = '2024-06-10 16:08:37', sellbillserial = '06666fad59a0b9', sellbillclientid = '413', sellbilltotaldeptbefor = '15015.00', sellbilltotaldeptafter = '19215.00', sellbilldiscount = '0', sellbilldiscounttype = '1', sellbilltotalbill = '4200.00', sellbillaftertotalbill = '4200.00', sellbilltotalpayed = '0.00', sellbillfinalbill = '4200.00', sellbillstoreid = '1', sellbillsysdate = '2024-06-10 16:08:37',comment = '', userid = '1', conditions = '0', sellbillclientname = 'سنتر الفيروز', sellbillsaveid = '1', sellbildirectpayment = '1', billnameid = '3', sellerid = '0', tempclientName = 'سنتر الفيروز', sellQuantity = '12.00' , dailyentryid = '10492',obygyVisitId = '0',onlineOrderId = '0',delbyuserid = '1',delivery = '0',totalafterdelivery = '4200',billReservation='0',billReservationDate='0000-00-00',visaAccountId = '0',cashPayed = '0',visaPayed = '0',isBankAccountTransfer = '0',extraDiscountPer='0',extraDiscountVal='0',taxOfDiscountPer='0',taxOfDiscountVal='0',taxBillNumber='0',collectionType = '0',collectionDate='0000-00-00' WHERE sellbillid = '17453';
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (413, '2024-06-10', 4200, 4200, 4200
                    , 4200, 4200, 4200, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4200, sellCostBuyPrice =sellCostBuyPrice+4200
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4200, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4200
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4200, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4200
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 4200, 4200, 4200
                    , 4200, 4200, 4200, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4200, netSellCostBuyPrice = netSellCostBuyPrice+4200
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4200
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4200
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 17452 and newid=17453 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:45:59";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:16:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:16:00', '1', 'editprint', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:46:53";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:16:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:16:55', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:47:04";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:17:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:17:04', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:51:06";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:21:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:21:06', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:51:34";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:21:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:21:34', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:51:46";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:21:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:21:47', '1', 'editsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:52:07";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:22:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:22:07', '1', 'update', '156.210.101.227', '', 'DESKTOP');
BEGIN;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - with id = 17450 and  = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete start with id = 17450 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE costcenterdetail SET del = 1 WHERE type in( 0) and  modelid = 17450;
UPDATE sellbill SET  sellbillsysdate = '2024-06-10 16:22:07', userid = '1',delbyuserid = '1', conditions = '1'  WHERE sellbillid = '17450';
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 422.50, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 422.50
                where sellbilldetailid = 51717;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-06-10', 8472.0698405693, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,21,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8472.0698405693, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-21
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8472.0698405693, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8472.0698405693, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '90', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '21', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '69.00', '90', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51718;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1783, '2024-06-10', 8068.6379433993, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8068.6379433993, sellCostBuyPrice =sellCostBuyPrice-8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8068.6379433993, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8068.6379433993, sellCostBuyPrice =sellCostBuyPrice-8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1783', '1', '20', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '20', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 51719;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-06-10', 10470.465052132, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,31,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-10470.465052132, sellCostBuyPrice =sellCostBuyPrice-11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-31
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 10470.465052132, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-10470.465052132, sellCostBuyPrice =sellCostBuyPrice-11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '137', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '1', '31', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '106.00', '137', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51720;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 6567.4960004413, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6567.4960004413, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 6567.4960004413, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6567.4960004413, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '80', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '20', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '60.00', '80', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 51721;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1782, '2024-06-10', 8199.9878634082, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,23,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8199.9878634082, sellCostBuyPrice =sellCostBuyPrice-8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-23
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8199.9878634082, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8199.9878634082, sellCostBuyPrice =sellCostBuyPrice-8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice-8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1782', '1', '23', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '23', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51722;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1784, '2024-06-10', 11141.287857892, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,25,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-11141.287857892, sellCostBuyPrice =sellCostBuyPrice-11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-25
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11141.287857892, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-11141.287857892, sellCostBuyPrice =sellCostBuyPrice-11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice-11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '55', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1784', '1', '25', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '30.00', '55', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51723;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 6567.4960004413, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6567.4960004413, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 6567.4960004413, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-6567.4960004413, sellCostBuyPrice =sellCostBuyPrice-7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '44', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6340';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '1', '20', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '24.00', '44', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51724;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 8443.9234291389, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,20,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8443.9234291389, sellCostBuyPrice =sellCostBuyPrice-9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-20
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8443.9234291389, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8443.9234291389, sellCostBuyPrice =sellCostBuyPrice-9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '-43', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '5618';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '20', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '-63.00', '-43', '1', '2024-06-09 00:05:20','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity-3 where id = 19169;
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51725;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1642, '2024-06-10', 8631.5661720086, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,23,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8631.5661720086, sellCostBuyPrice =sellCostBuyPrice-10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-23
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8631.5661720086, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8631.5661720086, sellCostBuyPrice =sellCostBuyPrice-10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice-10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '5966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '1', '23', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '0.00', '23', '1', '2024-06-09 00:05:20','0','0');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51726;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1781, '2024-06-10', 8472.0698405693, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0,21,0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8472.0698405693, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0
                        , netQuantity = netQuantity-21
                        , netQuantityRet = netQuantityRet-0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8472.0698405693, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-8472.0698405693, sellCostBuyPrice =sellCostBuyPrice-9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice-9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
UPDATE storedetail SET  productquantity = '67', userid = '1', storedetaildate = '2024-06-10 16:22:08' WHERE storedetailid = '6402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '21', '0', '17450', 'تعديل فاتورة مبيعات', 'sellbillController.php', '46.00', '67', '1', '2024-06-09 00:05:20','0','0');
CALL clientInUse(414,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '0', userid = '1' WHERE clientid = '414';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('414','85035.00','85035.00','1','تعديل فاتورة مبيعات','17450', '0', '2024-06-09 00:05:20', '1', 'sellbillController.php', 'تعديل فاتورة مبيعات', '85035', '0', null, '0', null, null,'', '0','1','1','85035','1');
UPDATE client SET  inUse = 0 where clientid = 414;
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-85035, sellCostBuyPrice =sellCostBuyPrice-91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice-92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (414, '2024-06-10', 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-85035, sellCostBuyPrice =sellCostBuyPrice-91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice-92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-0
                        , returnSellVal = returnSellVal-0, returnSellCostBuyPrice = returnSellCostBuyPrice-0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 85035, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal-85035, netSellCostBuyPrice = netSellCostBuyPrice-91785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice-92935
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice-92202.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount-92935
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount-92202.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice-0;

-- ----------------------------------------------------------------------------------------------------
-- bill update start - delete end - with id = 17450 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------


-- ----------------------------------------------------------------------------------------------------
-- bill update start - new add start - with id = 17450 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
CALL clientInUse(414,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,deletedsellid,controlname,tax, carnumber, cartype, carchase, carmotor,costcenterid,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,obygyVisitId,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-09 00:05:20', '06664c790ece27', '414', '0.00', '90635', '0', '1', '90635', '90635', '0', '90635', '1', '2024-06-09 00:05:20', '', '1', '0', 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', '1', '1', '3', '0', 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', '224', '17450', 'sellbillController', '0','','','','','-1','0','0','0','0','0','0','0','0','0','0','0','0','0000-00-00');
UPDATE client SET  clientdebt = '90635', userid = '1' WHERE clientid = '414';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('414','0.00','90635','0','اضافة فاتورة مبيعات (معدله)','17454', '90635', '2024-06-10 16:22:08', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات (معدله)', '90635', '0', null, '0', null, null,'', '0','1','1','1','1');
UPDATE client SET  inUse = 0 where clientid = 414;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01749', '17454', '1', '1749', '21.00', '430.00', '9030', '0', '', '0', '2024-06-10 16:22:09', '1749', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 422.50, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 422.50
                where sellbilldetailid = 51730;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-06-10', 9030, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 21, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+21
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9030, 9030, 9030
                    , 8872.5, 9030, 8872.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8872.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8872.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '69', userid = '1', storedetaildate = '2024-06-10 16:22:10' WHERE storedetailid = '6283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '21', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '90.00', '69', '1', '2024-06-10 16:22:10','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01783', '17454', '1', '1783', '20.00', '430.00', '8600', '0', '', '0', '2024-06-10 16:22:10', '1783', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51731;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1783, '2024-06-10', 8600, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8600, sellCostBuyPrice =sellCostBuyPrice+8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8600, 8600, 8600
                    , 8600, 8600, 8600, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8600, sellCostBuyPrice =sellCostBuyPrice+8600
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8600, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8600
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8600, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8600
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 16:22:11' WHERE storedetailid = '6404';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1783', '1', '20', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '20.00', '0', '1', '2024-06-10 16:22:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('360','01785', '17454', '1', '1785', '31.00', '360.00', '11160', '0', '', '0', '2024-06-10 16:22:11', '1785', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 51732;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1785, '2024-06-10', 11160, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 31, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11160, sellCostBuyPrice =sellCostBuyPrice+11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+31
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11160, 11160, 11160
                    , 11160, 11160, 11160, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11160, sellCostBuyPrice =sellCostBuyPrice+11160
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11160, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11160
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11160, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11160
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '106', userid = '1', storedetaildate = '2024-06-10 16:22:11' WHERE storedetailid = '6406';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '1', '31', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '137.00', '106', '1', '2024-06-10 16:22:11','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17454', '1', '1770', '20.00', '350.00', '7000', '0', '', '0', '2024-06-10 16:22:11', '1770', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51733;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '60', userid = '1', storedetaildate = '2024-06-10 16:22:12' WHERE storedetailid = '6359';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '20', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '80.00', '60', '1', '2024-06-10 16:22:12','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('380','01782', '17454', '1', '1782', '23.00', '380.00', '8740', '0', '', '0', '2024-06-10 16:22:12', '1782', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 51734;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1782, '2024-06-10', 8740, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 23, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8740, sellCostBuyPrice =sellCostBuyPrice+8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+23
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 8740, 8740, 8740
                    , 8740, 8740, 8740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+8740, sellCostBuyPrice =sellCostBuyPrice+8740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+8740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+8740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+8740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+8740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 16:22:12' WHERE storedetailid = '6403';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1782', '1', '23', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '23.00', '0', '1', '2024-06-10 16:22:13','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01784', '17454', '1', '1784', '25.00', '475.00', '11875', '0', '', '0', '2024-06-10 16:22:13', '1784', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51735;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1784, '2024-06-10', 11875, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 25, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11875, sellCostBuyPrice =sellCostBuyPrice+11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+25
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 11875, 11875, 11875
                    , 11875, 11875, 11875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+11875, sellCostBuyPrice =sellCostBuyPrice+11875
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11875, sellCostMeanBuyPrice = sellCostMeanBuyPrice+11875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11875, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+11875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '1', storedetaildate = '2024-06-10 16:22:13' WHERE storedetailid = '6405';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1784', '1', '25', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '55.00', '30', '1', '2024-06-10 16:22:13','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01761', '17454', '1', '1761', '20.00', '350.00', '7000', '0', '', '0', '2024-06-10 16:22:13', '1761', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51736;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 7000, 7000, 7000
                    , 7000, 7000, 7000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+7000, sellCostBuyPrice =sellCostBuyPrice+7000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+7000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+7000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+7000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+7000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-06-10 16:22:14' WHERE storedetailid = '6340';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '1', '20', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '44.00', '24', '1', '2024-06-10 16:22:14','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17454', '1', '1581', '20.00', '450.00', '9000', '0', '', '0', '2024-06-10 16:22:14', '1581', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51737;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 9000, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 20, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+20
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9000, 9000, 9000
                    , 9000, 9000, 9000, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9000, sellCostBuyPrice =sellCostBuyPrice+9000
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9000, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9000
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9000, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9000
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-63', userid = '1', storedetaildate = '2024-06-10 16:22:15' WHERE storedetailid = '5618';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '20', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '-43.00', '-63', '1', '2024-06-10 16:22:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 19169;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('456.52','01642', '17454', '1', '1642', '23.00', '400.00', '9200', '0', '', '0', '2024-06-10 16:22:16', '1642', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','19169-3,');
UPDATE sellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51738;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1642, '2024-06-10', 9200, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 23, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9200, sellCostBuyPrice =sellCostBuyPrice+10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+23
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9200, 10350, 11500
                    , 10925, 11500, 10925, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9200, sellCostBuyPrice =sellCostBuyPrice+10350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+11500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+10925
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+11500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+10925
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10 16:22:16' WHERE storedetailid = '5966';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '1', '23', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '23.00', '0', '1', '2024-06-10 16:22:17','0','0');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01781', '17454', '1', '1781', '21.00', '430.00', '9030', '0', '', '0', '2024-06-10 16:22:17', '1781', '0.00', '0', '1','0','','','0','0','0','0','0','0','0','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51739;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1781, '2024-06-10', 9030, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 21, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+21
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 9030, 9030, 9030
                    , 9030, 9030, 9030, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+9030, sellCostBuyPrice =sellCostBuyPrice+9030
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+9030, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9030
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+9030, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9030
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '46', userid = '1', storedetaildate = '2024-06-10 16:22:18' WHERE storedetailid = '6402';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '21', '1', '17454', 'اضافة فاتورة مبيعات (معدله)', 'sellbillController.php', '67.00', '46', '1', '2024-06-10 16:22:18','0','0');
UPDATE dailyentry SET totalcreditor = '85035.00', totaldebtor = '85035.00', thedate = '2024-06-10', userid = '1', `condition` = '0', reverseofid = '-10', dDateTime = '2024-06-10 01:15:07', entryComment = 'تم اضافة فاتورة مبيعات ( اجل )', fromFlag = '1',related='0' WHERE id = '10483';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '85035.00', '85035.00', '2024-06-10', '1', '0', '10483', '2024-06-10 16:22:18','تم عكس القيد رقم 10483 ','1','0','0');
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10493', '484', '85035.00', '','0');
UPDATE accountstree SET name = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', customName = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-08', itemtype2 = '1', theValue = '0', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '484';
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10493', '16', '85035.00', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '420703', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '90635', '90635', '2024-06-10', '1', '0', '10483', '2024-06-10 16:22:18','تم اضافة فاتورة مبيعات ( اجل )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10494', '484', '90635', '','0');
UPDATE accountstree SET name = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', customName = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2024-06-08', itemtype2 = '1', theValue = '90635', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '484';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10494', '16', '90635', '','0');
UPDATE accountstree SET name = 'المبيعات', customName = 'المبيعات', parent = '4', itemtype = '2', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '511338', theOrder = '0', layingOrder = '41',reportid = '2' WHERE id = '16';
UPDATE sellbill SET sellbilldate = '2024-06-09 00:05:20', sellbillserial = '06664c790ece27', sellbillclientid = '414', sellbilltotaldeptbefor = '0.00', sellbilltotaldeptafter = '90635.00', sellbilldiscount = '0', sellbilldiscounttype = '1', sellbilltotalbill = '90635.00', sellbillaftertotalbill = '90635.00', sellbilltotalpayed = '0.00', sellbillfinalbill = '90635.00', sellbillstoreid = '1', sellbillsysdate = '2024-06-09 00:05:20',comment = '', userid = '1', conditions = '0', sellbillclientname = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', sellbillsaveid = '1', sellbildirectpayment = '1', billnameid = '3', sellerid = '0', tempclientName = 'مصطفى تكس /السنبلاوين/(قرية) برهمتوش', sellQuantity = '224.00' , dailyentryid = '10494',obygyVisitId = '0',onlineOrderId = '0',delbyuserid = '1',delivery = '0',totalafterdelivery = '90635',billReservation='0',billReservationDate='0000-00-00',visaAccountId = '0',cashPayed = '0',visaPayed = '0',isBankAccountTransfer = '0',extraDiscountPer='0',extraDiscountVal='0',taxOfDiscountPer='0',taxOfDiscountVal='0',taxBillNumber='0',collectionType = '0',collectionDate='0000-00-00' WHERE sellbillid = '17454';
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 90635, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+90635, sellCostBuyPrice =sellCostBuyPrice+91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (414, '2024-06-10', 90635, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+90635, sellCostBuyPrice =sellCostBuyPrice+91785
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+92935, sellCostMeanBuyPrice = sellCostMeanBuyPrice+92202.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+92935, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+92202.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 90635, 91785, 92935
                    , 92202.5, 92935, 92202.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+90635, netSellCostBuyPrice = netSellCostBuyPrice+91785
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+92935
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+92202.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+92935
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+92202.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill update end - new add end - with oldid = 17450 and newid=17454 and controlname = sellbillController
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:52:23";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:22:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 16:22:23', '1', 'editprint', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:52:31";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:22:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:22:31', '1', 'all', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:52:39";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:22:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-06-10 16:22:39', '1', 'all', '156.210.101.227', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:59:13";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 16:29:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 16:29:13', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 12:59:13";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:44:41";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:45:15";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 18:15:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 18:15:15', '7', '', '197.192.234.157', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:45:16";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:45:46";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 18:15:46", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 18:15:46', '7', '', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:45:48";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 18:15:48", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 18:15:48', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:46:48";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:16:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:16:48', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:46:48";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:16:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:16:48', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:49:22";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:19:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 18:19:22', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:51:18";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:21:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 18:21:18', '1', 'add', '156.210.101.227', '', 'DESKTOP');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('ص39الوليد','','1','475','475', '555','485', '2024-06-10', '0', '1', '0', '', '0', '0', '0', '0', '0', '475','475','475','475','475','0','0','2.11','16.84','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'ص39الوليد', productDescription = '', productCatId = '1', productBuyPrice = '475', productSellAllPrice = '475', productSellUnitPrice = '555', productSellHalfPrice = '485', productDate = '2024-06-10', conditions = '0', userId = '1', limitamount = '0', parcode = '01786',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '475',lastbuyprice_withDiscount = '475',meanbuyprice = '475',meanbuyprice_withDiscount = '475' , productbuypricereal = '475' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1786';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1786', '1', '2024-06-10', '1', '0','0178601','475','485','555','475');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1786', '1', '210', '1', '2024-06-10');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '1', '210', '0', '1786', 'إضافة منتج', 'productController.php', '0', '210', '1', '2024-06-10','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1786, 1,'2024-06-10 18:21:19',1)
                ON DUPLICATE KEY UPDATE productid = 1786, edited = 1, sysdate = '2024-06-10 18:21:19', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '99750', '99750', '2024-06-10', '1', '0', '0', '2024-06-10 18:21:19','إضافة منتج ص39الوليد الكمية 210','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10495', '19', '99750', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '20083710.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10495', '7', '99750', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '20842061.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'ص39الوليد', productDescription = '', productCatId = '1', productBuyPrice = '475.00', productSellAllPrice = '475.00', productSellUnitPrice = '555.00', productSellHalfPrice = '485.00', productDate = '2024-06-10', conditions = '0', userId = '1', limitamount = '0', parcode = '01786',type ='0', expireDate = '0' , dailyentryId = '10495',isService = '0',isOptic = '0',lastbuyprice = '475',lastbuyprice_withDiscount = '475',meanbuyprice = '475',meanbuyprice_withDiscount = '475' , productbuypricereal = '475' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.11' , buypart_precentage = '16.84',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1786';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:51:20";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:21:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 18:21:21', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:55:21";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:25:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:25:21', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2116,1,6,1781,21,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 18:25:21',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '25', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, -21, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2024-06-10*430.00," WHERE transferproductid = 8825;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '21', '1', '8825', 'تحويل منتجات من المخزن', 'storemovementController.php', '46.00', '25', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1781', '6', '21', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1781, 0, 0
                    , 430.00, 21, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '6', '21', '0', '8825', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '21', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1729', '26', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-26', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6238';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1729, 0, 0
                    , 450.00, -26, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2024-06-10*450.00," WHERE transferproductid = 8826;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '1', '26', '1', '8826', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-26', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '37', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6333';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1729, 0, 0
                    , 450.00, 26, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '6', '26', '0', '8826', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '11.00', '37', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1577', '20', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '69', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5614';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1577, 0, 0
                    , 450.00, -20, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-06-10*450.00," WHERE transferproductid = 8827;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '1', '20', '1', '8827', 'تحويل منتجات من المخزن', 'storemovementController.php', '89.00', '69', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '35', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5638';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1577, 0, 0
                    , 450.00, 20, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '6', '20', '0', '8827', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '15.00', '35', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1749', '19', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '50', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6283';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1749, 0, 0
                    , 430.00, -19, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-06-10*430.00," WHERE transferproductid = 8828;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '19', '1', '8828', 'تحويل منتجات من المخزن', 'storemovementController.php', '69.00', '50', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1749', '6', '19', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1749, 0, 0
                    , 430.00, 19, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '6', '19', '0', '8828', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '19', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1764', '7', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6349';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-09', 1, 1764, 0, 0
                    , 360.00, 1, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1764, 0, 0
                    , 360.00, -6, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 360.00,
                        buyQuantity =buyQuantity+-6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-06-09*360.00,6*2024-06-10*360.00," WHERE transferproductid = 8829;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1764', '1', '7', '1', '8829', 'تحويل منتجات من المخزن', 'storemovementController.php', '7.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6352';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-09', 6, 1764, 0, 0
                    , 360.00, 1, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1764, 0, 0
                    , 360.00, 6, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+6, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1764', '6', '7', '0', '8829', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '6.00', '13', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1581', '12', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-75', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1581, 0, 0
                    , 450.00, -12, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-06-10*450.00," WHERE transferproductid = 8830;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '1', '8830', 'تحويل منتجات من المخزن', 'storemovementController.php', '-63.00', '-75', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '54', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5629';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '12', '0', '8830', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '42.00', '54', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1785', '15', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '91', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6406';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1785, 0, 0
                    , 360.00, -15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 360.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-06-10*360.00," WHERE transferproductid = 8831;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '1', '15', '1', '8831', 'تحويل منتجات من المخزن', 'storemovementController.php', '106.00', '91', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1785', '6', '15', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1785, 0, 0
                    , 360.00, 15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '6', '15', '0', '8831', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '15', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1786', '23', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '187', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6410';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1786, 0, 0
                    , 475.00, -23, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 475.00,
                        buyQuantity =buyQuantity+-23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2024-06-10*475.00," WHERE transferproductid = 8832;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '1', '23', '1', '8832', 'تحويل منتجات من المخزن', 'storemovementController.php', '210.00', '187', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1786', '6', '23', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1786, 0, 0
                    , 475.00, 23, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '6', '23', '0', '8832', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '23', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1766', '15', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6355';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1766, 0, 0
                    , 310.00, -15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 310.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-06-10*310.00," WHERE transferproductid = 8833;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1766', '1', '15', '1', '8833', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1766', '6', '15', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1766, 0, 0
                    , 310.00, 15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1766', '6', '15', '0', '8833', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '15', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1765', '15', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6354';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1765, 0, 0
                    , 310.00, -15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 310.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-06-10*310.00," WHERE transferproductid = 8834;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '1', '15', '1', '8834', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1765', '6', '15', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1765, 0, 0
                    , 310.00, 15, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '6', '15', '0', '8834', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '15', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1634', '20', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '151', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5933';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1634, 0, 0
                    , 1.00, -20, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 1.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-06-10*1.00," WHERE transferproductid = 8835;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '1', '20', '1', '8835', 'تحويل منتجات من المخزن', 'storemovementController.php', '171.00', '151', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1634', '6', '20', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1634, 0, 0
                    , 1.00, 20, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '6', '20', '0', '8835', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1772', '2', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6364';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1772, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-06-10*430.00," WHERE transferproductid = 8836;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '1', '2', '1', '8836', 'تحويل منتجات من المخزن', 'storemovementController.php', '6.00', '4', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6376';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1772, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '6', '2', '0', '8836', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1773', '2', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6365';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1773, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-06-10*430.00," WHERE transferproductid = 8837;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '1', '2', '1', '8837', 'تحويل منتجات من المخزن', 'storemovementController.php', '10.00', '8', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6375';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1773, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '6', '2', '0', '8837', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1771', '2', '2024-06-10', '1', '0','2116',null,null,'2024-06-10 18:25:21',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6363';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1771, 0, 0
                    , 430.00, -2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-06-10*430.00," WHERE transferproductid = 8838;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '1', '2', '1', '8838', 'تحويل منتجات من المخزن', 'storemovementController.php', '9.00', '7', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6374';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 6, 1771, 0, 0
                    , 430.00, 2, 0, 0, 1, '2024-06-10 18:25:21')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:25:21' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1771', '6', '2', '0', '8838', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:55:22";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:25:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:25:22', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 14:59:21";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:29:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:29:21', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:02:12";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:32:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:32:12', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2117,1,5,1577,14,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 18:32:12',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '55', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5614';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1577, 0, 0
                    , 450.00, -14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-06-10*450.00," WHERE transferproductid = 8839;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '1', '14', '1', '8839', 'تحويل منتجات من المخزن', 'storemovementController.php', '69.00', '55', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5697';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1577, 0, 0
                    , 450.00, 14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '14', '0', '8839', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '-16.00', '-2', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1781', '22', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '3', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6402';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1781, 0, 0
                    , 430.00, -22, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "22*2024-06-10*430.00," WHERE transferproductid = 8840;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '1', '22', '1', '8840', 'تحويل منتجات من المخزن', 'storemovementController.php', '25.00', '3', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1781', '5', '22', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1781, 0, 0
                    , 430.00, 22, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+22, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1781', '5', '22', '0', '8840', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '22', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1785', '16', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '75', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6406';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1785, 0, 0
                    , 360.00, -16, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 360.00,
                        buyQuantity =buyQuantity+-16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "16*2024-06-10*360.00," WHERE transferproductid = 8841;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '1', '16', '1', '8841', 'تحويل منتجات من المخزن', 'storemovementController.php', '91.00', '75', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1785', '5', '16', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1785, 0, 0
                    , 360.00, 16, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+16, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1785', '5', '16', '0', '8841', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '16', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1770', '19', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '41', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6359';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1770, 0, 0
                    , 350.00, -19, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-06-10*350.00," WHERE transferproductid = 8842;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '1', '19', '1', '8842', 'تحويل منتجات من المخزن', 'storemovementController.php', '60.00', '41', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '37', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6372';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1770, 0, 0
                    , 350.00, 19, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '19', '0', '8842', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '37', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1761', '19', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6340';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1761, 0, 0
                    , 350.00, -19, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "19*2024-06-10*350.00," WHERE transferproductid = 8843;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '1', '19', '1', '8843', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '5', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6371';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1761, 0, 0
                    , 350.00, 19, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+19, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '5', '19', '0', '8843', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '4.00', '23', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1581', '12', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-87', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1581, 0, 0
                    , 450.00, -12, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-06-10*450.00," WHERE transferproductid = 8844;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '12', '1', '8844', 'تحويل منتجات من المخزن', 'storemovementController.php', '-75.00', '-87', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5688';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1581, 0, 0
                    , 450.00, 12, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '12', '0', '8844', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '24.00', '36', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1786', '23', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '164', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6410';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1786, 0, 0
                    , 475.00, -23, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 475.00,
                        buyQuantity =buyQuantity+-23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "23*2024-06-10*475.00," WHERE transferproductid = 8845;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '1', '23', '1', '8845', 'تحويل منتجات من المخزن', 'storemovementController.php', '187.00', '164', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1786', '5', '23', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1786, 0, 0
                    , 475.00, 23, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+23, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1786', '5', '23', '0', '8845', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '23', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1578', '14', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5615';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1578, 0, 0
                    , 440.00, -14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 440.00,
                        buyQuantity =buyQuantity+-14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-06-10*440.00," WHERE transferproductid = 8846;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '1', '14', '1', '8846', 'تحويل منتجات من المخزن', 'storemovementController.php', '16.00', '2', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5696';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1578, 0, 0
                    , 440.00, 14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '5', '14', '0', '8846', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '15', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1635', '8', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5951';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1635, 0, 0
                    , 430.00, -8, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 430.00,
                        buyQuantity =buyQuantity+-8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-06-10*430.00," WHERE transferproductid = 8847;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '1', '8', '1', '8847', 'تحويل منتجات من المخزن', 'storemovementController.php', '23.00', '15', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6055';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1635, 0, 0
                    , 430.00, 8, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '5', '8', '0', '8847', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '1.00', '9', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1780', '14', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6399';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1780, 0, 0
                    , 250.00, -14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-06-10*250.00," WHERE transferproductid = 8848;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '1', '14', '1', '8848', 'تحويل منتجات من المخزن', 'storemovementController.php', '14.00', '0', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1780', '5', '14', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1780, 0, 0
                    , 250.00, 14, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '5', '14', '0', '8848', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '14', '1', '2024-06-10','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1634', '20', '2024-06-10', '1', '0','2117',null,null,'2024-06-10 18:32:12',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '131', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5933';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 1, 1634, 0, 0
                    , 1.00, -20, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyprice = 1.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-06-10*1.00," WHERE transferproductid = 8849;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '1', '20', '1', '8849', 'تحويل منتجات من المخزن', 'storemovementController.php', '151.00', '131', '1', '2024-06-10','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1634', '5', '20', '1', '2024-06-10');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-10', 5, 1634, 0, 0
                    , 1.00, 20, 0, 0, 1, '2024-06-10 18:32:12')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:32:12' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1634', '5', '20', '0', '8849', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:02:12";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:32:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:32:12', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:05:58";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 18:35:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 18:35:58', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:09:45";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 18:39:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 18:39:45', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:12:40";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:42:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 18:42:40', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:12:54";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:13:57";
UPDATE user SET loginip = "197.63.195.62", lastactivetime = "2024-06-10 18:43:57", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 18:43:57', '8', '', '197.63.195.62', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:13:57";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:14:00";
UPDATE user SET loginip = "197.63.195.62", lastactivetime = "2024-06-10 18:44:00", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 18:44:00', '8', 'addsellBill', '197.63.195.62', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:22:17";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:52:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:52:17', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:22:17";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:52:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:52:17', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:22:42";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:52:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:52:42', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2118,7,8,1780,14,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 18:52:42',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6400';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-08', 7, 1780, 0, 0
                    , 250.00, 14, 0, 0, 1, '2024-06-10 18:52:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-14, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:52:43' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "14*2024-06-08*250.00," WHERE transferproductid = 8850;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '7', '14', '1', '8850', 'تحويل منتجات من المخزن', 'storemovementController.php', '14.00', '0', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '6401';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-06-08', 8, 1780, 0, 0
                    , 250.00, 14, 0, 0, 1, '2024-06-10 18:52:43')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+14, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:52:43' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '14', '0', '8850', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '8.00', '22', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:22:43";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:52:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:52:43', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:27:11";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:57:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:57:11', '1', '', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:27:36";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:57:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:57:36', '1', 'add', '156.210.101.227', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS insertUniqueOptNum;;

CREATE PROCEDURE insertUniqueOptNum(IN optnum INT,IN storeidfrom INT,IN storeidto INT,IN productid INT,IN transferproductamount DECIMAL(10,2),IN transferproductdate DATE,IN userid INT,IN conditions INT,IN `comment` TEXT,IN deloperationnum INT,IN sizeid INT,IN colorid INT,IN driverid INT,IN drivertimeout INT,IN driverdate datetime,IN delivererid INT,IN deliverdate datetime,OUT inserted_id INT,OUT optnum_used INT)
BEGIN
DECLARE n INT DEFAULT 0;
DECLARE id INT DEFAULT 0;
DECLARE lastopt INT DEFAULT 0;


DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
    ROLLBACK;
    GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE,
     @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
    SET @full_error = CONCAT("ERROR ", @errno, " (", @sqlstate, "): ", @text);
    SELECT @full_error;
    ROLLBACK;
END;



START TRANSACTION;


SELECT COUNT(*) FROM storemovement WHERE `operationnum` = optnum INTO n;
SELECT DISTINCT operationnum FROM storemovement WHERE operationnum != 0  ORDER BY operationnum DESC limit 1 INTO lastopt;
set lastopt = lastopt+1;

	IF n > 0 THEN


      INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,comment ,
                lastopt,
                deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),lastopt INTO inserted_id,optnum_used;
ELSE

    INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions,comment,operationnum ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate)
                VALUES (storeidfrom, storeidto, productid,transferproductamount, transferproductdate, userid, conditions ,comment
                ,optnum
                ,deloperationnum,sizeid,colorid,driverid,drivertimeout,driverdate,delivererid,deliverdate);
            SELECT LAST_INSERT_ID(),optnum INTO inserted_id,optnum_used;
	END IF;

COMMIT WORK; -- it is mandatory dont wait comit in php.as if sp didnot found comit before reaching the end it will rollback giving no errors at all

End;
;;

;
BEGIN;
CALL insertUniqueOptNum(2119,8,7,1579,1,'2024-06-10',1,0, '' ,0,0,0,0,0,'2024-06-10 18:57:36',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '7', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5771';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 8, 1579, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-06-10 18:57:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:57:36' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-02-25*430.00," WHERE transferproductid = 8851;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1579', '8', '1', '1', '8851', 'تحويل منتجات من المخزن', 'storemovementController.php', '8.00', '7', '1', '2024-06-10','0','0');
UPDATE storedetail SET  productquantity = '22', userid = '1', storedetaildate = '2024-06-10' WHERE storedetailid = '5747';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1579, 0, 0
                    , 430.00, 1, 0, 0, 1, '2024-06-10 18:57:36')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-06-10 18:57:36' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1579', '7', '1', '0', '8851', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '21.00', '22', '1', '2024-06-10','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:27:37";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:57:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-06-10 18:57:37', '1', 'editshow', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:29:19";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:59:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 18:59:19', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:29:30";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 18:59:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-06-10 18:59:30', '1', 'show', '156.210.101.227', '', 'DESKTOP');
UPDATE product SET productName = 'شامية66', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2024-06-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01780',type ='0', expireDate = '0' , dailyentryId = '10459',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '12.00' , buyhalf_precentage = '16.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1780';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1780, 1,'2024-06-10 18:59:42',1)
                ON DUPLICATE KEY UPDATE productid = 1780, edited = 1, sysdate = '2024-06-10 18:59:42', userid = 1;
UPDATE product SET productName = 'شامية66', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '300', productDate = '2024-06-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01780',type ='0', expireDate = '0' , dailyentryId = '10459',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '12.00' , buyhalf_precentage = '16.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1780';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1780, 1,'2024-06-10 18:59:44',1)
                ON DUPLICATE KEY UPDATE productid = 1780, edited = 1, sysdate = '2024-06-10 18:59:44', userid = 1;
UPDATE product SET productName = 'شامية66', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '300', productSellUnitPrice = '300', productSellHalfPrice = '300', productDate = '2024-06-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01780',type ='0', expireDate = '0' , dailyentryId = '10459',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '12.00' , buyhalf_precentage = '16.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1780';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1780, 1,'2024-06-10 18:59:46',1)
                ON DUPLICATE KEY UPDATE productid = 1780, edited = 1, sysdate = '2024-06-10 18:59:46', userid = 1;
UPDATE product SET productName = 'شامية66', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '300.00', productSellUnitPrice = '300.00', productSellHalfPrice = '310', productDate = '2024-06-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01780',type ='0', expireDate = '0' , dailyentryId = '10459',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '12.00' , buyhalf_precentage = '16.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1780';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1780, 1,'2024-06-10 18:59:50',1)
                ON DUPLICATE KEY UPDATE productid = 1780, edited = 1, sysdate = '2024-06-10 18:59:50', userid = 1;
UPDATE product SET productName = 'شامية66', productDescription = '', productCatId = '1', productBuyPrice = '250.00', productSellAllPrice = '300.00', productSellUnitPrice = '330', productSellHalfPrice = '310.00', productDate = '2024-06-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01780',type ='0', expireDate = '0' , dailyentryId = '10459',isService = '0',isOptic = '0',lastbuyprice = '250.00',lastbuyprice_withDiscount = '250',meanbuyprice = '250.00',meanbuyprice_withDiscount = '250' , productbuypricereal = '250.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '12.00' , buyhalf_precentage = '16.00' , buypart_precentage = '0.00',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1780';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1780, 1,'2024-06-10 19:00:15',1)
                ON DUPLICATE KEY UPDATE productid = 1780, edited = 1, sysdate = '2024-06-10 19:00:15', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:32:28";
UPDATE user SET loginip = "156.210.101.227", lastactivetime = "2024-06-10 19:02:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 19:02:28', '1', 'addsellBill', '156.210.101.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 15:37:06";
UPDATE user SET loginip = "197.63.195.62", lastactivetime = "2024-06-10 19:07:06", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 19:07:06', '8', 'addsellBill', '197.63.195.62', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:10:45";
UPDATE user SET loginip = "197.32.177.49", lastactivetime = "2024-06-10 20:40:45", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 20:40:45', '3', '', '197.32.177.49', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:10:45";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:11:27";
UPDATE user SET loginip = "197.32.177.49", lastactivetime = "2024-06-10 20:41:27", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 20:41:27', '3', 'addsellBill', '197.32.177.49', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:26:36";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:26:45";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 20:56:45", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 20:56:45', '7', '', '197.192.234.157', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:26:45";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:26:57";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 20:56:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 20:56:57', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:36:26";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 21:06:26", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 21:06:26', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:43:02";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:43:07";
UPDATE user SET loginip = "197.32.177.49", lastactivetime = "2024-06-10 21:13:07", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 21:13:07', '3', '', '197.32.177.49', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 17:43:08";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 18:31:33";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 18:31:38";
UPDATE user SET loginip = "197.32.177.49", lastactivetime = "2024-06-10 22:01:38", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 22:01:38', '3', '', '197.32.177.49', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 18:31:38";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:01:18";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 22:31:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:31:18', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:01:20";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 22:31:20", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:31:20', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:04:58";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 22:34:58", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:34:59', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:13:38";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:43:38", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:43:38', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666740a30059c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 21:06:27', '0666740a30059c', '1', '0.00', '0', '20', '1', '570', '550', '550', '0', '5', '2024-06-10 22:43:38', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','550','0','','0','0','550','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17455', '0', '2024-06-10 22:43:38', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '550', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17835;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('550','01665', '17455', '1', '1665', '1', '570', '570', '0', '', '1', '2024-06-10 22:43:38', '1665', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','17835-1,');
UPDATE sellbilldetail SET  lastbuyprice = 550.00 , meanbuyprice = 520.00, lastbuyprice_withDiscount = 550.00, meanbuyprice_withDiscount = 520.00
                where sellbilldetailid = 51740;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1665, '2024-06-10', 550, 490, 550
                    , 520, 550, 520, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 550, 490, 550
                    , 520, 550, 520, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '27', userid = '7', storedetaildate = '2024-06-10 22:43:38' WHERE storedetailid = '6056';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1665', '5', '1', '1', '17455', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28.00', '27', '7', '2024-06-10 22:43:38','0','0');
UPDATE save SET  savecurrentvalue = '76030',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('75480.00','550', '0', '5', 'اضافة فاتورة مبيعات', '17455', '76030', '2024-06-10 22:43:38', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 550, 490, 550
                    , 520, 550, 520, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 550, 490, 550
                    , 520, 550, 520, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+550, sellCostBuyPrice =sellCostBuyPrice+490
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+550, sellCostMeanBuyPrice = sellCostMeanBuyPrice+520
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+550, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+520
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 550, 490, 550
                    , 520, 550, 520, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+550, netSellCostBuyPrice = netSellCostBuyPrice+490
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+550
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+520
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+550
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+520
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666740a30059c and sellbillId = 17455 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:13:39";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:43:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:43:39', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:14:28";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:44:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:44:28', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667576b4a97b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 22:43:39', '06667576b4a97b', '1', '0.00', '0', '0', '1', '490', '490', '490', '0', '5', '2024-06-10 22:44:28', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','490','0','','0','0','490','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17456', '0', '2024-06-10 22:44:28', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '490', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('440','01756', '17456', '1', '1756', '1', '490', '490', '0', '', '1', '2024-06-10 22:44:28', '1756', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
                where sellbilldetailid = 51741;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1756, '2024-06-10', 490, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 490, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-14', userid = '7', storedetaildate = '2024-06-10 22:44:28' WHERE storedetailid = '6327';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1756', '5', '1', '1', '17456', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-13.00', '-14', '7', '2024-06-10 22:44:28','0','0');
UPDATE save SET  savecurrentvalue = '76520',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('76030.00','490', '0', '5', 'اضافة فاتورة مبيعات', '17456', '76520', '2024-06-10 22:44:28', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 490, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 490, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+490, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 490, 440, 440
                    , 440, 440, 440, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+490, netSellCostBuyPrice = netSellCostBuyPrice+440
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+440
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+440
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+440
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+440
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667576b4a97b and sellbillId = 17456 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:14:30";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:44:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:44:30', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:15:56";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:45:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:45:56', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667579f17503
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(160,@clientdebt,@clientname);
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 22:44:31', '06667579f17503', '160', '845.00', '1955', '0', '1', '1710', '1710', '600', '1110', '5', '2024-06-10 22:45:56', '', '7', '0', 'ام بسمله المهاجرين', '5', '1', '3', '0', 'ام بسمله المهاجرين', '4' ,'0','','','','','-1','0','0','0','0','0','1710','0','','0','0','600','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '1955', userid = '7' WHERE clientid = '160';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('160','845.00','1110','0','اضافة فاتورة مبيعات','17457', '1955', '2024-06-10 22:45:56', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1710', '0', null, '0', null, null,'', '0','1','1','1110','1');
UPDATE client SET  inUse = 0 where clientid = 160;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19231;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17457', '1', '1577', '1', '460.00', '460', '0', '', '2', '2024-06-10 22:45:56', '1577', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19231-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51742;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-3', userid = '7', storedetaildate = '2024-06-10 22:45:56' WHERE storedetailid = '5697';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '1', '1', '17457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2.00', '-3', '7', '2024-06-10 22:45:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01584', '17457', '1', '1584', '1', '440.00', '440', '0', '', '2', '2024-06-10 22:45:56', '1584', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','16899-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51743;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1584, '2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2024-06-10 22:45:56' WHERE storedetailid = '5686';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1584', '5', '1', '1', '17457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2024-06-10 22:45:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16919;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('440','01578', '17457', '1', '1578', '1', '450.00', '450', '0', '', '2', '2024-06-10 22:45:56', '1578', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','16919-1,');
UPDATE sellbilldetail SET  lastbuyprice = 440.00 , meanbuyprice = 440.00, lastbuyprice_withDiscount = 440.00, meanbuyprice_withDiscount = 440.00
                where sellbilldetailid = 51744;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1578, '2024-06-10', 450, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 450, 440, 440
                    , 440, 440, 440, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+440
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+440, sellCostMeanBuyPrice = sellCostMeanBuyPrice+440
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+440, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+440
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '7', storedetaildate = '2024-06-10 22:45:56' WHERE storedetailid = '5696';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1578', '5', '1', '1', '17457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '7', '2024-06-10 22:45:56','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19055;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17457', '1', '1770', '1', '360.00', '360', '0', '', '2', '2024-06-10 22:45:56', '1770', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19055-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51745;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '7', storedetaildate = '2024-06-10 22:45:56' WHERE storedetailid = '6372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '1', '1', '17457', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37.00', '36', '7', '2024-06-10 22:45:56','0','0');
UPDATE save SET  savecurrentvalue = '77120',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('76520.00','600', '0', '5', 'اضافة فاتورة مبيعات', '17457', '77120', '2024-06-10 22:45:56', '7',  'sellbillController.php','160','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 1710, 1670, 1670
                    , 1670, 1670, 1670, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1710, sellCostBuyPrice =sellCostBuyPrice+1670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (160, '2024-06-10', 1710, 1670, 1670
                    , 1670, 1670, 1670, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1710, sellCostBuyPrice =sellCostBuyPrice+1670
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1670, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1670
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1670, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1670
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1710, 1670, 1670
                    , 1670, 1670, 1670, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1710, netSellCostBuyPrice = netSellCostBuyPrice+1670
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1670
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1670
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1670
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1670
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667579f17503 and sellbillId = 17457 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:15:57";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:45:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:45:58', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:16:16";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:46:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:46:16', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:19:01";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:49:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 22:49:01', '7', '', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:19:47";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:49:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:49:47', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:19:54";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:49:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 22:49:54', '7', '', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:20:05";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:50:05", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:50:05', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:20:07";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:50:07", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:50:07', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:20:37";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:50:37", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:50:37', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666758f017f64
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(160,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 22:50:08', '0666758f017f64', '160', '1955.00', '1595', '0', '1', '360', '360', '0', '-360', '5', '2024-06-10 22:50:37', '', '7', '0', 'ام بسمله المهاجرين','5', '1', '5', '0', 'ام بسمله المهاجرين', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '1595', userid = '7' WHERE clientid = '160';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('160','1955.00','360','1','اضافة فاتورة مردوات مبيعات','5924', '1595', '2024-06-10 22:50:37', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','360','1');
UPDATE client SET  inUse = 0 where clientid = 160;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('350.00', '01761', '5924', '1', '1761', '1', '360', '360', '0', '', '2', '0', '1761', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where returnsellbilldetailid = 12797;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 350, 350, 350
                    , 350, 350, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+360, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+360, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '24', userid = '7', storedetaildate = '2024-06-10 22:50:37' WHERE storedetailid = '6371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '5', '1', '0', '5924', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '23.00', '24', '7', '2024-06-10 22:50:37','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+360, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (160, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+360, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -360, -350, -350
                    , -350, -350, -350, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-360, netSellCostBuyPrice = netSellCostBuyPrice+-350
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-350
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-350
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-350
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-350
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666758f017f64 and sellbillId = 5924 and returnsellbillId = 5924
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:20:38";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:50:38", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:50:38', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:20:41";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:50:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:50:42', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:21:31";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:51:31", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:51:31', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667591225d97
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 22:50:42', '06667591225d97', '1', '0.00', '0', '0', '1', '940', '940', '940', '0', '5', '2024-06-10 22:51:31', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','940','0','','0','0','940','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17458', '0', '2024-06-10 22:51:31', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '940', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('460','01681', '17458', '1', '1681', '2', '470.00', '940', '0', '', '2', '2024-06-10 22:51:31', '1681', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
                where sellbilldetailid = 51746;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1681, '2024-06-10', 940, 920, 920
                    , 920, 920, 920, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+940, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+920
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+920
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 940, 920, 920
                    , 920, 920, 920, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+940, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+920
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+920
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-2', userid = '7', storedetaildate = '2024-06-10 22:51:31' WHERE storedetailid = '6099';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '5', '2', '1', '17458', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0.00', '-2', '7', '2024-06-10 22:51:31','0','0');
UPDATE save SET  savecurrentvalue = '78060',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('77120.00','940', '0', '5', 'اضافة فاتورة مبيعات', '17458', '78060', '2024-06-10 22:51:31', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 940, 920, 920
                    , 920, 920, 920, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+940, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+920
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+920
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 940, 920, 920
                    , 920, 920, 920, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+940, sellCostBuyPrice =sellCostBuyPrice+920
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+920, sellCostMeanBuyPrice = sellCostMeanBuyPrice+920
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+920, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+920
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 940, 920, 920
                    , 920, 920, 920, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+940, netSellCostBuyPrice = netSellCostBuyPrice+920
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+920
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+920
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+920
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+920
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667591225d97 and sellbillId = 17458 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:21:33";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:51:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:51:33', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:21:40";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:51:40", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:51:40', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:21:59";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:51:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:51:59', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667594ce14f7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 22:51:40', '06667594ce14f7', '1', '0.00', '0', '0', '1', '970', '970', '-970', '0', '5', '2024-06-10 22:51:59', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-970','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5925', '0', '2024-06-10 22:51:59', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '970', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('475.00', '01760', '5925', '1', '1760', '2', '485.00', '970', '0', '', '2', '0', '1760', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where returnsellbilldetailid = 12798;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 950, 950, 950
                    , 950, 950, 0, 0, 2)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+950, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+950
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+950, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+950
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+950
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+2;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 950, 950, 950
                    , 950, 950, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+950, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+950
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+950, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+950
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+950
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-5', userid = '7', storedetaildate = '2024-06-10 22:51:59' WHERE storedetailid = '6329';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '5', '2', '0', '5925', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-7.00', '-5', '7', '2024-06-10 22:51:59','0','0');
UPDATE save SET  savecurrentvalue = '77090',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('78060.00','970', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5925', '77090', '2024-06-10 22:51:59', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 950, 950, 950
                    , 950, 950, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+950, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+950
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+950, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+950
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+950
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 970, 950, 950, 950
                    , 950, 950, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+970, returnSellCostBuyPrice = returnSellCostBuyPrice+950, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+950
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+950, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+950
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+950
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -970, -950, -950
                    , -950, -950, -950, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-970, netSellCostBuyPrice = netSellCostBuyPrice+-950
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-950
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-950
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-950
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-950
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667594ce14f7 and sellbillId = 5925 and returnsellbillId = 5925
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:22:00";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:52:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:52:00', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:22:06";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:52:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:52:06', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:22:22";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:52:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:52:22', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066675966d811f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 22:52:06', '066675966d811f', '1', '0.00', '0', '0', '1', '440', '440', '440', '0', '5', '2024-06-10 22:52:22', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','440','0','','0','0','440','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17459', '0', '2024-06-10 22:52:22', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01772', '17459', '1', '1772', '1', '440.00', '440', '0', '', '2', '2024-06-10 22:52:22', '1772', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 51747;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1772, '2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-3', userid = '7', storedetaildate = '2024-06-10 22:52:22' WHERE storedetailid = '6370';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1772', '5', '1', '1', '17459', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-2.00', '-3', '7', '2024-06-10 22:52:22','0','0');
UPDATE save SET  savecurrentvalue = '77530',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('77090.00','440', '0', '5', 'اضافة فاتورة مبيعات', '17459', '77530', '2024-06-10 22:52:22', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 440, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 440, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+440, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066675966d811f and sellbillId = 17459 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:22:24";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 22:52:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 22:52:24', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:41:48";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:11:48", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:11:48', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:45:53";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:15:53", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:15:53', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:47:02";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:17:02", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:17:02', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:53:19";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:23:19", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-06-10 23:23:19', '8', '', '154.183.2.120', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:53:20";
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:53:23";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:23:23", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:23:23', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:54:20";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:24:20", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:24:20', '3', 'addAndRetuen', '197.32.136.192', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066675f3e5e8da
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:17:02', '066675f3e5e8da', '1', '0.00', '0', '20', '1', '2300', '2280', '2280', '0', '8', '2024-06-10 23:24:21', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','2280','0','','0','0','2280','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17460', '0', '2024-06-10 23:24:21', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2280', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17855;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('400','01661', '17460', '1', '1661', '1', '480.00', '480', '0', '', '1', '2024-06-10 23:24:21', '1661', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17855-1,');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where sellbilldetailid = 51748;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1661, '2024-06-10', 475.82608695652, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475.82608695652, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 475.82608695652, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+475.82608695652, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '6062';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '3', '2024-06-10 23:24:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19015;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01763', '17460', '2', '1763', '1', '430', '430', '0', '', '1', '2024-06-10 23:24:21', '1763', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19015-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51749;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1763, '2024-06-10', 426.26086956522, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+426.26086956522, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 426.26086956522, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+426.26086956522, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '6346';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1763', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '3', '2024-06-10 23:24:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18167;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('240','01370', '17460', '1', '1370', '1', '290', '290', '0', '', '1', '2024-06-10 23:24:21', '1370', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18167-1,');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
                where sellbilldetailid = 51750;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1370, '2024-06-10', 287.47826086957, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+287.47826086957, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 287.47826086957, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+287.47826086957, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '30', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '5073';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1370', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31.00', '30', '3', '2024-06-10 23:24:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01588', '17460', '1', '1588', '1', '440', '440', '0', '', '1', '2024-06-10 23:24:21', '1588', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17097-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 385.00
                where sellbilldetailid = 51751;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1588, '2024-06-10', 436.17391304348, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+436.17391304348, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 436.17391304348, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+436.17391304348, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '5784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1588', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '15.00', '14', '3', '2024-06-10 23:24:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17460', '1', '1780', '1', '330', '330', '0', '', '1', '2024-06-10 23:24:21', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19163-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51752;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-06-10', 327.13043478261, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.13043478261, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 327.13043478261, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.13043478261, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '21', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22.00', '21', '3', '2024-06-10 23:24:21','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17987;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01684', '17460', '1', '1684', '1', '330', '330', '0', '', '1', '2024-06-10 23:24:21', '1684', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17987-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51753;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1684, '2024-06-10', 327.13043478261, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.13043478261, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 327.13043478261, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+327.13043478261, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '16', userid = '3', storedetaildate = '2024-06-10 23:24:21' WHERE storedetailid = '6124';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1684', '8', '1', '1', '17460', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '3', '2024-06-10 23:24:21','0','0');
UPDATE save SET  savecurrentvalue = '31495',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('29215.00','2280', '0', '8', 'اضافة فاتورة مبيعات', '17460', '31495', '2024-06-10 23:24:21', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 2280, 1850, 1900
                    , 1875, 1900, 1875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2280, sellCostBuyPrice =sellCostBuyPrice+1850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 2280, 1850, 1900
                    , 1875, 1900, 1875, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2280, sellCostBuyPrice =sellCostBuyPrice+1850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1875
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1875
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 2280, 1850, 1900
                    , 1875, 1900, 1875, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2280, netSellCostBuyPrice = netSellCostBuyPrice+1850
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1900
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1875
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1900
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1875
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066675f3e5e8da and sellbillId = 17460 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:54:21";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:24:21", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:24:21', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:54:41";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:24:41", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:24:41', '8', 'addAndRetuen', '154.183.2.120', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666760bb3fd37
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:23:23', '0666760bb3fd37', '1', '0.00', '0', '0', '1', '2495', '2495', '2495', '0', '6', '2024-06-10 23:24:41', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','2495','0','','0','0','2495','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17461', '0', '2024-06-10 23:24:41', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2495', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18993;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01729', '17461', '1', '1729', '1', '460', '460', '0', '', '2', '2024-06-10 23:24:41', '1729', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','18993-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51754;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1729, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '36', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '6333';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '37.00', '36', '8', '2024-06-10 23:24:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18897;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17461', '1', '1577', '1', '460', '460', '0', '', '2', '2024-06-10 23:24:42', '1577', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','18897-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51755;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '34', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '5638';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35.00', '34', '8', '2024-06-10 23:24:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18899;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01760', '17461', '1', '1760', '1', '485', '485', '0', '', '2', '2024-06-10 23:24:42', '1760', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','18899-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51756;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-06-10', 485, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 485, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '6334';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '8', '2024-06-10 23:24:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19075;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17461', '1', '1770', '1', '360', '360', '0', '', '2', '2024-06-10 23:24:42', '1770', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','19075-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51757;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '27', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '6378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '28.00', '27', '8', '2024-06-10 23:24:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19025;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('360','01764', '17461', '2', '1764', '1', '390', '390', '0', '', '2', '2024-06-10 23:24:42', '1764', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','19025-1,');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 51758;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1764, '2024-06-10', 390, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 390, 360, 360
                    , 360, 360, 360, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+360, sellCostMeanBuyPrice = sellCostMeanBuyPrice+360
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+360, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+360
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '6352';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1764', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '8', '2024-06-10 23:24:42','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('300','01769', '17461', '2', '1769', '1', '340', '340', '0', '', '2', '2024-06-10 23:24:42', '1769', '0.00', '0', '6','0','','','0','0','0','0','0','0','2','0','','19057-1,');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 51759;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1769, '2024-06-10', 340, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 340, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '5', userid = '8', storedetaildate = '2024-06-10 23:24:42' WHERE storedetailid = '6373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1769', '6', '1', '1', '17461', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '8', '2024-06-10 23:24:42','0','0');
UPDATE save SET  savecurrentvalue = '35595',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('33100.00','2495', '0', '6', 'اضافة فاتورة مبيعات', '17461', '35595', '2024-06-10 23:24:42', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 2495, 2385, 2385
                    , 2385, 2385, 2385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2495, sellCostBuyPrice =sellCostBuyPrice+2385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 2495, 2385, 2385
                    , 2385, 2385, 2385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2495, sellCostBuyPrice =sellCostBuyPrice+2385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2385, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2385, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 2495, 2385, 2385
                    , 2385, 2385, 2385, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2495, netSellCostBuyPrice = netSellCostBuyPrice+2385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2385
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2385
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2385
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2385
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666760bb3fd37 and sellbillId = 17461 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:54:42";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:24:42", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:24:42', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:05";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:05", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:05', '8', 'addAndRetuen', '154.183.2.120', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667610ab7561
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:24:42', '06667610ab7561', '1', '0.00', '0', '0', '1', '1340', '1340', '1340', '0', '6', '2024-06-10 23:25:05', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1340','0','','0','0','1340','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17462', '0', '2024-06-10 23:25:05', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1340', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19057;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('300','01769', '17462', '2', '1769', '1', '380', '380', '0', '', '1', '2024-06-10 23:25:05', '1769', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','19057-1,');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 51760;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1769, '2024-06-10', 380, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 380, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+380, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '8', storedetaildate = '2024-06-10 23:25:05' WHERE storedetailid = '6373';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1769', '6', '1', '1', '17462', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '8', '2024-06-10 23:25:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19075;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17462', '1', '1770', '1', '430', '430', '0', '', '1', '2024-06-10 23:25:05', '1770', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','19075-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51761;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '26', userid = '8', storedetaildate = '2024-06-10 23:25:05' WHERE storedetailid = '6378';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '6', '1', '1', '17462', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27.00', '26', '8', '2024-06-10 23:25:05','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18315;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17462', '1', '1581', '1', '530', '530', '0', '', '1', '2024-06-10 23:25:05', '1581', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','18315-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51762;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 530, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 530, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+530, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '53', userid = '8', storedetaildate = '2024-06-10 23:25:05' WHERE storedetailid = '5629';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '1', '1', '17462', 'اضافة فاتورة مبيعات', 'sellbillController.php', '54.00', '53', '8', '2024-06-10 23:25:05','0','0');
UPDATE save SET  savecurrentvalue = '36935',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('35595.00','1340', '0', '6', 'اضافة فاتورة مبيعات', '17462', '36935', '2024-06-10 23:25:05', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 1340, 1100, 1100
                    , 1100, 1100, 1100, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1340, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 1340, 1100, 1100
                    , 1100, 1100, 1100, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1340, sellCostBuyPrice =sellCostBuyPrice+1100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1100, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1100
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1100, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1100
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1340, 1100, 1100
                    , 1100, 1100, 1100, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1340, netSellCostBuyPrice = netSellCostBuyPrice+1100
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1100
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1100
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1100
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1100
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667610ab7561 and sellbillId = 17462 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:06";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:06", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:06', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:09";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:09", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:25:09', '8', '', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:13";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:25:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:13', '3', 'addAndRetuen', '197.32.136.192', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666760f5b2a15
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:24:21', '0666760f5b2a15', '1', '0.00', '0', '0', '1', '950', '950', '950', '0', '8', '2024-06-10 23:25:13', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','950','0','','0','0','950','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17463', '0', '2024-06-10 23:25:13', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '950', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 18989;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01760', '17463', '1', '1760', '2', '475.00', '950', '0', '', '0', '2024-06-10 23:25:13', '1760', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','18989-2,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51763;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-06-10', 950, 950, 950
                    , 950, 950, 950, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 950, 950, 950
                    , 950, 950, 950, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '3', storedetaildate = '2024-06-10 23:25:13' WHERE storedetailid = '6339';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '8', '2', '1', '17463', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '12', '3', '2024-06-10 23:25:13','0','0');
UPDATE save SET  savecurrentvalue = '32445',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('31495.00','950', '0', '8', 'اضافة فاتورة مبيعات', '17463', '32445', '2024-06-10 23:25:13', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 950, 950, 950
                    , 950, 950, 950, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 950, 950, 950
                    , 950, 950, 950, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+950, sellCostMeanBuyPrice = sellCostMeanBuyPrice+950
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+950, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+950
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 950, 950, 950
                    , 950, 950, 950, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+950
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+950
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+950
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+950
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+950
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666760f5b2a15 and sellbillId = 17463 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:13";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:25:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:13', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:26";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:26", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:26', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:29";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:29", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:29', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:44";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:45", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:45', '8', 'addAndRetuen', '154.183.2.120', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666761396377c
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:25:29', '0666761396377c', '1', '0.00', '0', '30', '1', '480', '450', '450', '0', '6', '2024-06-10 23:25:45', '', '8', '0', 'نقدي', '6', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','450','0','','0','0','450','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '8' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17464', '0', '2024-06-10 23:25:45', '8', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16813;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01573', '17464', '1', '1573', '1', '480', '480', '0', '', '1', '2024-06-10 23:25:45', '1573', '0.00', '0', '6','0','','','0','0','0','0','0','0','1','0','','16813-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 51764;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1573, '2024-06-10', 450, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (6, '2024-06-10', 450, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '8', storedetaildate = '2024-06-10 23:25:45' WHERE storedetailid = '5643';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1573', '6', '1', '1', '17464', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '8', '2024-06-10 23:25:45','0','0');
UPDATE save SET  savecurrentvalue = '37385',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('36935.00','450', '0', '6', 'اضافة فاتورة مبيعات', '17464', '37385', '2024-06-10 23:25:45', '8',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 450, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 450, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 450, 410, 410
                    , 410, 410, 410, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+410
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+410
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+410
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666761396377c and sellbillId = 17464 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:45";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:45", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:25:45', '8', 'addsellBill', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:55:47";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:25:48", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:25:48', '8', '', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:56:36";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:26:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:26:36', '3', 'addAndRetuen', '197.32.136.192', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667612a04729
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:25:14', '06667612a04729', '1', '0.00', '0', '0', '1', '290', '290', '290', '0', '8', '2024-06-10 23:26:37', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','290','0','','0','0','290','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17465', '0', '2024-06-10 23:26:37', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '290', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18167;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('240','01370', '17465', '1', '1370', '1', '290', '290', '0', '', '1', '2024-06-10 23:26:37', '1370', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18167-1,');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
                where sellbilldetailid = 51765;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1370, '2024-06-10', 290, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 290, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '29', userid = '3', storedetaildate = '2024-06-10 23:26:37' WHERE storedetailid = '5073';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1370', '8', '1', '1', '17465', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30.00', '29', '3', '2024-06-10 23:26:37','0','0');
UPDATE save SET  savecurrentvalue = '32735',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('32445.00','290', '0', '8', 'اضافة فاتورة مبيعات', '17465', '32735', '2024-06-10 23:26:37', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 290, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 290, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+290, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 290, 240, 240
                    , 240, 240, 240, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+290, netSellCostBuyPrice = netSellCostBuyPrice+240
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+240
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+240
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667612a04729 and sellbillId = 17465 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 19:56:37";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:26:37", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:26:37', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:01:33";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:31:33", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:31:33', '8', '', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:01:40";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:31:40", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:31:40', '8', 'add', '154.183.2.120', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'فطار', '', '20', '2024-06-10', '8', '0','-1','6','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '37365',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('37385.00','20', '1', '6', 'إضافة مصروف', '5121', '37365', '2024-06-10 23:31:40', '8',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-06-10', '8', '0', '0', '2024-06-10 23:31:40','اضافة اسم مصروف( فطار )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10496', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4531835', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10496', '140', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1955437', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'فطار', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-06-10', userid = '8', conditions = '0',saveid = '6' , dailyentryid = '10496', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5121';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:01:41";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:31:41", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:31:41', '8', 'sucess', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:01:42";
UPDATE user SET loginip = "154.183.2.120", lastactivetime = "2024-06-10 23:31:43", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:31:43', '8', 'show', '154.183.2.120', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:05:44";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:35:44", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:35:44', '3', 'addAndRetuen', '197.32.136.192', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667617dbcbbc
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:26:37', '06667617dbcbbc', '1', '0.00', '0', '0', '1', '1490', '1490', '1490', '0', '8', '2024-06-10 23:35:44', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '4' ,'0','','','','','-1','0','0','0','0','0','1490','0','','0','0','1490','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17466', '0', '2024-06-10 23:35:44', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1490', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18669;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('320','01754', '17466', '1', '1754', '1', '400', '400', '0', '', '1', '2024-06-10 23:35:44', '1754', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18669-1,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 51766;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1754, '2024-06-10', 400, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 400, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '12', userid = '3', storedetaildate = '2024-06-10 23:35:44' WHERE storedetailid = '6300';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1754', '8', '1', '1', '17466', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '3', '2024-06-10 23:35:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17466', '1', '1780', '2', '330', '660', '0', '', '1', '2024-06-10 23:35:44', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19163-2,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51767;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-06-10', 660, 500, 500
                    , 500, 500, 500, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 660, 500, 500
                    , 500, 500, 500, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+660, sellCostBuyPrice =sellCostBuyPrice+500
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+500, sellCostMeanBuyPrice = sellCostMeanBuyPrice+500
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+500, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+500
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '3', storedetaildate = '2024-06-10 23:35:44' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '2', '1', '17466', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '19', '3', '2024-06-10 23:35:44','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17466', '1', '1770', '1', '430', '430', '0', '', '1', '2024-06-10 23:35:44', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19037-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51768;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '3', storedetaildate = '2024-06-10 23:35:44' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '1', '1', '17466', 'اضافة فاتورة مبيعات', 'sellbillController.php', '24.00', '23', '3', '2024-06-10 23:35:44','0','0');
UPDATE save SET  savecurrentvalue = '34225',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('32735.00','1490', '0', '8', 'اضافة فاتورة مبيعات', '17466', '34225', '2024-06-10 23:35:44', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 1490, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1490, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 1490, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1490, sellCostBuyPrice =sellCostBuyPrice+1170
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1170
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1170
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1490, 1170, 1170
                    , 1170, 1170, 1170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1490, netSellCostBuyPrice = netSellCostBuyPrice+1170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667617dbcbbc and sellbillId = 17466 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:05:45";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:35:45", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:35:45', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:19";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:19", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:36:19', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:27";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:27", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:36:27', '3', 'showDetail', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:38";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:38", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:36:39', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:42";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:42", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:36:42', '3', 'showDetail', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:52";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:52", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:36:52', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:06:55";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:36:55", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:36:55', '3', 'showDetail', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:07:49";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:37:49", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:37:49', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:07:51";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:37:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:37:51', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:18:48";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:48:48", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:48:48', '3', 'addAndRetuen', '197.32.136.192', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666764201714f
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:37:52', '0666764201714f', '1', '0.00', '0', '0', '1', '5510', '5510', '5510', '0', '8', '2024-06-10 23:48:49', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '14' ,'0','','','','','-1','0','0','0','0','0','5510','0','','0','0','5510','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '3' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17467', '0', '2024-06-10 23:48:49', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '5510', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17467', '1', '1770', '1', '430', '430', '0', '', '1', '2024-06-10 23:48:49', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19037-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51769;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '22', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '23.00', '22', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19079;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('310','01774', '17467', '2', '1774', '1', '390', '390', '0', '', '1', '2024-06-10 23:48:49', '1774', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19079-1,');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
                where sellbilldetailid = 51770;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1774, '2024-06-10', 390, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 390, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '25', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6382';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1774', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26.00', '25', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18728;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('380','01657', '17467', '1', '1657', '1', '430', '430', '0', '', '1', '2024-06-10 23:48:49', '1657', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18728-1,');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 51771;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1657, '2024-06-10', 430, 380, 380
                    , 380, 380, 380, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 430, 380, 380
                    , 380, 380, 380, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1657', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '8', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17467', '1', '1780', '1', '330', '330', '0', '', '1', '2024-06-10 23:48:49', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19163-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51772;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-06-10', 330, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 330, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '18', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '19.00', '18', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19151;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01779', '17467', '1', '1779', '1', '430', '430', '0', '', '1', '2024-06-10 23:48:49', '1779', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19151-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51773;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1779, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 430, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6398';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1779', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17467', '1', '1780', '1', '330', '330', '0', '', '1', '2024-06-10 23:48:49', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19163-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51774;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-06-10', 330, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 330, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+330, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '1', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 19037;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17467', '1', '1770', '2', '430', '860', '0', '', '1', '2024-06-10 23:48:49', '1770', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19037-2,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51775;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 860, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+860, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 860, 700, 700
                    , 700, 700, 700, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+860, sellCostBuyPrice =sellCostBuyPrice+700
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+700
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+700
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '20', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6361';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '8', '2', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '22.00', '20', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 19163;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01780', '17467', '1', '1780', '3', '330', '990', '0', '', '1', '2024-06-10 23:48:49', '1780', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','19163-3,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 51776;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1780, '2024-06-10', 990, 750, 750
                    , 750, 750, 750, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 990, 750, 750
                    , 750, 750, 750, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+990, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+750, sellCostMeanBuyPrice = sellCostMeanBuyPrice+750
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+750, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+750
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '6401';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1780', '8', '3', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '14', '3', '2024-06-10 23:48:49','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 17097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01588', '17467', '1', '1588', '3', '440', '1320', '0', '', '1', '2024-06-10 23:48:49', '1588', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17097-3,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 385.00
                where sellbilldetailid = 51777;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1588, '2024-06-10', 1320, 1080, 1230
                    , 1155, 1230, 1155, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1320, sellCostBuyPrice =sellCostBuyPrice+1080
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-06-10', 1320, 1080, 1230
                    , 1155, 1230, 1155, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1320, sellCostBuyPrice =sellCostBuyPrice+1080
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1230, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1155
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1230, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1155
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '3', storedetaildate = '2024-06-10 23:48:49' WHERE storedetailid = '5784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1588', '8', '3', '1', '17467', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '11', '3', '2024-06-10 23:48:49','0','0');
UPDATE save SET  savecurrentvalue = '39735',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('34225.00','5510', '0', '8', 'اضافة فاتورة مبيعات', '17467', '39735', '2024-06-10 23:48:49', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 5510, 4420, 4570
                    , 4495, 4570, 4495, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5510, sellCostBuyPrice =sellCostBuyPrice+4420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 5510, 4420, 4570
                    , 4495, 4570, 4495, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5510, sellCostBuyPrice =sellCostBuyPrice+4420
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+4570, sellCostMeanBuyPrice = sellCostMeanBuyPrice+4495
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+4570, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+4495
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 5510, 4420, 4570
                    , 4495, 4570, 4495, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+5510, netSellCostBuyPrice = netSellCostBuyPrice+4420
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+4570
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+4495
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+4570
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+4495
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666764201714f and sellbillId = 17467 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:18:49";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:48:49", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:48:49', '3', 'addsellBill', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:19:41";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:49:41", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:49:41', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:19:46";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:49:46", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:49:46', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:20:02";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:50:02", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:50:02', '3', 'add', '197.32.136.192', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'تاكسي', '', '100', '2024-06-10', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '39635',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('39735.00','100', '1', '8', 'إضافة مصروف', '5122', '39635', '2024-06-10 23:50:02', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '100', '100', '2024-06-10', '3', '0', '0', '2024-06-10 23:50:02','اضافة اسم مصروف( تاكسي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10497', '160', '100', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4531935', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10497', '142', '100', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2706891', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'تاكسي', expensesdetails = '', expensesValue = '100.00', expensesdate = '2024-06-10', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10497', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5122';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:20:03";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:50:03", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:50:03', '3', 'sucess', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:20:04";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:50:04", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-06-10 23:50:04', '3', 'show', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:20:06";
UPDATE user SET loginip = "197.32.136.192", lastactivetime = "2024-06-10 23:50:06", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-06-10 23:50:06', '3', '', '197.32.136.192', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:22:26";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:52:26", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:52:26', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066675978dc89e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 22:52:24', '066675978dc89e', '1', '0.00', '0', '0', '1', '5765', '5765', '5765', '0', '5', '2024-06-10 23:52:26', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '14' ,'0','','','','','-1','0','0','0','0','0','5765','0','','0','0','5765','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17468', '0', '2024-06-10 23:52:26', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '5765', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('300','01768', '17468', '2', '1768', '1', '340.00', '340', '0', '', '2', '2024-06-10 23:52:26', '1768', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
                where sellbilldetailid = 51778;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1768, '2024-06-10', 340, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 340, 300, 300
                    , 300, 300, 300, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+340, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+300, sellCostMeanBuyPrice = sellCostMeanBuyPrice+300
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+300, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+300
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-1', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '6367';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1768', '5', '1', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '0.00', '-1', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19053;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('475','01760', '17468', '1', '1760', '1', '485', '485', '0', '', '2', '2024-06-10 23:52:26', '1760', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19053-1,');
UPDATE sellbilldetail SET  lastbuyprice = 475.00 , meanbuyprice = 475.00, lastbuyprice_withDiscount = 475.00, meanbuyprice_withDiscount = 475.00
                where sellbilldetailid = 51779;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1760, '2024-06-10', 485, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 485, 475, 475
                    , 475, 475, 475, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+485, sellCostBuyPrice =sellCostBuyPrice+475
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+475, sellCostMeanBuyPrice = sellCostMeanBuyPrice+475
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+475, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+475
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-6', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '6329';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1760', '5', '1', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-5.00', '-6', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 18299;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01581', '17468', '1', '1581', '3', '460', '1380', '0', '', '2', '2024-06-10 23:52:26', '1581', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','18299-3,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51780;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-06-10', 1380, 1350, 1350
                    , 1350, 1350, 1350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1380, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 1380, 1350, 1350
                    , 1350, 1350, 1350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1380, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '33', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '5688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '3', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36.00', '33', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 16969;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('330','01552', '17468', '1', '1552', '2', '370', '740', '0', '', '2', '2024-06-10 23:52:26', '1552', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','16969-2,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 51781;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1552, '2024-06-10', 740, 660, 660
                    , 660, 660, 660, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 740, 660, 660
                    , 660, 660, 660, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+740, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '5721';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1552', '5', '2', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '9', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 19097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('310','01765', '17468', '1', '1765', '3', '360', '1080', '0', '', '2', '2024-06-10 23:52:26', '1765', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19097-3,');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
                where sellbilldetailid = 51782;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1765, '2024-06-10', 1080, 930, 930
                    , 930, 930, 930, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 1080, 930, 930
                    , 930, 930, 930, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1080, sellCostBuyPrice =sellCostBuyPrice+930
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+930, sellCostMeanBuyPrice = sellCostMeanBuyPrice+930
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+930, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+930
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '6390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '5', '3', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '7', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19055;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17468', '1', '1770', '1', '360', '360', '0', '', '2', '2024-06-10 23:52:26', '1770', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19055-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51783;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '35', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '6372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '1', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '36.00', '35', '7', '2024-06-10 23:52:26','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 18875;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01729', '17468', '1', '1729', '3', '460', '1380', '0', '', '2', '2024-06-10 23:52:26', '1729', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','18875-3,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51784;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1729, '2024-06-10', 1380, 1350, 1350
                    , 1350, 1350, 1350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1380, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+3
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 1380, 1350, 1350
                    , 1350, 1350, 1350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1380, sellCostBuyPrice =sellCostBuyPrice+1350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '7', storedetaildate = '2024-06-10 23:52:26' WHERE storedetailid = '6328';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1729', '5', '3', '1', '17468', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '8', '7', '2024-06-10 23:52:26','0','0');
UPDATE save SET  savecurrentvalue = '83295',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('77530.00','5765', '0', '5', 'اضافة فاتورة مبيعات', '17468', '83295', '2024-06-10 23:52:26', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 5765, 5415, 5415
                    , 5415, 5415, 5415, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5765, sellCostBuyPrice =sellCostBuyPrice+5415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5415, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5415, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 5765, 5415, 5415
                    , 5415, 5415, 5415, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+5765, sellCostBuyPrice =sellCostBuyPrice+5415
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+5415, sellCostMeanBuyPrice = sellCostMeanBuyPrice+5415
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+5415, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+5415
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 5765, 5415, 5415
                    , 5415, 5415, 5415, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+5765, netSellCostBuyPrice = netSellCostBuyPrice+5415
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+5415
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+5415
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+5415
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+5415
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066675978dc89e and sellbillId = 17468 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:22:27";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:52:27", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:52:27', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:22:34";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:52:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:52:34', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:23:05";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:53:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:53:06', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666767931d12b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 23:52:35', '0666767931d12b', '1', '0.00', '0', '10', '1', '720', '710', '-710', '0', '5', '2024-06-10 23:53:06', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-710','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5926', '0', '2024-06-10 23:53:06', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '710', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('350.00', '01721', '5926', '1', '1721', '1', '360.00', '360', '0', '', '2', '0', '1721', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where returnsellbilldetailid = 12799;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1721, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 365, 350, 350, 350
                    , 350, 350, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+365, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 365, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+365, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '7', storedetaildate = '2024-06-10 23:53:06' WHERE storedetailid = '6222';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '5', '1', '0', '5926', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '6.00', '7', '7', '2024-06-10 23:53:06','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('350.00', '01761', '5926', '1', '1761', '1', '360.00', '360', '0', '', '2', '0', '1761', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where returnsellbilldetailid = 12800;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1761, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 365, 350, 350, 350
                    , 350, 350, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+365, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 365, 350, 350, 350
                    , 350, 350, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+365, returnSellCostBuyPrice = returnSellCostBuyPrice+350, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+350
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+350, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+350
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+350
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '25', userid = '7', storedetaildate = '2024-06-10 23:53:06' WHERE storedetailid = '6371';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1761', '5', '1', '0', '5926', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '24.00', '25', '7', '2024-06-10 23:53:06','0','0');
UPDATE save SET  savecurrentvalue = '82585',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('83295.00','710', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5926', '82585', '2024-06-10 23:53:06', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 710, 700, 700, 700
                    , 700, 700, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+710, returnSellCostBuyPrice = returnSellCostBuyPrice+700, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+700
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+700, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+700
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+700
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 710, 700, 700, 700
                    , 700, 700, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+710, returnSellCostBuyPrice = returnSellCostBuyPrice+700, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+700
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+700, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+700
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+700
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -710, -700, -700
                    , -700, -700, -700, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-710, netSellCostBuyPrice = netSellCostBuyPrice+-700
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-700
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-700
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-700
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-700
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666767931d12b and sellbillId = 5926 and returnsellbillId = 5926
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:23:06";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:53:06", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:53:06', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:23:34";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:53:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:53:34', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666767b2e7d75
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 23:53:06', '0666767b2e7d75', '1', '0.00', '0', '10', '1', '510', '500', '-500', '0', '5', '2024-06-10 23:53:34', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-500','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5927', '0', '2024-06-10 23:53:34', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01773', '5927', '1', '1773', '1', '510', '510', '0', '', '1', '0', '1773', '0.00', '0','5','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 12801;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1773, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 430, 430, 430
                    , 430, 430, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 520, 430, 430, 430
                    , 430, 430, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+520, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-1', userid = '7', storedetaildate = '2024-06-10 23:53:34' WHERE storedetailid = '6369';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1773', '5', '1', '0', '5927', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-2.00', '-1', '7', '2024-06-10 23:53:34','0','0');
UPDATE save SET  savecurrentvalue = '82085',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('82585.00','500', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5927', '82085', '2024-06-10 23:53:34', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 500, 430, 430, 430
                    , 430, 430, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+500, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 500, 430, 430, 430
                    , 430, 430, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+500, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -500, -430, -430
                    , -430, -430, -430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-500, netSellCostBuyPrice = netSellCostBuyPrice+-430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666767b2e7d75 and sellbillId = 5927 and returnsellbillId = 5927
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:23:35";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:53:35", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:53:35', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:25:17";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:55:17", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:55:17', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');
DROP PROCEDURE IF EXISTS clientInUse;;

CREATE PROCEDURE clientInUse(IN id INT,OUT debtis VARCHAR(256),OUT nameis VARCHAR(256))
BEGIN
DECLARE in_use_flag INT DEFAULT 1;
SELECT inUse FROM client WHERE clientid = id INTO in_use_flag;

    IF in_use_flag = 0 THEN
        update client set inUse=1 where clientid = id;
        SELECT clientdebt,clientname INTO debtis,nameis FROM client WHERE clientid = id ;
    ELSE
        SELECT "in_use","in_use" INTO debtis,nameis;
    END IF;

END

;

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666767cf3c49a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(55,@clientdebt,@clientname);
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 23:53:35', '0666767cf3c49a', '55', '3710.00', '2530', '0', '1', '1210', '1210', '30', '-1180', '5', '2024-06-10 23:55:18', '', '7', '0', 'ام صبحي','5', '1', '5', '0', 'ام صبحي', '4', '0', '', '','','','-1','0','0','0','','0','30','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '2530', userid = '7' WHERE clientid = '55';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('55','3710.00','1180','1','اضافة فاتورة مردوات مبيعات','5928', '2530', '2024-06-10 23:55:18', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '1210', '0', null, '0', null, null,'', '0','1','1','1180','1');
UPDATE client SET  inUse = 0 where clientid = 55;
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('300.00', '01768', '5928', '2', '1768', '1', '340.00', '340', '0', '', '2', '0', '1768', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 300.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 300.00
                where returnsellbilldetailid = 12802;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1768, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 340, 300, 300, 300
                    , 300, 300, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+340, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 340, 300, 300, 300
                    , 300, 300, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+340, returnSellCostBuyPrice = returnSellCostBuyPrice+300, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+300
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+300, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+300
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+300
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '0', userid = '7', storedetaildate = '2024-06-10 23:55:18' WHERE storedetailid = '6367';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1768', '5', '1', '0', '5928', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '-1.00', '0', '7', '2024-06-10 23:55:18','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('280.00', '01624', '5928', '1', '1624', '3', '290.00', '870', '0', '', '2', '0', '1624', '0.00', '0','5','0','','','0','0','0','0','0','2');
UPDATE returnsellbilldetail SET  lastbuyprice = 300.00 , meanbuyprice = 290.00, lastbuyprice_withDiscount = 300.00, meanbuyprice_withDiscount = 290.00
                where returnsellbilldetailid = 12803;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1624, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 870, 840, 900, 870
                    , 900, 870, 0, 0, 3)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+870, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+900
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+870, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+900
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+870
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+3;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 870, 840, 900, 870
                    , 900, 870, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+870, returnSellCostBuyPrice = returnSellCostBuyPrice+840, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+900
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+870, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+900
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+870
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '7', storedetaildate = '2024-06-10 23:55:18' WHERE storedetailid = '5914';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1624', '5', '3', '0', '5928', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '11.00', '14', '7', '2024-06-10 23:55:18','0','0');
UPDATE save SET  savecurrentvalue = '82055',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('82085.00','-30', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5928', '82055', '2024-06-10 23:55:18', '7',  'returnsellbillController.php','55','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1210, 1140, 1200, 1170
                    , 1200, 1170, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+1210, returnSellCostBuyPrice = returnSellCostBuyPrice+1140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (55, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 1210, 1140, 1200, 1170
                    , 1200, 1170, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+1210, returnSellCostBuyPrice = returnSellCostBuyPrice+1140, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1200
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+1170, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1200
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+1170
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -1210, -1140, -1200
                    , -1170, -1200, -1170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-1210, netSellCostBuyPrice = netSellCostBuyPrice+-1140
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1200
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-1170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1200
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-1170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666767cf3c49a and sellbillId = 5928 and returnsellbillId = 5928
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:25:19";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:55:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:55:19', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:26:19";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:56:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:56:19', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:26:47";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:56:47", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:56:47', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667687389cfa
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:56:19', '06667687389cfa', '1', '0.00', '0', '20', '1', '420', '400', '400', '0', '5', '2024-06-10 23:56:47', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','400','0','','0','0','400','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17469', '0', '2024-06-10 23:56:47', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16915;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('370','01583', '17469', '1', '1583', '1', '420.00', '420', '0', '', '1', '2024-06-10 23:56:47', '1583', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','16915-1,');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 51785;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1583, '2024-06-10', 400, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 400, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '8', userid = '7', storedetaildate = '2024-06-10 23:56:47' WHERE storedetailid = '5694';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '5', '1', '1', '17469', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '8', '7', '2024-06-10 23:56:47','0','0');
UPDATE save SET  savecurrentvalue = '82455',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('82055.00','400', '0', '5', 'اضافة فاتورة مبيعات', '17469', '82455', '2024-06-10 23:56:47', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 400, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 400, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 400, 370, 370
                    , 370, 370, 370, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+370
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+370
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+370
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+370
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+370
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667687389cfa and sellbillId = 17469 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:26:48";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:56:48", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:56:48', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:27:49";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:57:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:57:50', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 066676890ab3de
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:56:48', '066676890ab3de', '1', '0.00', '0', '0', '1', '1940', '1940', '1940', '0', '5', '2024-06-10 23:57:50', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '5' ,'0','','','','','-1','0','0','0','0','0','1940','0','','0','0','1940','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17470', '0', '2024-06-10 23:57:50', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1940', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19055;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('350','01770', '17470', '1', '1770', '1', '360.00', '360', '0', '', '2', '2024-06-10 23:57:50', '1770', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19055-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 51786;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1770, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 360, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '34', userid = '7', storedetaildate = '2024-06-10 23:57:50' WHERE storedetailid = '6372';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1770', '5', '1', '1', '17470', 'اضافة فاتورة مبيعات', 'sellbillController.php', '35.00', '34', '7', '2024-06-10 23:57:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 16915;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('370','01583', '17470', '1', '1583', '2', '380.00', '760', '0', '', '2', '2024-06-10 23:57:50', '1583', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','16915-2,');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 51787;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1583, '2024-06-10', 760, 740, 740
                    , 740, 740, 740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 760, 740, 740
                    , 740, 740, 740, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+760, sellCostBuyPrice =sellCostBuyPrice+740
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+740, sellCostMeanBuyPrice = sellCostMeanBuyPrice+740
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+740, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+740
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-06-10 23:57:50' WHERE storedetailid = '5694';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1583', '5', '2', '1', '17470', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '6', '7', '2024-06-10 23:57:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('310','01765', '17470', '1', '1765', '1', '360.00', '360', '0', '', '2', '2024-06-10 23:57:50', '1765', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19097-1,');
UPDATE sellbilldetail SET  lastbuyprice = 310.00 , meanbuyprice = 310.00, lastbuyprice_withDiscount = 310.00, meanbuyprice_withDiscount = 310.00
                where sellbilldetailid = 51788;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1765, '2024-06-10', 360, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 360, 310, 310
                    , 310, 310, 310, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+310
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+310, sellCostMeanBuyPrice = sellCostMeanBuyPrice+310
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+310, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+310
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-06-10 23:57:50' WHERE storedetailid = '6390';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1765', '5', '1', '1', '17470', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '7', '2024-06-10 23:57:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 19231;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01577', '17470', '1', '1577', '1', '460.00', '460', '0', '', '2', '2024-06-10 23:57:50', '1577', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','19231-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 51789;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '-4', userid = '7', storedetaildate = '2024-06-10 23:57:50' WHERE storedetailid = '5697';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '5', '1', '1', '17470', 'اضافة فاتورة مبيعات', 'sellbillController.php', '-3.00', '-4', '7', '2024-06-10 23:57:50','0','0');
UPDATE save SET  savecurrentvalue = '84395',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('82455.00','1940', '0', '5', 'اضافة فاتورة مبيعات', '17470', '84395', '2024-06-10 23:57:50', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 1940, 1850, 1850
                    , 1850, 1850, 1850, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1940, sellCostBuyPrice =sellCostBuyPrice+1850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1850
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1850
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 1940, 1850, 1850
                    , 1850, 1850, 1850, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1940, sellCostBuyPrice =sellCostBuyPrice+1850
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1850, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1850
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1850, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1850
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 1940, 1850, 1850
                    , 1850, 1850, 1850, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1940, netSellCostBuyPrice = netSellCostBuyPrice+1850
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1850
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1850
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1850
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1850
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 066676890ab3de and sellbillId = 17470 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:27:53";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:57:53", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:57:53', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:28:04";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:58:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:58:04', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:28:51";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:58:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:58:51', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0666768dd0ac9b
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-06-10 23:58:05', '0666768dd0ac9b', '1', '0.00', '0', '0', '1', '260', '260', '-260', '0', '5', '2024-06-10 23:58:51', '', '7', '0', 'نقدي','5', '0', '5', '0', 'نقدي', '1', '0', '', '','','','-1','0','0','0','','0','-260','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5929', '0', '2024-06-10 23:58:51', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '260', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('260.00', '01718', '5929', '1', '1718', '1', '260.00', '260', '0', '', '0', '0', '1718', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 260.00 , meanbuyprice = 260.00, lastbuyprice_withDiscount = 260.00, meanbuyprice_withDiscount = 260.00
                where returnsellbilldetailid = 12804;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1718, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 260, 260, 260, 260
                    , 260, 260, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+260, returnSellCostBuyPrice = returnSellCostBuyPrice+260, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+260
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+260, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+260
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+260
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 260, 260, 260, 260
                    , 260, 260, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+260, returnSellCostBuyPrice = returnSellCostBuyPrice+260, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+260
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+260, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+260
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+260
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '7', storedetaildate = '2024-06-10 23:58:51' WHERE storedetailid = '6219';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '5', '1', '0', '5929', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '13.00', '14', '7', '2024-06-10 23:58:51','0','0');
UPDATE save SET  savecurrentvalue = '84135',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('84395.00','260', '1', '5', 'اضافة فاتورة مردوات مبيعات', '5929', '84135', '2024-06-10 23:58:51', '7',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 260, 260, 260, 260
                    , 260, 260, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+260, returnSellCostBuyPrice = returnSellCostBuyPrice+260, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+260
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+260, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+260
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+260
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 0, 0, 0
                    , 0, 0, 0, 0
                    , 260, 260, 260, 260
                    , 260, 260, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+260, returnSellCostBuyPrice = returnSellCostBuyPrice+260, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+260
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+260, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+260
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+260
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -260, -260, -260
                    , -260, -260, -260, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-260, netSellCostBuyPrice = netSellCostBuyPrice+-260
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-260
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-260
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-260
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-260
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0666768dd0ac9b and sellbillId = 5929 and returnsellbillId = 5929
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:28:52";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:58:52", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:58:52', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:29:01";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:59:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:59:01', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:29:29";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:59:29", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:59:29', '7', 'addAndRetuen', '197.192.234.157', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 06667691598bd8
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO sellbill (sellbilldate, sellbillserial, sellbillclientid, sellbilltotaldeptbefor, sellbilltotaldeptafter, sellbilldiscount, sellbilldiscounttype, sellbilltotalbill, sellbillaftertotalbill, sellbilltotalpayed, sellbillfinalbill, sellbillstoreid, sellbillsysdate,comment, userid, conditions, sellbillclientname, sellbillsaveid, sellbildirectpayment, billnameid, sellerid, tempclientName, sellQuantity,tax ,carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,obygyVisitId,onlineOrderId,delbyuserid,delivery,totalafterdelivery,billReservation,billReservationDate,webApiId,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal,taxBillNumber,collectionType,collectionDate) VALUES ('2024-06-10 23:59:01', '06667691598bd8', '1', '0.00', '0', '0', '1', '440', '440', '440', '0', '5', '2024-06-10 23:59:29', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','440','0','','0','0','440','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '7' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','0','اضافة فاتورة مبيعات','17471', '0', '2024-06-10 23:59:29', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18867;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('430','01749', '17471', '1', '1749', '1', '440.00', '440', '0', '', '2', '2024-06-10 23:59:29', '1749', '0.00', '0', '5','0','','','0','0','0','0','0','0','2','0','','18867-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 422.50, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 422.50
                where sellbilldetailid = 51790;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-06-10', 440, 430, 430
                    , 422.5, 430, 422.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+422.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+422.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-06-10', 440, 430, 430
                    , 422.5, 430, 422.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+422.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+422.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-06-10 23:59:29' WHERE storedetailid = '6325';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '5', '1', '1', '17471', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '7', '2024-06-10 23:59:29','0','0');
UPDATE save SET  savecurrentvalue = '84575',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('84135.00','440', '0', '5', 'اضافة فاتورة مبيعات', '17471', '84575', '2024-06-10 23:59:29', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-06-10', 440, 430, 430
                    , 422.5, 430, 422.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+422.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+422.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-06-10', 440, 430, 430
                    , 422.5, 430, 422.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+422.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+422.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 440, 430, 430
                    , 422.5, 430, 422.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+440, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+422.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+422.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 06667691598bd8 and sellbillId = 17471 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:29:30";
UPDATE user SET loginip = "197.192.234.157", lastactivetime = "2024-06-10 23:59:30", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:59:30', '7', 'addsellBill', '197.192.234.157', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-06-10 20:29:59";
UPDATE user SET loginip = "197.32.244.59", lastactivetime = "2024-06-10 23:59:59", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-06-10 23:59:59', '3', 'addsellBill', '197.32.244.59', '', 'DESKTOP');
