UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:32:20";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:02:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 00:02:20', '1', 'all', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:32:53";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:02:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:02:53', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:33:20";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:03:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:03:20', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:35:47";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:05:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:05:47', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:36:02";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:06:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:06:02', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:36:06";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:06:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:06:06', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:36:21";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:06:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:06:22', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '380.00', productSellUnitPrice = '460.00', productSellHalfPrice = '390.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '390',meanbuyprice_withDiscount = '390' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:06:38',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:06:38', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '390.00',meanbuyprice_withDiscount = '390' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:06:42',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:06:42', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '410', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '390.00',meanbuyprice_withDiscount = '390' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:06:46',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:06:46', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '380', productSellHalfPrice = '410.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '390.00',meanbuyprice_withDiscount = '390' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:07:00',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:07:00', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '400.00', productSellUnitPrice = '380.00', productSellHalfPrice = '410.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '370',meanbuyprice_withDiscount = '370' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:07:35',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:07:35', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350', productSellUnitPrice = '350', productSellHalfPrice = '350', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '370.00',meanbuyprice_withDiscount = '370' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:07:46',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:07:46', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '350.00', productSellHalfPrice = '360', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '370.00',meanbuyprice_withDiscount = '370' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:07:54',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:07:54', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '380', productSellHalfPrice = '360.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '370.00',meanbuyprice_withDiscount = '370' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 00:07:58',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 00:07:58', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:38:15";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:08:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:08:15', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:38:25";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:08:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:08:25', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:38:28";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:08:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:08:28', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:38:39";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:08:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:08:39', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:38:42";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:08:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:08:42', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:40:10";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:10:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:10:10', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:40:12";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:10:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:10:12', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:40:15";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:10:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:10:16', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:40:33";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:10:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:10:34', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '400', productSellAllPrice = '460.00', productSellUnitPrice = '540.00', productSellHalfPrice = '470.00', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 00:10:49',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 00:10:49', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400', productSellUnitPrice = '400', productSellHalfPrice = '400', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 00:10:58',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 00:10:58', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '400.00', productSellHalfPrice = '410', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 00:11:05',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 00:11:05', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '430', productSellHalfPrice = '410.00', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 00:11:13',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 00:11:13', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:41:21";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:11:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:11:21', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:41:26";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:11:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:11:26', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:41:30";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:11:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:11:30', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:41:38";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:11:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:11:38', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:43:31";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:13:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:13:31', '1', 'addAndRetuen', '156.210.108.153', '', '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 0664a6b0ae084d
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(407,@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-05-20 00:11:38', '0664a6b0ae084d', '407', '10980.00', '21000', '0', '1', '10020', '10020', '0', '10020', '1', '2024-05-20 00:13:31', '', '1', '0', 'الحاج عبدالباسط الزقازيق', '1', '1', '3', '0', 'الحاج عبدالباسط الزقازيق', '24' ,'0','','','','','-1','0','0','0','0','0','10020','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '21000', userid = '1' WHERE clientid = '407';
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 ('407','10980.00','10020','0','اضافة فاتورة مبيعات','17058', '21000', '2024-05-20 00:13:31', '1', 'sellbillController.php', 'اضافة فاتورة مبيعات', '10020', '0', null, '0', null, null,'', '0','1','1','10020','1');
UPDATE client SET  inUse = 0 where clientid = 407;
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','01696', '17058', '1', '1696', '6', '430', '2580', '0', '', '1', '2024-05-20 00:13:31', '1696', '0.00', '0', '1','0','','','0','0','0','0','0','0','1','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 425.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 425.00
                where sellbilldetailid = 50663;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1696, '2024-05-20', 2580, 2400, 2700
                    , 2550, 2700, 2550, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2550
                            , 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+6
                        , 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-05-20', 2580, 2400, 2700
                    , 2550, 2700, 2550, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2550
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2550
                            , 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 = '57', userid = '1', storedetaildate = '2024-05-20 00:13:31' WHERE storedetailid = '6147';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1696', '1', '6', '1', '17058', 'اضافة فاتورة مبيعات', 'sellbillController.php', '63.00', '57', '1', '2024-05-20 00:13:31','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 ('400','01749', '17058', '1', '1749', '6', '430', '2580', '0', '', '1', '2024-05-20 00:13:31', '1749', '0.00', '0', '1','0','','','0','0','0','0','0','0','1','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 415.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 415.00
                where sellbilldetailid = 50664;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1749, '2024-05-20', 2580, 2400, 2580
                    , 2490, 2580, 2490, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2490
                            , 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+6
                        , 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-05-20', 2580, 2400, 2580
                    , 2490, 2580, 2490, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2580, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2490
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2580, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2490
                            , 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 = '116', userid = '1', storedetaildate = '2024-05-20 00:13:31' WHERE storedetailid = '6283';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1749', '1', '6', '1', '17058', 'اضافة فاتورة مبيعات', 'sellbillController.php', '122.00', '116', '1', '2024-05-20 00:13:31','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','01687', '17058', '1', '1687', '6', '380', '2280', '0', '', '1', '2024-05-20 00:13:31', '1687', '0.00', '0', '1','0','','','0','0','0','0','0','0','1','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 50665;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1687, '2024-05-20', 2280, 2100, 2280
                    , 2220, 2280, 2220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2280, sellCostBuyPrice =sellCostBuyPrice+2100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2220
                            , 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+6
                        , 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-05-20', 2280, 2100, 2280
                    , 2220, 2280, 2220, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2280, sellCostBuyPrice =sellCostBuyPrice+2100
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2280, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2220
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2280, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2220
                            , 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-05-20 00:13:31' WHERE storedetailid = '6126';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '1', '6', '1', '17058', 'اضافة فاتورة مبيعات', 'sellbillController.php', '30.00', '24', '1', '2024-05-20 00:13:31','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18785;
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','01680', '17058', '1', '1680', '6', '430', '2580', '0', '', '1', '2024-05-20 00:13:31', '1680', '0.00', '0', '1','0','','','0','0','0','0','0','0','1','0','','18785-1,');
UPDATE sellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50666;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1680, '2024-05-20', 2580, 2400, 2760
                    , 2580, 2760, 2580, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 6, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2580
                            , 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+6
                        , 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-05-20', 2580, 2400, 2760
                    , 2580, 2760, 2580, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2580, sellCostBuyPrice =sellCostBuyPrice+2400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2580
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2580
                            , 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-05-20 00:13:31' WHERE storedetailid = '6091';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1680', '1', '6', '1', '17058', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '0', '1', '2024-05-20 00:13:31','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 10020, 9300, 10320
                    , 9840, 10320, 9840, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10020, sellCostBuyPrice =sellCostBuyPrice+9300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+10320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+10320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9840
                            , 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 (407, '2024-05-20', 10020, 9300, 10320
                    , 9840, 10320, 9840, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+10020, sellCostBuyPrice =sellCostBuyPrice+9300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+10320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+9840
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+10320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+9840
                            , 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, 10020, 9300, 10320
                    , 9840, 10320, 9840, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+10020, netSellCostBuyPrice = netSellCostBuyPrice+9300
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+10320
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+9840
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+10320
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+9840
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664a6b0ae084d and sellbillId = 17058 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:43:32";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:13:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:13:32', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 20:49:28";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:19:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:19:28', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:00:53";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:30:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:30:53', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:00:54";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:30:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:30:54', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:01:06";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:31:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:31:06', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:01:14";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:31:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:31:14', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:01:16";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:31:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:31:16', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:01:18";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:31:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:31:18', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:01:20";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:31:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2024-05-20 00:31:20', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:09:50";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:39:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:39:50', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:10:08";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:40:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 00:40:08', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:12:36";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:42:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 00:42:36', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:13:24";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:43:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:43:24', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:13:37";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:43:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:43:37', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:13:47";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:43:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:43:47', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:16";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:44:16', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:18";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:44:18', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:20";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:44:20', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:31";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:44:31', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:31";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 00:44:31', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:32";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:44:32', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:37";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:44:37', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:14:46";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:44:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 00:44:46', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:15:06";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:45:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 00:45:06', '1', 'add', '156.210.108.153', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '8', '-1', '0', '43675.00', '50', '43725', '', '0', '2024-05-20 00:45:06', '1', 'settlementsaveController.php');
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('-1', '', '50', '1', ' خصم معالجة عجز  / ', '564', '-50', '2024-05-20', '1', 'supplierPayedDeptController.php', '', '0','8', '0','1','1','50','1');
UPDATE supplier SET  suppliercurrentDebt = '-50', userid = '1', supplierdate = '2024-05-20'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '50.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '564', supplierdebtchangeafter = '-50.00', supplierdebtchangedate = '2024-05-20 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '8',currencyId='1',conversionFactor='1',payedInCurrency='50',saveConversionFactor='1' WHERE supplierdebtchangeid = '939';
UPDATE save SET  savecurrentvalue = '43725',  userid = '1' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('43675.00','50', '0', '8', 'تسوية خزنة بالإضافة', '-1', '43725', '2024-05-20 00:45:06', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '28285' WHERE savedailyid = '28285';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '50', '50', '2024-05-20', '1', '0', '0', '2024-05-20 00:45:06','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10288', '142', '50', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2573516', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10288', '27', '50', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-131925', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:15:06";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:45:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 00:45:07', '1', 'sucess', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:15:08";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:45:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 00:45:08', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:15:17";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:45:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:45:17', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:15:17";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:45:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:45:18', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:16:30";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:46:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:46:30', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 21:16:54";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 00:46:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 00:46:54', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:05:51";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 01:35:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 01:35:51', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:31:34";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:01:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:01:34', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:31:46";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:01:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:01:46', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:31:57";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:01:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:01:58', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:32:12";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:02:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:02:12', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:32:21";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:02:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:02:21', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:32:35";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:02:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:02:35', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:32:44";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:02:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:02:44', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:34:09";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:04:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:04:09', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:35:46";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:05:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 02:05:46', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:36:04";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:06:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 02:06:04', '1', 'add', '156.210.108.153', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '5', '-1', '0', '10130.00', '25', '10155', '', '0', '2024-05-20 02:06:04', '1', 'settlementsaveController.php');
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('-1', '', '25', '1', ' خصم معالجة عجز  / ', '565', '-25', '2024-05-20', '1', 'supplierPayedDeptController.php', '', '0','5', '0','1','1','25','1');
UPDATE supplier SET  suppliercurrentDebt = '-25', userid = '1', supplierdate = '2024-05-20'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '25.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '565', supplierdebtchangeafter = '-25.00', supplierdebtchangedate = '2024-05-20 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='25',saveConversionFactor='1' WHERE supplierdebtchangeid = '940';
UPDATE save SET  savecurrentvalue = '10155',  userid = '1' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10130.00','25', '0', '5', 'تسوية خزنة بالإضافة', '-1', '10155', '2024-05-20 02:06:05', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '28286' WHERE savedailyid = '28286';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '25', '25', '2024-05-20', '1', '0', '0', '2024-05-20 02:06:05','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10289', '139', '25', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3101643', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10289', '27', '25', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-131950', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:36:05";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:06:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 02:06:05', '1', 'sucess', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:36:07";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:06:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 02:06:07', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:36:14";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:06:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:06:15', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-19 22:36:31";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 02:06:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 02:06:31', '1', 'show', '156.210.108.153', '', '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-05-20 05:32:54";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:02:54", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 09:02:54', '3', '', '197.32.164.122', '', '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-05-20',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-05-20',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-05-20 05:32: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-05-20 05:43:19";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:13:19", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-20 09:13:19', '3', '', '197.32.164.122', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:43:41";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:13:41", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-20 09:13:42', '3', 'add', '197.32.164.122', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'ملح', '', '5', '2024-05-20', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '43720',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('43725.00','5', '1', '8', 'إضافة مصروف', '5037', '43720', '2024-05-20 09:13:42', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5', '5', '2024-05-20', '3', '0', '0', '2024-05-20 09:13:42','اضافة اسم مصروف( ملح )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10290', '160', '5', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4500840', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10290', '142', '5', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2573521', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'ملح', expensesdetails = '', expensesValue = '5.00', expensesdate = '2024-05-20', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10290', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '5037';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:43:42";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:13:42", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-20 09:13:42', '3', 'sucess', '197.32.164.122', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:43:44";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:13:44", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-20 09:13:44', '3', 'show', '197.32.164.122', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:43:45";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:13:45", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 09:13:45', '3', '', '197.32.164.122', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:49: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-05-20 05:49:52";
UPDATE user SET loginip = "156.197.126.45", lastactivetime = "2024-05-20 09:19:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 09:19:52', '4', '', '156.197.126.45', '', '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-05-20 05:49:52";
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-05-20 05:49:57";
UPDATE user SET loginip = "156.197.126.45", lastactivetime = "2024-05-20 09:19:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 09:19:57', '4', 'addsellBill', '156.197.126.45', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 05:51:42";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 09:21:42", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 09:21:42', '3', 'addsellBill', '197.32.164.122', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 3;
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-05-20 08:45:06";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 12:15:06", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 12:15:06', '3', '', '197.32.164.122', '', '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-05-20 08:45:06";
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-05-20 08:48:35";
UPDATE user SET loginip = "197.32.164.122", lastactivetime = "2024-05-20 12:18:35", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 12:18:35', '3', 'addsellBill', '197.32.164.122', '', '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-05-20 08:53:30";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 12:23:30", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 12:23:30', '8', '', '154.183.25.101', '', '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-05-20 08:53:30";
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-05-20 08:53:34";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 12:23:34", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 12:23:34', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:08:17";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 12:38:17", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 12:38:17', '8', '', '154.183.25.101', '', '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-05-20 09:08:17";
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-05-20 09:15:24";
UPDATE user SET loginip = "156.197.126.45", lastactivetime = "2024-05-20 12:45:24", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 12:45:24', '4', '', '156.197.126.45', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:17:21";
UPDATE user SET loginip = "156.197.126.45", lastactivetime = "2024-05-20 12:47:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 12:47:21', '4', 'addsellBill', '156.197.126.45', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:17:40";
UPDATE user SET loginip = "156.197.126.45", lastactivetime = "2024-05-20 12:47:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 12:47:40', '4', 'addsellBill', '156.197.126.45', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:56:56";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:57:07";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:57:17";
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-05-20 09:58:18";
UPDATE user SET loginip = "197.192.204.135", lastactivetime = "2024-05-20 13:28:18", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 13:28:18', '7', '', '197.192.204.135', '', '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-05-20 09:58:18";
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-05-20 09:58:33";
UPDATE user SET loginip = "197.192.204.135", lastactivetime = "2024-05-20 13:28:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 13:28:33', '7', 'addsellBill', '197.192.204.135', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 09:58:35";
UPDATE user SET loginip = "197.192.204.135", lastactivetime = "2024-05-20 13:28:35", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 13:28:35', '7', 'addsellBill', '197.192.204.135', '', '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-05-20 10:16:13";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 13:46:13", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 13:46:13', '8', '', '154.183.25.101', '', '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-05-20 10:16:14";
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-05-20 10:28:14";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 13:58:14", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 13:58:14', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:30:42";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:00:42", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:00:42', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:40:46";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:10:46", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:10:46', '8', 'addAndRetuen', '154.183.25.101', '', '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 0664b2d5a4d360
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(356,@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-05-20 14:00:42', '0664b2d5a4d360', '356', '4320.00', '3475', '0', '1', '845', '845', '0', '-845', '6', '2024-05-20 14:10:46', '', '8', '0', 'ام محمود البيضه البلاد','6', '1', '5', '0', 'ام محمود البيضه البلاد', '2', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3475', userid = '8' WHERE clientid = '356';
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 ('356','4320.00','845','1','اضافة فاتورة مردوات مبيعات','5794', '3475', '2024-05-20 14:10:46', '8', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '845', '0', null, '0', null, null,'', '0','1','1','845','1');
UPDATE client SET  inUse = 0 where clientid = 356;
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 ('370.00', '01673', '5794', '1', '1673', '1', '420.00', '420', '0', '', '1', '0', '1673', '0.00', '0','6','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where returnsellbilldetailid = 12545;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1673, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 370, 370, 370
                    , 370, 370, 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+420, returnSellCostBuyPrice = returnSellCostBuyPrice+370, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+370
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+370, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+370
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+370
                            , 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 (6, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 420, 370, 370, 370
                    , 370, 370, 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+420, returnSellCostBuyPrice = returnSellCostBuyPrice+370, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+370
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+370, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+370
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+370
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '1', userid = '8', storedetaildate = '2024-05-20 14:10:46' WHERE storedetailid = '6200';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1673', '6', '1', '0', '5794', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '1', '8', '2024-05-20 14:10:46','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 ('395.00', '01529', '5794', '1', '1529', '1', '425.00', '425', '0', '', '1', '0', '1529', '0.00', '0','6','0','','','0','0','0','0','0','1');
UPDATE returnsellbilldetail SET  lastbuyprice = 395.00 , meanbuyprice = 395.00, lastbuyprice_withDiscount = 395.00, meanbuyprice_withDiscount = 395.00
                where returnsellbilldetailid = 12546;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1529, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 425, 395, 395, 395
                    , 395, 395, 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+425, returnSellCostBuyPrice = returnSellCostBuyPrice+395, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+395
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+395, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+395
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+395
                            , 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 (6, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 425, 395, 395, 395
                    , 395, 395, 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+425, returnSellCostBuyPrice = returnSellCostBuyPrice+395, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+395
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+395, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+395
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+395
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '1', userid = '8', storedetaildate = '2024-05-20 14:10:46' WHERE storedetailid = '5648';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1529', '6', '1', '0', '5794', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '1', '8', '2024-05-20 14:10:46','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 845, 765, 765, 765
                    , 765, 765, 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+845, returnSellCostBuyPrice = returnSellCostBuyPrice+765, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+765
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+765, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+765
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+765
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (356, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 845, 765, 765, 765
                    , 765, 765, 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+845, returnSellCostBuyPrice = returnSellCostBuyPrice+765, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+765
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+765, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+765
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+765
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -845, -765, -765
                    , -765, -765, -765, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-845, netSellCostBuyPrice = netSellCostBuyPrice+-765
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-765
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-765
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-765
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-765
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b2d5a4d360 and sellbillId = 5794 and returnsellbillId = 5794
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:40:46";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:10:46", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:10:47', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:40:53";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:10:53", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 14:10:53', '8', '', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:41:55";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:11:55", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:11:55', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:43:18";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:13:18", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:13:18', '8', 'addAndRetuen', '154.183.25.101', '', '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 0664b2ffbc46b7
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(356,@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-05-20 14:11:55', '0664b2ffbc46b7', '356', '3475.00', '3035', '0', '1', '440', '440', '0', '-440', '6', '2024-05-20 14:13:18', '', '8', '0', 'ام محمود البيضه البلاد','6', '1', '5', '0', 'ام محمود البيضه البلاد', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '3035', userid = '8' WHERE clientid = '356';
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 ('356','3475.00','440','1','اضافة فاتورة مردوات مبيعات','5795', '3035', '2024-05-20 14:13:18', '8', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','440','1');
UPDATE client SET  inUse = 0 where clientid = 356;
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', '01701', '5795', '1', '1701', '1', '440.00', '440', '0', '', '0', '0', '1701', '0.00', '0','6','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 297.75, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 297.75
                where returnsellbilldetailid = 12547;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1701, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 400, 1, 297.75
                    , 1, 297.75, 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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+297.75, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+297.75
                            , 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 (6, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 400, 1, 297.75
                    , 1, 297.75, 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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+297.75, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+297.75
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '8', storedetaildate = '2024-05-20 14:13:18' WHERE storedetailid = '6171';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '6', '1', '0', '5795', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '10.00', '11', '8', '2024-05-20 14:13:18','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 400, 1, 297.75
                    , 1, 297.75, 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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+297.75, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+297.75
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (356, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 440, 400, 1, 297.75
                    , 1, 297.75, 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+440, returnSellCostBuyPrice = returnSellCostBuyPrice+400, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+1
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+297.75, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+1
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+297.75
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -440, -400, -1
                    , -297.75, -1, -297.75, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-440, netSellCostBuyPrice = netSellCostBuyPrice+-400
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-1
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-297.75
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-1
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-297.75
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b2ffbc46b7 and sellbillId = 5795 and returnsellbillId = 5795
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:43:19";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:13:19", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:13:19', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:43:24";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:13:24", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 14:13:25', '8', '', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:43:27";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 14:13:27", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:13:27', '8', 'addsellBill', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 10:53:32";
UPDATE user SET loginip = "197.192.204.135", lastactivetime = "2024-05-20 14:23:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:23:32', '7', 'addsellBill', '197.192.204.135', '', '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-05-20 10:56:58";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 14:26:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 14:26:58', '1', '', '156.210.108.153', '', '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-05-20 10:56:59";
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-05-20 11:05:41";
UPDATE user SET loginip = "197.192.204.135", lastactivetime = "2024-05-20 14:35:41", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 14:35:41', '7', 'addsellBill', '197.192.204.135', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 8;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 11:58:53";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:28:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 15:28:55', '1', 'addsellBill', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:20:34";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:50:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:50:35', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:20:37";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:50:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:50:37', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:20:38";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:50:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:50:38', '1', '', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:20:52";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:50:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:50:52', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:22:48";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:52:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:52:48', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:23:48";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:53:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:53:48', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:24:53";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 15:54:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 15:54:53', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:32:40";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:02:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 16:02:40', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:39:04";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:09:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 16:09:05', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:40:45";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:10:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 16:10:45', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:41:54";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:11:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:11:55', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:41:57";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:11:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:11:57', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:41:59";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:11:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:11:59', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:45:00";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:15:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 16:15:00', '1', 'show', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:46:29";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:16:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:16:29', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:46:34";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:16:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:16:34', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:46:37";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:16:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:16:37', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:46:40";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:16:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:16:40', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:46:43";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:16:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:16:44', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:49:29";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:19:29", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:19:30', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:52:16";
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-05-20 12:52:22";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:22:22", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 16:22:22', '8', '', '154.183.25.101', '', '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-05-20 12:52:23";
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-05-20 12:52:28";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:22:28", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 16:22:28', '8', '', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:53:02";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:23:02", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 16:23:02', '8', 'show', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:53:07";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:23:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 16:23:07', '8', 'show', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:53:13";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:23:13", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 16:23:14', '8', 'show', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:53:27";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 16:23:27", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-05-20 16:23:27', '8', 'show', '154.183.25.101', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 12:56:29";
UPDATE user SET loginip = "156.210.108.153", lastactivetime = "2024-05-20 16:26:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:26:30', '1', 'showDetail', '156.210.108.153', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 13:18:26";
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-05-20 13:18:55";
UPDATE user SET loginip = "197.192.194.162", lastactivetime = "2024-05-20 16:48:55", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 16:48:56', '7', '', '197.192.194.162', '', '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-05-20 13:18:56";
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-05-20 13:20:16";
UPDATE user SET loginip = "197.192.194.162", lastactivetime = "2024-05-20 16:50:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:50:16', '7', 'addsellBill', '197.192.194.162', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 13:20:16";
UPDATE user SET loginip = "197.192.194.162", lastactivetime = "2024-05-20 16:50:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 16:50:16', '7', 'addsellBill', '197.192.194.162', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 13:33:44";
UPDATE user SET loginip = "154.183.25.101", lastactivetime = "2024-05-20 17:03:44", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 17:03:44', '8', '', '154.183.25.101', '', '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-05-20 13:33:44";
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-05-20 13:41:19";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 17:11:19", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 17:11:19', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 13:41:24";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 17:11:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 17:11:24', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:36:17";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:36:18";
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-05-20 14:36:35";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:06:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 18:06:35', '1', '', '156.210.41.61', '', '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-05-20 14:36: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-05-20 14:36:39";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:06:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 18:06:39', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:36:39";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:06:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 18:06:40', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:37:53";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:07:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 18:07:54', '1', 'add', '156.210.41.61', '', '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(2049,7,8,1698,5,'2024-05-20',1,0, '' ,0,0,0,0,0,'2024-05-20 18:07:54',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6161';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-07', 7, 1698, 0, 0
                    , 350.00, 2, 0, 0, 1, '2024-05-20 18:07:54')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-20 18:07:54' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-20', 7, 1698, 0, 0
                    , 350.00, -3, 0, 0, 1, '2024-05-20 18:07:54')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 18:07:54' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-04-07*350.00,3*2024-05-20*350.00," WHERE transferproductid = 8671;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '7', '5', '1', '8671', 'تحويل منتجات من المخزن', 'storemovementController.php', '4.00', '-1', '1', '2024-05-20','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6165';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-07', 8, 1698, 0, 0
                    , 350.00, 2, 0, 0, 1, '2024-05-20 18:07:54')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 18:07:54' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-20', 8, 1698, 0, 0
                    , 350.00, 3, 0, 0, 1, '2024-05-20 18:07:54')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 18:07:54' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '8', '5', '0', '8671', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '4.00', '9', '1', '2024-05-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:37:54";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:07:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 18:07:54', '1', 'editshow', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:38:58";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:08:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:08:58', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:38:58";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:08:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:08:58', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:39:12";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:09:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:09:12', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = '888مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01748',type ='0', expireDate = '0' , dailyentryId = '10233',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.5',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '13.95',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1748';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1748, 1,'2024-05-20 18:09:19',1)
                ON DUPLICATE KEY UPDATE productid = 1748, edited = 1, sysdate = '2024-05-20 18:09:19', userid = 1;
UPDATE product SET productName = '888مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01748',type ='0', expireDate = '0' , dailyentryId = '10233',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '13.95',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1748';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1748, 1,'2024-05-20 18:09:40',1)
                ON DUPLICATE KEY UPDATE productid = 1748, edited = 1, sysdate = '2024-05-20 18:09:40', userid = 1;
UPDATE product SET productName = '888مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01748',type ='0', expireDate = '0' , dailyentryId = '10233',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '13.95',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1748';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1748, 1,'2024-05-20 18:09:44',1)
                ON DUPLICATE KEY UPDATE productid = 1748, edited = 1, sysdate = '2024-05-20 18:09:44', userid = 1;
UPDATE product SET productName = '888مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '440.00', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01748',type ='0', expireDate = '0' , dailyentryId = '10233',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '13.95',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1748';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1748, 1,'2024-05-20 18:09:50',1)
                ON DUPLICATE KEY UPDATE productid = 1748, edited = 1, sysdate = '2024-05-20 18:09:50', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:39:58";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:09:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:09:59', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر 888', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01696',type ='0', expireDate = '0' , dailyentryId = '9975',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '427.5',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1696';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1696, 1,'2024-05-20 18:10:06',1)
                ON DUPLICATE KEY UPDATE productid = 1696, edited = 1, sysdate = '2024-05-20 18:10:06', userid = 1;
UPDATE product SET productName = 'مشجر 888', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01696',type ='0', expireDate = '0' , dailyentryId = '9975',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1696';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1696, 1,'2024-05-20 18:10:10',1)
                ON DUPLICATE KEY UPDATE productid = 1696, edited = 1, sysdate = '2024-05-20 18:10:10', userid = 1;
UPDATE product SET productName = 'مشجر 888', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01696',type ='0', expireDate = '0' , dailyentryId = '9975',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1696';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1696, 1,'2024-05-20 18:10:13',1)
                ON DUPLICATE KEY UPDATE productid = 1696, edited = 1, sysdate = '2024-05-20 18:10:13', userid = 1;
UPDATE product SET productName = 'مشجر 888', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '440.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01696',type ='0', expireDate = '0' , dailyentryId = '9975',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '427.50',meanbuyprice_withDiscount = '427.5' , productbuypricereal = '450.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1696';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1696, 1,'2024-05-20 18:10:18',1)
                ON DUPLICATE KEY UPDATE productid = 1696, edited = 1, sysdate = '2024-05-20 18:10:18', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:40:28";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:10:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:10:28', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = '1002مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01749',type ='0', expireDate = '0' , dailyentryId = '10234',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.5',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '4.65',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1749';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1749, 1,'2024-05-20 18:10:34',1)
                ON DUPLICATE KEY UPDATE productid = 1749, edited = 1, sysdate = '2024-05-20 18:10:34', userid = 1;
UPDATE product SET productName = '1002مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01749',type ='0', expireDate = '0' , dailyentryId = '10234',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '4.65',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1749';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1749, 1,'2024-05-20 18:10:40',1)
                ON DUPLICATE KEY UPDATE productid = 1749, edited = 1, sysdate = '2024-05-20 18:10:40', userid = 1;
UPDATE product SET productName = '1002مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01749',type ='0', expireDate = '0' , dailyentryId = '10234',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '4.65',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1749';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1749, 1,'2024-05-20 18:10:44',1)
                ON DUPLICATE KEY UPDATE productid = 1749, edited = 1, sysdate = '2024-05-20 18:10:44', userid = 1;
UPDATE product SET productName = '1002مشجر', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '440.00', productDate = '2024-05-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01749',type ='0', expireDate = '0' , dailyentryId = '10234',isService = '0',isOptic = '0',lastbuyprice = '430.00',lastbuyprice_withDiscount = '430',meanbuyprice = '422.50',meanbuyprice_withDiscount = '422.5' , productbuypricereal = '430.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.33' , buypart_precentage = '4.65',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1749';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1749, 1,'2024-05-20 18:10:48',1)
                ON DUPLICATE KEY UPDATE productid = 1749, edited = 1, sysdate = '2024-05-20 18:10:48', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:41:12";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:11:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:11:12', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:18',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:18', userid = 1;
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '440', productSellUnitPrice = '440', productSellHalfPrice = '440', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:21',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:21', userid = 1;
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '440.00', productSellUnitPrice = '440.00', productSellHalfPrice = '440', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:26',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:26', userid = 1;
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:32',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:32', userid = 1;
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '430.00', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:35',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:35', userid = 1;
UPDATE product SET productName = 'مشجر 100 ', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510.00', productSellHalfPrice = '440', productDate = '2024-04-07', conditions = '0', userId = '1', limitamount = '0', parcode = '01701',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '363.88',meanbuyprice_withDiscount = '363.88' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1701';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1701, 1,'2024-05-20 18:11:41',1)
                ON DUPLICATE KEY UPDATE productid = 1701, edited = 1, sysdate = '2024-05-20 18:11:41', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:41:50";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:11:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:11:50', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر 999', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01697',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '420',meanbuyprice_withDiscount = '420' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1697';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1697, 1,'2024-05-20 18:11:57',1)
                ON DUPLICATE KEY UPDATE productid = 1697, edited = 1, sysdate = '2024-05-20 18:11:57', userid = 1;
UPDATE product SET productName = 'مشجر 999', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01697',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '420.00',meanbuyprice_withDiscount = '420' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1697';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1697, 1,'2024-05-20 18:12:00',1)
                ON DUPLICATE KEY UPDATE productid = 1697, edited = 1, sysdate = '2024-05-20 18:12:00', userid = 1;
UPDATE product SET productName = 'مشجر 999', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01697',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '420.00',meanbuyprice_withDiscount = '420' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1697';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1697, 1,'2024-05-20 18:12:05',1)
                ON DUPLICATE KEY UPDATE productid = 1697, edited = 1, sysdate = '2024-05-20 18:12:05', userid = 1;
UPDATE product SET productName = 'مشجر 999', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '440.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01697',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450.00',lastbuyprice_withDiscount = '450',meanbuyprice = '420.00',meanbuyprice_withDiscount = '420' , productbuypricereal = '390.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.56' , buypart_precentage = '12.82',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1697';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1697, 1,'2024-05-20 18:12:08',1)
                ON DUPLICATE KEY UPDATE productid = 1697, edited = 1, sysdate = '2024-05-20 18:12:08', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:42:36";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:12:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:12:36', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:42:36";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:12:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:12:37', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:43:12";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:13:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:13:12', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:43:43";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:13:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:13:43', '1', 'add', '156.210.41.61', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6282';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1748', '1', '42', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '42.00', '0', '1', '2024-05-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:43:45";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:13:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:13:45', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:44:12";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:14:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:14:12', '1', 'add', '156.210.41.61', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '99', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6147';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1696', '1', '42', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '57.00', '99', '1', '2024-05-20','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:44:14";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:14:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:14:14', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:45:31";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:15:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:15:31', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:55:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:25:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:25:20', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:55:30";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:25:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:25:31', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:55:43";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:25:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:25:43', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'ص 21', productDescription = '', productCatId = '1', productBuyPrice = '360.00', productSellAllPrice = '360.00', productSellUnitPrice = '440', productSellHalfPrice = '370.01', productDate = '2024-02-25', conditions = '0', userId = '1', limitamount = '0', parcode = '01588',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '410.00',lastbuyprice_withDiscount = '410',meanbuyprice = '385.00',meanbuyprice_withDiscount = '385' , productbuypricereal = '360.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.78' , buypart_precentage = '13.89',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1588';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1588, 1,'2024-05-20 18:26:24',1)
                ON DUPLICATE KEY UPDATE productid = 1588, edited = 1, sysdate = '2024-05-20 18:26:24', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:56:50";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:26:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:26:50', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:56:53";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:26:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 18:26:53', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:56:57";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:26:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:26:57', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:57:39";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:27:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:27:39', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:57:50";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:27:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:27:50', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'ست الحبايب 475', productDescription = '', productCatId = '1', productBuyPrice = '365.00', productSellAllPrice = '385.00', productSellUnitPrice = '445', productSellHalfPrice = '395.00', productDate = '2024-05-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01752',type ='0', expireDate = '0' , dailyentryId = '10238',isService = '0',isOptic = '0',lastbuyprice = '365.00',lastbuyprice_withDiscount = '365',meanbuyprice = '365.00',meanbuyprice_withDiscount = '365' , productbuypricereal = '365.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '5.48' , buyhalf_precentage = '8.22' , buypart_precentage = '13.70',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1752';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1752, 1,'2024-05-20 18:28:08',1)
                ON DUPLICATE KEY UPDATE productid = 1752, edited = 1, sysdate = '2024-05-20 18:28:08', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:58:15";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:28:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:28:15', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:58:27";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:28:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:28:28', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 14:59:28";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:29:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:29:28', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'ست الحبايب473', productDescription = '', productCatId = '1', productBuyPrice = '360.00', productSellAllPrice = '380.00', productSellUnitPrice = '440', productSellHalfPrice = '390.00', productDate = '2024-05-08', conditions = '0', userId = '1', limitamount = '0', parcode = '01753',type ='0', expireDate = '0' , dailyentryId = '10239',isService = '0',isOptic = '0',lastbuyprice = '360.00',lastbuyprice_withDiscount = '360',meanbuyprice = '360.00',meanbuyprice_withDiscount = '360' , productbuypricereal = '360.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '5.56' , buyhalf_precentage = '8.33' , buypart_precentage = '13.89',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1753';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1753, 1,'2024-05-20 18:29:44',1)
                ON DUPLICATE KEY UPDATE productid = 1753, edited = 1, sysdate = '2024-05-20 18:29:44', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:01:31";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:31:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:31:31', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:03:51";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:33:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:33:51', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:04:21";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:34:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:34:21', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:04:53";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:34:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 18:34:53', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:05:22";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:35:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 18:35:22', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:05:31";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:35:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:35:31', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:05:36";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:35:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:35:36', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:05:38";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:35:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:35:39', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:05:42";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:35:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 18:35:42', '1', 'editprint', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:09:01";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:39:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 18:39:01', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:14:17";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:44:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:44:17', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:18:38";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:48:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:48:38', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:18:51";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:48:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 18:48:51', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:20:03";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:50:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:50:03', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:20:03";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:50:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:50:03', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:20:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:50:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 18:50:20', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:20:31";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 18:50:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('buyreport.php', '2024-05-20 18:50:31', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:35:37";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:05:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 19:05:37', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:36:08";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:06:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 19:06:08', '1', 'add', '156.210.41.61', '', '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(2050,5,1,1560,6,'2024-05-20',1,0, '' ,0,0,0,0,0,'2024-05-20 19:06:08',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '5698';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 5, 1560, 0, 0
                    , 350.00, 3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-3, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-20', 5, 1560, 0, 0
                    , 350.00, -3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2024-02-25*350.00,3*2024-05-20*350.00," WHERE transferproductid = 8672;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1560', '5', '6', '1', '8672', 'تحويل منتجات من المخزن', 'storemovementController.php', '6.00', '0', '1', '2024-05-20','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '5597';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1560, 0, 0
                    , 350.00, 3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-05-20', 1, 1560, 0, 0
                    , 350.00, 3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1560', '1', '6', '0', '8672', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '14.00', '20', '1', '2024-05-20','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('5', '1', '1673', '4', '2024-05-20', '1', '0','2050',null,null,'2024-05-20 19:06:08',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6078';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-27', 5, 1673, 0, 0
                    , 370.00, 3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-3, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 5, 1673, 0, 0
                    , 370.00, 1, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-1, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "3*2024-03-27*370.00,1*2024-03-30*370.00," WHERE transferproductid = 8673;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1673', '5', '4', '1', '8673', 'تحويل منتجات من المخزن', 'storemovementController.php', '4.00', '0', '1', '2024-05-20','0','0');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-05-20' WHERE storedetailid = '6074';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-27', 1, 1673, 0, 0
                    , 370.00, 3, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+3, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 1, 1673, 0, 0
                    , 370.00, 1, 0, 0, 1, '2024-05-20 19:06:08')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-05-20 19:06:08' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1673', '1', '4', '0', '8673', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '4', '1', '2024-05-20','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:36:09";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:06:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-05-20 19:06:09', '1', 'editshow', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:36: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-05-20 15:36:54";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 19:06:54", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 19:06:54', '7', '', '197.192.200.251', '', '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-05-20 15:36:55";
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-05-20 15:36:57";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 19:06:57", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 19:06:58', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:53:38";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:23:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 19:23:38', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:53:53";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:23:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 19:23:53', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '430.00', productSellHalfPrice = '410.00', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 19:24:15',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 19:24:15', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 19:24:19',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 19:24:19', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 19:24:22',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 19:24:22', userid = 1;
UPDATE product SET productName = 'مشجر جديد 555', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '510', productSellHalfPrice = '440.00', productDate = '2024-03-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01680',type ='0', expireDate = '0' , dailyentryId = '9899',isService = '0',isOptic = '0',lastbuyprice = '460.00',lastbuyprice_withDiscount = '460',meanbuyprice = '430.00',meanbuyprice_withDiscount = '430' , productbuypricereal = '460.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.17' , buypart_precentage = '10.87',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1680';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1680, 1,'2024-05-20 19:24:39',1)
                ON DUPLICATE KEY UPDATE productid = 1680, edited = 1, sysdate = '2024-05-20 19:24:39', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:54:54";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:24:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('buyreport.php', '2024-05-20 19:24:54', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:55:25";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:25:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('buyreport.php', '2024-05-20 19:25:25', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:55:49";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:25:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 19:25:49', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:56:34";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:26:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 19:26:34', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:56:50";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:26:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 19:26:50', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '480', productSellHalfPrice = '410.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '307.75',meanbuyprice_withDiscount = '307.75' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:27:17',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:27:17', userid = 1;
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '400.00', productSellAllPrice = '400.00', productSellUnitPrice = '480.00', productSellHalfPrice = '410.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '307.75',meanbuyprice_withDiscount = '307.75' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:27:25',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:27:25', userid = 1;
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '430', productSellAllPrice = '400.00', productSellUnitPrice = '480.00', productSellHalfPrice = '410.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '368.88',meanbuyprice_withDiscount = '368.88' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:27:34',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:27:34', userid = 1;
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430', productSellUnitPrice = '430', productSellHalfPrice = '430', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '368.88',meanbuyprice_withDiscount = '368.88' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:27:38',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:27:38', userid = 1;
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '430.00', productSellHalfPrice = '440', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '368.88',meanbuyprice_withDiscount = '368.88' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:27:46',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:27:46', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 15:58:03";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 19:28:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 19:28:04', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'ص 29', productDescription = '', productCatId = '1', productBuyPrice = '430.00', productSellAllPrice = '430.00', productSellUnitPrice = '480', productSellHalfPrice = '440.00', productDate = '2024-04-03', conditions = '0', userId = '1', limitamount = '0', parcode = '01695',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '1.00',lastbuyprice_withDiscount = '1',meanbuyprice = '368.88',meanbuyprice_withDiscount = '368.88' , productbuypricereal = '400.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.50' , buypart_precentage = '12.50',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1695';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1695, 1,'2024-05-20 19:29:19',1)
                ON DUPLICATE KEY UPDATE productid = 1695, edited = 1, sysdate = '2024-05-20 19:29:19', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:38:15";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:08:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:08:15', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:39:16";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:09:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:09:16', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:39:24";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:09:25", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:09:25', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:39:43";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:09:43", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:09:43', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:39:50";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:09:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:09:50', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:40:50";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:10:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:10:50', '7', 'addAndRetuen', '197.192.200.251', '', '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 0664b91eeaad17
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(149,@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-05-20 21:09:50', '0664b91eeaad17', '149', '1035.00', '1035', '0', '1', '810', '810', '810', '0', '5', '2024-05-20 21:10:50', '', '7', '0', 'ام احمد الجوهري اسكندريه', '5', '1', '3', '0', 'ام احمد الجوهري اسكندريه', '2' ,'0','','','','','-1','0','0','0','0','0','810','0','','0','0','810','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '1035', userid = '7' WHERE clientid = '149';
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 ('149','1035.00','0','0','اضافة فاتورة مبيعات','17059', '1035', '2024-05-20 21:10:50', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '810', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE client SET  inUse = 0 where clientid = 149;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '17059', '1', '1581', '1', '450.00', '450', '0', '', '0', '2024-05-20 21:10:50', '1581', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','18299-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 50667;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-05-20', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, 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-05-20', 450, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, 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 = '31', userid = '7', storedetaildate = '2024-05-20 21:10:50' WHERE storedetailid = '5688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '1', '1', '17059', 'اضافة فاتورة مبيعات', 'sellbillController.php', '32.00', '31', '7', '2024-05-20 21:10:50','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18572;
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','01521', '17059', '1', '1521', '1', '360', '360', '0', '', '0', '2024-05-20 21:10:50', '1521', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','18572-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 50668;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1521, '2024-05-20', 360, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , 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-05-20', 360, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+360, sellCostBuyPrice =sellCostBuyPrice+330
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+330, sellCostMeanBuyPrice = sellCostMeanBuyPrice+330
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+330, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+330
                            , 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 = '7', storedetaildate = '2024-05-20 21:10:50' WHERE storedetailid = '6278';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1521', '5', '1', '1', '17059', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '12', '7', '2024-05-20 21:10:50','0','0');
UPDATE save SET  savecurrentvalue = '10965',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10155.00','810', '0', '5', 'اضافة فاتورة مبيعات', '17059', '10965', '2024-05-20 21:10:50', '7',  'sellbillController.php','149','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 810, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , 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 (149, '2024-05-20', 810, 780, 780
                    , 780, 780, 780, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+810, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+780, sellCostMeanBuyPrice = sellCostMeanBuyPrice+780
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+780, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+780
                            , 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, 810, 780, 780
                    , 780, 780, 780, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+810, netSellCostBuyPrice = netSellCostBuyPrice+780
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+780
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+780
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+780
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+780
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b91eeaad17 and sellbillId = 17059 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:40:51";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:10:51", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:10:51', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:40:55";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:10:56", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:10:56', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:41:32";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:11:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:11:32', '7', 'addAndRetuen', '197.192.200.251', '', '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 0664b92304403e
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(149,@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-05-20 21:10:56', '0664b92304403e', '149', '1035.00', '605', '0', '1', '430', '430', '0', '-430', '5', '2024-05-20 21:11:32', '', '7', '0', 'ام احمد الجوهري اسكندريه','5', '1', '5', '0', 'ام احمد الجوهري اسكندريه', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '605', userid = '7' WHERE clientid = '149';
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 ('149','1035.00','430','1','اضافة فاتورة مردوات مبيعات','5796', '605', '2024-05-20 21:11:32', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '430', '0', null, '0', null, null,'', '0','1','1','430','1');
UPDATE client SET  inUse = 0 where clientid = 149;
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', '01570', '5796', '1', '1570', '1', '430', '430', '0', '', '0', '0', '1570', '0.00', '0','5','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 = 12548;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1570, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 410, 410, 410
                    , 410, 410, 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+430, returnSellCostBuyPrice = returnSellCostBuyPrice+410, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+410
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+410, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+410
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+410
                            , 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-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 410, 410, 410
                    , 410, 410, 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+430, returnSellCostBuyPrice = returnSellCostBuyPrice+410, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+410
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+410, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+410
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+410
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '1', userid = '7', storedetaildate = '2024-05-20 21:11:32' WHERE storedetailid = '6243';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1570', '5', '1', '0', '5796', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '1', '7', '2024-05-20 21:11:32','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 410, 410, 410
                    , 410, 410, 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+430, returnSellCostBuyPrice = returnSellCostBuyPrice+410, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+410
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+410, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+410
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+410
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (149, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 430, 410, 410, 410
                    , 410, 410, 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+430, returnSellCostBuyPrice = returnSellCostBuyPrice+410, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+410
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+410, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+410
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+410
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -430, -410, -410
                    , -410, -410, -410, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-430, netSellCostBuyPrice = netSellCostBuyPrice+-410
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-410
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-410
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-410
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-410
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b92304403e and sellbillId = 5796 and returnsellbillId = 5796
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:41:33";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:11:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:11:33', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:41:43";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:11:43", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:11:43', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:42:33";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:12:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:12:33', '7', 'addAndRetuen', '197.192.200.251', '', '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 0664b925f7dc40
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(89,@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-05-20 21:11:43', '0664b925f7dc40', '89', '25.00', '385', '0', '1', '1170', '1170', '810', '360', '5', '2024-05-20 21:12:33', '', '7', '0', 'ام محمد نوح', '5', '1', '3', '0', 'ام محمد نوح', '3' ,'0','','','','','-1','0','0','0','0','0','1170','0','','0','0','810','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '385', userid = '7' WHERE clientid = '89';
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 ('89','25.00','360','0','اضافة فاتورة مبيعات','17060', '385', '2024-05-20 21:12:33', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1170', '0', null, '0', null, null,'', '0','1','1','360','1');
UPDATE client SET  inUse = 0 where clientid = 89;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+3 where id = 18025;
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 ('390','01689', '17060', '1', '1689', '3', '390', '1170', '0', '', '0', '2024-05-20 21:12:33', '1689', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','18025-3,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 50669;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1689, '2024-05-20', 1170, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 3, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1170, 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
                        , 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-05-20', 1170, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1170, 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;
UPDATE storedetail SET  productquantity = '6', userid = '7', storedetaildate = '2024-05-20 21:12:33' WHERE storedetailid = '6142';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1689', '5', '3', '1', '17060', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '6', '7', '2024-05-20 21:12:33','0','0');
UPDATE save SET  savecurrentvalue = '11775',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10965.00','810', '0', '5', 'اضافة فاتورة مبيعات', '17060', '11775', '2024-05-20 21:12:33', '7',  'sellbillController.php','89','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 1170, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1170, 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 (89, '2024-05-20', 1170, 1170, 1170
                    , 1170, 1170, 1170, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1170, 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, 1170, 1170, 1170
                    , 1170, 1170, 1170, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1170, netSellCostBuyPrice = netSellCostBuyPrice+1170
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1170
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1170
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b925f7dc40 and sellbillId = 17060 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:42:34";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:12:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:12:34', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:42:39";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:12:39", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:12:39', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:43:08";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:13:08", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:13:08', '7', 'addAndRetuen', '197.192.200.251', '', '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 0664b9297a858a
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(89,@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-05-20 21:12:39', '0664b9297a858a', '89', '385.00', '25', '0', '1', '360', '360', '0', '-360', '5', '2024-05-20 21:13:08', '', '7', '0', 'ام محمد نوح','5', '1', '5', '0', 'ام محمد نوح', '1', '0', '', '','','','-1','0','0','0','','0','0','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '25', userid = '7' WHERE clientid = '89';
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 ('89','385.00','360','1','اضافة فاتورة مردوات مبيعات','5797', '25', '2024-05-20 21:13:08', '7', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '360', '0', null, '0', null, null,'', '0','1','1','360','1');
UPDATE client SET  inUse = 0 where clientid = 89;
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 ('330.00', '01525', '5797', '1', '1525', '1', '360', '360', '0', '', '0', '0', '1525', '0.00', '0','5','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where returnsellbilldetailid = 12549;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1525, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 330, 330, 330
                    , 330, 330, 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+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                            , 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-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 330, 330, 330
                    , 330, 330, 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+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '1', userid = '7', storedetaildate = '2024-05-20 21:13:08' WHERE storedetailid = '6079';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1525', '5', '1', '0', '5797', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '0.00', '1', '7', '2024-05-20 21:13:08','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 330, 330, 330
                    , 330, 330, 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+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (89, '2024-05-20', 0, 0, 0
                    , 0, 0, 0, 0
                    , 360, 330, 330, 330
                    , 330, 330, 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+330, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+330
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+330, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+330
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+330
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -360, -330, -330
                    , -330, -330, -330, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-360, netSellCostBuyPrice = netSellCostBuyPrice+-330
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-330
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-330
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-330
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-330
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b9297a858a and sellbillId = 5797 and returnsellbillId = 5797
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:43:09";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:13:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:13:09', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:43:23";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:13:23", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:13:23', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:43:34";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:13:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:13:34', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:01";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:01", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:01', '7', 'addAndRetuen', '197.192.200.251', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664b92ce85989
-- ----------------------------------------------------------------------------------------------------

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-05-20 21:13:34', '0664b92ce85989', '1', '0.00', '0', '5', '1', '405', '400', '400', '0', '5', '2024-05-20 21:14:01', '', '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','اضافة فاتورة مبيعات','17061', '0', '2024-05-20 21:14:01', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '400', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17785;
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 ('345','01524', '17061', '1', '1524', '1', '405', '405', '0', '', '1', '2024-05-20 21:14:01', '1524', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','17785-1,');
UPDATE sellbilldetail SET  lastbuyprice = 345.00 , meanbuyprice = 345.00, lastbuyprice_withDiscount = 345.00, meanbuyprice_withDiscount = 345.00
                where sellbilldetailid = 50670;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1524, '2024-05-20', 400, 345, 345
                    , 345, 345, 345, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , 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-05-20', 400, 345, 345
                    , 345, 345, 345, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , 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 = '7', storedetaildate = '2024-05-20 21:14:01' WHERE storedetailid = '5703';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1524', '5', '1', '1', '17061', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '7', '2024-05-20 21:14:01','0','0');
UPDATE save SET  savecurrentvalue = '12175',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('11775.00','400', '0', '5', 'اضافة فاتورة مبيعات', '17061', '12175', '2024-05-20 21:14:01', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 400, 345, 345
                    , 345, 345, 345, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , 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-05-20', 400, 345, 345
                    , 345, 345, 345, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+400, sellCostBuyPrice =sellCostBuyPrice+345
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+345, sellCostMeanBuyPrice = sellCostMeanBuyPrice+345
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+345, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+345
                            , 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, 345, 345
                    , 345, 345, 345, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+400, netSellCostBuyPrice = netSellCostBuyPrice+345
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+345
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+345
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+345
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+345
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b92ce85989 and sellbillId = 17061 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:02";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:02', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:33";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:33', '7', 'addAndRetuen', '197.192.200.251', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664b92ea691ba
-- ----------------------------------------------------------------------------------------------------

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-05-20 21:14:02', '0664b92ea691ba', '1', '0.00', '0', '30', '1', '530', '500', '500', '0', '5', '2024-05-20 21:14:33', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','500','0','','0','0','500','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','اضافة فاتورة مبيعات','17062', '0', '2024-05-20 21:14:33', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '500', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 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', '17062', '1', '1581', '1', '530', '530', '0', '', '1', '2024-05-20 21:14:33', '1581', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18299-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 50671;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1581, '2024-05-20', 500, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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-05-20', 500, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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 = '30', userid = '7', storedetaildate = '2024-05-20 21:14:33' WHERE storedetailid = '5688';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '1', '1', '17062', 'اضافة فاتورة مبيعات', 'sellbillController.php', '31.00', '30', '7', '2024-05-20 21:14:33','0','0');
UPDATE save SET  savecurrentvalue = '12675',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('12175.00','500', '0', '5', 'اضافة فاتورة مبيعات', '17062', '12675', '2024-05-20 21:14:33', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 500, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-05-20', 500, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+500, 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 500, 450, 450
                    , 450, 450, 450, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+500, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b92ea691ba and sellbillId = 17062 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:34";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:34', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:58";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:58', '7', 'addAndRetuen', '197.192.200.251', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664b930ab659a
-- ----------------------------------------------------------------------------------------------------

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-05-20 21:14:34', '0664b930ab659a', '1', '0.00', '0', '20', '1', '440', '420', '420', '0', '5', '2024-05-20 21:14:58', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','420','0','','0','0','420','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','اضافة فاتورة مبيعات','17063', '0', '2024-05-20 21:14:59', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '420', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18025;
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 ('390','01689', '17063', '1', '1689', '1', '440', '440', '0', '', '1', '2024-05-20 21:14:59', '1689', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18025-1,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 50672;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1689, '2024-05-20', 420, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-05-20', 420, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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 = '7', storedetaildate = '2024-05-20 21:14:59' WHERE storedetailid = '6142';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1689', '5', '1', '1', '17063', 'اضافة فاتورة مبيعات', 'sellbillController.php', '6.00', '5', '7', '2024-05-20 21:14:59','0','0');
UPDATE save SET  savecurrentvalue = '13095',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('12675.00','420', '0', '5', 'اضافة فاتورة مبيعات', '17063', '13095', '2024-05-20 21:14:59', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 420, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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-05-20', 420, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+420, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+390, sellCostMeanBuyPrice = sellCostMeanBuyPrice+390
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+390, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+390
                            , 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, 420, 390, 390
                    , 390, 390, 390, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+420, netSellCostBuyPrice = netSellCostBuyPrice+390
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+390
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+390
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+390
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+390
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664b930ab659a and sellbillId = 17063 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:44:59";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:14:59", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:14:59', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:45:09";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:15:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:15:09', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:45:13";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:15:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:15:13', '7', 'showDetail', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:46:02";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:16:02", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:16:02', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:46:03";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:16:03", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:16:03', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:52:04";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:22:04", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:22:04', '7', 'showDetail', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:52:24";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:22:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:22:24', '7', '', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:54:38";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:24:38", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:24:38', '7', 'showDetail', '197.192.200.251', '', '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-05-20 17:57:07";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:27:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 21:27:07', '8', '', '197.63.232.89', '', '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-05-20 17:57: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 lastactivetime < "2024-05-20 17:57:16";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:27:16", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:27:16', '8', 'addsellBill', '197.63.232.89', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:57:42";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:27:42", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-05-20 21:27:42', '8', '', '197.63.232.89', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:57:45";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:27:45", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 21:27:45', '8', '', '197.63.232.89', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:59:03";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:29:04", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 21:29:04', '8', 'add', '197.63.232.89', '', '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 =25264
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(356,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '1365' , clientdate = '2024-05-20 21:29:04', userid = '8' WHERE clientid = '356';
UPDATE client SET  inUse = 0 where clientid = 356;
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 ('356','3035.00','1670','1','ايصال تحصيل (( قبض من عميل ))','25264', '1365', '2024-05-20 21:27:45', '8', 'clientPayedDeptController.php', '   ', '1670', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '22770',  userid = '8' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('21100.00','1670', '0', '6', 'ايصال تحصيل (( قبض من عميل ))', '25264', '22770', '2024-05-20 21:29:04', '8',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1670', '1670', '2024-05-20', '8', '0', '0', '2024-05-20 21:29:04','اضافة ايصال سداد للعميل ام محمود البيضه البلاد','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10291', '140', '1670', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1889237', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10291', '432', '1670', '','0');
UPDATE accountstree SET name = 'ام محمود البيضه البلاد', customName = 'ام محمود البيضه البلاد', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2023-03-24', itemtype2 = '1', theValue = '-15095', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '432';
UPDATE clientdebtchange SET clientid = '356', clientdebtchangebefore = '3035.00', clientdebtchangeamount = '1670.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '25264', clientdebtchangeafter = '1365.00', clientdebtchangedate = '2024-05-20 21:27:45', userid = '8', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '1670.00',discount='', reciptid=null, dailyentryid = '10291',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '25264';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:59:05";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:29:05", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 21:29:05', '8', 'sucess', '197.63.232.89', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:59:07";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:29:07", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 21:29:07', '8', 'show', '197.63.232.89', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 17:59:08";
UPDATE user SET loginip = "197.63.232.89", lastactivetime = "2024-05-20 21:29:08", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:29:09', '8', '', '197.63.232.89', '', '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-05-20 18:16:49";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 21:46:49", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 21:46:49', '3', '', '197.32.190.38', '', '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-05-20 18:16:49";
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-05-20 18:17:00";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 21:47:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:47:00', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:17:05";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 21:47:05", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 21:47:05', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:19:09";
UPDATE user SET loginip = "197.192.200.251", lastactivetime = "2024-05-20 21:49:09", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 21:49:09', '7', 'addsellBill', '197.192.200.251', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:38:38";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:08:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:08:38', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:38:50";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:08:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:08:50', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:40:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:10:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:10:20', '1', 'add', '156.210.41.61', '', 'DESKTOP');
BEGIN;
INSERT INTO transfermoney (saveidfrom, saveidto, transfermoneyvalue, transfermoneydate, userid, conditions, dailyentryid , comment) VALUES ('8','9', '40000', '2024-05-20', '1', '0', '0','20000/ للشيخ عبد اللطيف     /20000لعصام حرحيرة\r\n');
UPDATE save SET  savecurrentvalue = '3720',  userid = '1' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('43720.00','40000', '1', '8', 'تحويل امول الى الخزنة  [ الشيخ وليد ] ', '706', '3720', '2024-05-20 22:10:20', '1',  'transfermoneyController.php','0','');
UPDATE save SET  savecurrentvalue = '8223465',  userid = '1' WHERE saveid = '9';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8183465.00','40000', '0', '9', 'تحويل امول من الخزنة  [ خزينة محل ابو كريم ] ', '706', '8223465', '2024-05-20 22:10:20', '1',  'transfermoneyController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '40000', '40000', '2024-05-20', '1', '0', '0', '2024-05-20 22:10:20','اضافة تحويل من خزينة محل ابو كريم الى الشيخ وليد','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10292', '156', '40000', '','0');
UPDATE accountstree SET name = 'الشيخ وليد', customName = 'الشيخ وليد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-09', itemtype2 = '1', theValue = '8223465', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '156';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10292', '142', '40000', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2613521', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE transfermoney SET saveidfrom = '8', saveidto = '9', transfermoneyvalue = '40000.00', transfermoneydate = '2024-05-20', userid = '1', conditions = '0' , dailyentryid = '10292' , comment = '20000/ للشيخ عبد اللطيف     /20000لعصام حرحيرة\r\n' WHERE transfermoneyid = '706';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:40:21";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:10:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:10:21', '1', 'sucess', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:40:23";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:10:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:10:23', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:40:42";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:10:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('saveController.php', '2024-05-20 22:10:42', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:40:51";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:10:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 22:10:51', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:42:17";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:12:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 22:12:17', '1', 'add', '156.210.41.61', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '8', '-1', '0', '3720.00', '520', '4240', '400/ شغل خاص بالشيخ وليد  /120زيادة درج', '0', '2024-05-20 22:12:17', '1', 'settlementsaveController.php');
INSERT INTO supplierdebtchange (supplierid, supplierdebtchangebefore, supplierdebtchangeamount, supplierdebtchangetype, processname, supplierdebtchangemodelid, supplierdebtchangeafter, supplierdebtchangedate, userid, tablename, comment, dailyentryid,saveid, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor) VALUES ('-1', '', '520', '1', ' خصم معالجة عجز  / 400/ شغل خاص بالشيخ وليد  /120زيادة درج', '566', '-520', '2024-05-20', '1', 'supplierPayedDeptController.php', '400/ شغل خاص بالشيخ وليد  /120زيادة درج', '0','8', '0','1','1','520','1');
UPDATE supplier SET  suppliercurrentDebt = '-520', userid = '1', supplierdate = '2024-05-20'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '520.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / 400/ شغل خاص بالشيخ وليد  /120زيادة درج', supplierdebtchangemodelid = '566', supplierdebtchangeafter = '-520.00', supplierdebtchangedate = '2024-05-20 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '400/ شغل خاص بالشيخ وليد  /120زيادة درج', dailyentryid = '0',saveid = '8',currencyId='1',conversionFactor='1',payedInCurrency='520',saveConversionFactor='1' WHERE supplierdebtchangeid = '941';
UPDATE save SET  savecurrentvalue = '4240',  userid = '1' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('3720.00','520', '0', '8', 'تسوية خزنة بالإضافة', '-1', '4240', '2024-05-20 22:12:17', '1',  'settlementsaveController.php','0','400/ شغل خاص بالشيخ وليد  /120زيادة درج');
UPDATE savedaily SET  savedailymodelid = '28296' WHERE savedailyid = '28296';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '520', '520', '2024-05-20', '1', '0', '0', '2024-05-20 22:12:17','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10293', '142', '520', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2613001', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10293', '27', '520', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-132470', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:42:18";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:12:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 22:12:18', '1', 'sucess', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:42:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:12:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 22:12:20', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:42:45";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:12:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:12:45', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 18:42:45";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 22:12:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 22:12:46', '1', '', '156.210.41.61', '', '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-05-20 18:51:13";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:21:13", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 22:21:13', '3', '', '197.32.190.38', '', '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-05-20 18:51:14";
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-05-20 18:51:18";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:21:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:21:18', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:08:51";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:38:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:38:51', '3', 'addAndRetuen', '197.32.190.38', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664ba2aeab4c6
-- ----------------------------------------------------------------------------------------------------

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-05-20 22:21:18', '0664ba2aeab4c6', '1', '0.00', '0', '10', '1', '4060', '4050', '4050', '0', '8', '2024-05-20 22:38:51', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '9' ,'0','','','','','-1','0','0','0','0','0','4050','0','','0','0','4050','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','اضافة فاتورة مبيعات','17064', '0', '2024-05-20 22:38:51', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '4050', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 18109;
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','01698', '17064', '1', '1698', '2', '440.00', '880', '0', '', '1', '2024-05-20 22:38:51', '1698', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18109-2,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 355.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 355.00
                where sellbilldetailid = 50673;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1698, '2024-05-20', 877.83251231527, 720, 700
                    , 710, 700, 710, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+877.83251231527, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+710
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+710
                            , 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-05-20', 877.83251231527, 720, 700
                    , 710, 700, 710, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+877.83251231527, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+700, sellCostMeanBuyPrice = sellCostMeanBuyPrice+710
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+700, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+710
                            , 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 = '3', storedetaildate = '2024-05-20 22:38:51' WHERE storedetailid = '6165';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '8', '2', '1', '17064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '7', '3', '2024-05-20 22:38:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18659;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18739;
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','01753', '17064', '1', '1753', '2', '440.00', '880', '0', '', '1', '2024-05-20 22:38:51', '1753', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18659-1,18739-1,');
UPDATE sellbilldetail SET  lastbuyprice = 360.00 , meanbuyprice = 360.00, lastbuyprice_withDiscount = 360.00, meanbuyprice_withDiscount = 360.00
                where sellbilldetailid = 50674;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1753, '2024-05-20', 877.83251231527, 720, 720
                    , 720, 720, 720, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+877.83251231527, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , 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-05-20', 877.83251231527, 720, 720
                    , 720, 720, 720, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+877.83251231527, sellCostBuyPrice =sellCostBuyPrice+720
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+720, sellCostMeanBuyPrice = sellCostMeanBuyPrice+720
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+720, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+720
                            , 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-05-20 22:38:51' WHERE storedetailid = '6297';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1753', '8', '2', '1', '17064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25.00', '23', '3', '2024-05-20 22:38:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 18761;
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', '17064', '1', '1577', '2', '530.00', '1060', '0', '', '1', '2024-05-20 22:38:51', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18761-2,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 50675;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-05-20', 1057.3891625616, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1057.3891625616, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , 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-05-20', 1057.3891625616, 900, 900
                    , 900, 900, 900, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1057.3891625616, sellCostBuyPrice =sellCostBuyPrice+900
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+900, sellCostMeanBuyPrice = sellCostMeanBuyPrice+900
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+900, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+900
                            , 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-05-20 22:38:51' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '2', '1', '17064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '27.00', '25', '3', '2024-05-20 22:38:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '17064', '1', '1657', '2', '430.00', '860', '0', '', '1', '2024-05-20 22:38:51', '1657', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18728-2,');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 50676;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1657, '2024-05-20', 857.88177339901, 760, 760
                    , 760, 760, 760, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+857.88177339901, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , 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-05-20', 857.88177339901, 760, 760
                    , 760, 760, 760, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+857.88177339901, sellCostBuyPrice =sellCostBuyPrice+760
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+760, sellCostMeanBuyPrice = sellCostMeanBuyPrice+760
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+760, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+760
                            , 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-05-20 22:38:51' WHERE storedetailid = '6029';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1657', '8', '2', '1', '17064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '21.00', '19', '3', '2024-05-20 22:38:51','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18041;
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','01687', '17064', '1', '1687', '1', '380.00', '380', '0', '', '1', '2024-05-20 22:38:51', '1687', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18041-1,');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 50677;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1687, '2024-05-20', 379.06403940887, 350, 380
                    , 370, 380, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.06403940887, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, 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 (8, '2024-05-20', 379.06403940887, 350, 380
                    , 370, 380, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+379.06403940887, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, 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 = '15', userid = '3', storedetaildate = '2024-05-20 22:38:51' WHERE storedetailid = '6146';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '8', '1', '1', '17064', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '3', '2024-05-20 22:38:51','0','0');
UPDATE save SET  savecurrentvalue = '8290',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4240.00','4050', '0', '8', 'اضافة فاتورة مبيعات', '17064', '8290', '2024-05-20 22:38:51', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 4050, 3450, 3460
                    , 3460, 3460, 3460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4050, sellCostBuyPrice =sellCostBuyPrice+3450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3460
                            , 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-05-20', 4050, 3450, 3460
                    , 3460, 3460, 3460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+4050, sellCostBuyPrice =sellCostBuyPrice+3450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+3460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+3460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+3460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+3460
                            , 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, 4050, 3450, 3460
                    , 3460, 3460, 3460, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+4050, netSellCostBuyPrice = netSellCostBuyPrice+3450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+3460
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+3460
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+3460
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+3460
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664ba2aeab4c6 and sellbillId = 17064 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:08:52";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:38:52", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:38:52', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:09:56";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:39:56", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:39:56', '3', 'addAndRetuen', '197.32.190.38', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664ba6cc51daa
-- ----------------------------------------------------------------------------------------------------

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-05-20 22:38:52', '0664ba6cc51daa', '1', '0.00', '0', '0', '1', '460', '460', '460', '0', '8', '2024-05-20 22:39:57', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','460','0','','0','0','460','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','اضافة فاتورة مبيعات','17065', '0', '2024-05-20 22:39:57', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17613;
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','01611', '17065', '1', '1611', '1', '460.00', '460', '0', '', '2', '2024-05-20 22:39:57', '1611', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','17613-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50678;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1611, '2024-05-20', 460, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, 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 (8, '2024-05-20', 460, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, 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 = '10', userid = '3', storedetaildate = '2024-05-20 22:39:57' WHERE storedetailid = '5864';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1611', '8', '1', '1', '17065', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '3', '2024-05-20 22:39:57','0','0');
UPDATE save SET  savecurrentvalue = '8750',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8290.00','460', '0', '8', 'اضافة فاتورة مبيعات', '17065', '8750', '2024-05-20 22:39:57', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 460, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, 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-05-20', 460, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, 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, 460, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664ba6cc51daa and sellbillId = 17065 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:09:57";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:39:57", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:39:58', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:12:18";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:42:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:42:18', '3', 'addAndRetuen', '197.32.190.38', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664ba70e3ada8
-- ----------------------------------------------------------------------------------------------------

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-05-20 22:39:58', '0664ba70e3ada8', '1', '0.00', '0', '0', '1', '390', '390', '390', '0', '8', '2024-05-20 22:42:18', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','390','0','','0','0','390','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','اضافة فاتورة مبيعات','17066', '0', '2024-05-20 22:42:18', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '390', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17381;
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 ('340','01542', '17066', '1', '1542', '1', '390.00', '390', '0', '', '2', '2024-05-20 22:42:18', '1542', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','17381-1,');
UPDATE sellbilldetail SET  lastbuyprice = 340.00 , meanbuyprice = 340.00, lastbuyprice_withDiscount = 340.00, meanbuyprice_withDiscount = 340.00
                where sellbilldetailid = 50679;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1542, '2024-05-20', 390, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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-05-20', 390, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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 = '3', storedetaildate = '2024-05-20 22:42:18' WHERE storedetailid = '5851';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1542', '8', '1', '1', '17066', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '3', '2024-05-20 22:42:18','0','0');
UPDATE save SET  savecurrentvalue = '9140',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8750.00','390', '0', '8', 'اضافة فاتورة مبيعات', '17066', '9140', '2024-05-20 22:42:18', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 390, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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-05-20', 390, 340, 340
                    , 340, 340, 340, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+390, sellCostBuyPrice =sellCostBuyPrice+340
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+340, sellCostMeanBuyPrice = sellCostMeanBuyPrice+340
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+340, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+340
                            , 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, 390, 340, 340
                    , 340, 340, 340, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+390, netSellCostBuyPrice = netSellCostBuyPrice+340
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+340
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+340
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+340
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+340
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664ba70e3ada8 and sellbillId = 17066 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:12:18";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:42:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:42:18', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:13:05";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:43:05", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:43:05', '3', 'addAndRetuen', '197.32.190.38', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0664ba79af117b
-- ----------------------------------------------------------------------------------------------------

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-05-20 22:42:18', '0664ba79af117b', '1', '0.00', '0', '0', '1', '440', '440', '440', '0', '8', '2024-05-20 22:43:06', '', '3', '0', 'نقدي', '8', '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 = '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','اضافة فاتورة مبيعات','17067', '0', '2024-05-20 22:43:06', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '440', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18779;
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','01697', '17067', '1', '1697', '1', '440.00', '440', '0', '', '2', '2024-05-20 22:43:06', '1697', '0.00', '0', '8','0','','','0','0','0','0','0','0','2','0','','18779-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 420.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 420.00
                where sellbilldetailid = 50680;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1697, '2024-05-20', 440, 430, 450
                    , 420, 450, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , 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-05-20', 440, 430, 450
                    , 420, 450, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , 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-05-20 22:43:06' WHERE storedetailid = '6315';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1697', '8', '1', '1', '17067', 'اضافة فاتورة مبيعات', 'sellbillController.php', '9.00', '8', '3', '2024-05-20 22:43:06','0','0');
UPDATE save SET  savecurrentvalue = '9580',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9140.00','440', '0', '8', 'اضافة فاتورة مبيعات', '17067', '9580', '2024-05-20 22:43:06', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-05-20', 440, 430, 450
                    , 420, 450, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , 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-05-20', 440, 430, 450
                    , 420, 450, 420, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+420
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+420
                            , 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, 450
                    , 420, 450, 420, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+440, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+420
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+420
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0664ba79af117b and sellbillId = 17067 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:13:06";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:43:06", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:43:06', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:13:11";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:43:11", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:43:11', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:18:00";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:48:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 22:48:01', '3', 'editprint', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:18:10";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:48:10", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:48:10', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:18:15";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:48:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:48:15', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:20:17";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:50:17", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:50:17', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:20:21";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:50:21", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:50:21', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:20:36";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:50:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:50:36', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:20:40";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:50:41", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:50:41', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:21:05";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:51:05", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:51:05', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:21:08";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:51:08", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:51:08', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:21:54";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:51:55", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:51:55', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:21:57";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:51:57", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 22:51:57', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:27:15";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 22:57:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 22:57:15', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:33:36";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:03:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:03:36', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:33:40";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:03:40", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 23:03:40', '3', 'editprint', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:34:02";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:04:02", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:04:02', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:35:08";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:05:08", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-05-20 23:05:08', '3', 'editprint', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:35:12";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:05:12", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:05:12', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:35:15";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:05:15", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:05:15', '3', 'showDetail', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:37:20";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:07:20", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:07:20', '3', '', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:39:22";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:39:31";
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-05-20 19:47:59";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:17:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 23:17:59', '1', '', '156.210.41.61', '', '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-05-20 19:47:59";
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-05-20 19:51:18";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:21:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:21:18', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:53:17";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:23:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:23:17', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:53:30";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:23:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:23:30', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:00";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:00', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:02";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:02', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:03";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:03', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:05";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:05', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:06";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:06', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:09";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:09', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:11";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:11', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:13";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:13', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:17";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:24:17', '1', 'showDetail', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:54:19";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:24:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-05-20 23:24:20', '1', 'editprint', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:55:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:25:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:25:20', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:56:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:26:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:26:20', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:56:20";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:26:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-05-20 23:26:20', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:56:35";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:26:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-05-20 23:26:35', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 19:59:54";
UPDATE user SET loginip = "197.32.190.38", lastactivetime = "2024-05-20 23:29:55", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:29:55', '3', 'addsellBill', '197.32.190.38', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:00:30";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:30:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-05-20 23:30:30', '1', '', '156.210.41.61', '', '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-05-20 20:00:30";
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-05-20 20:20:18";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:50:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-05-20 23:50:18', '1', 'addsellBill', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:21:24";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:51:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-05-20 23:51:24', '1', '', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:23:03";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:53:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:53:03', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:23:16";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:53:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:53:16', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '380', productSellAllPrice = '350.00', productSellUnitPrice = '380.00', productSellHalfPrice = '360.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '375',meanbuyprice_withDiscount = '375' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 23:53:39',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 23:53:39', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380', productSellUnitPrice = '380', productSellHalfPrice = '380', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '375.00',meanbuyprice_withDiscount = '375' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 23:53:43',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 23:53:43', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380.00', productSellUnitPrice = '380.00', productSellHalfPrice = '390', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '375.00',meanbuyprice_withDiscount = '375' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 23:53:49',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 23:53:49', userid = 1;
UPDATE product SET productName = 'مشجر جديد 444', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380.00', productSellUnitPrice = '460', productSellHalfPrice = '390.00', productDate = '2024-04-02', conditions = '0', userId = '1', limitamount = '0', parcode = '01687',type ='0', expireDate = '0' , dailyentryId = '9939',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '375.00',meanbuyprice_withDiscount = '375' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1687';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1687, 1,'2024-05-20 23:54:23',1)
                ON DUPLICATE KEY UPDATE productid = 1687, edited = 1, sysdate = '2024-05-20 23:54:23', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:25:22";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:55:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:55:23', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:25:35";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:55:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:55:36', '1', 'edit', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:26:39";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:56:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:56:39', '1', 'update', '156.210.41.61', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 1745;
UPDATE productunit SET unitid = '1', productid = '1745', productnumber = '1.00', productunitdate = '2024-05-20', userid = '1', conditions = '0',proUnitParcode='0174501',proUnitSellAllPrice='380',proUnitSellHalfPrice='390',proUnitSellUnitPrice ='430',proUnitBuyPrice='380' WHERE productunitid = '1745';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1745, 1,'2024-05-20 23:56:39',1)
                ON DUPLICATE KEY UPDATE productid = 1745, edited = 1, sysdate = '2024-05-20 23:56:39', userid = 1;
UPDATE product SET productName = '101جديد الجزار', productDescription = '', productCatId = '1', productBuyPrice = '380', productSellAllPrice = '380', productSellUnitPrice = '430', productSellHalfPrice = '390', productDate = '2024-05-04', conditions = '0', userId = '1', limitamount = '0', parcode = '01745',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '380.00',meanbuyprice_withDiscount = '380' , productbuypricereal = '380' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1745';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:26:41";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:56:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:56:41', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:27:04";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:57:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:57:04', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:27:09";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:57:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:57:09', '1', 'edit', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:27:30";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:57:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:57:31', '1', 'update', '156.210.41.61', '', 'DESKTOP');
BEGIN;
UPDATE productunit SET  conditions = 1 WHERE productunitid = 1746;
UPDATE productunit SET unitid = '1', productid = '1746', productnumber = '1.00', productunitdate = '2024-05-20', userid = '1', conditions = '0',proUnitParcode='0174601',proUnitSellAllPrice='380',proUnitSellHalfPrice='390',proUnitSellUnitPrice ='430',proUnitBuyPrice='380' WHERE productunitid = '1746';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1746, 1,'2024-05-20 23:57:31',1)
                ON DUPLICATE KEY UPDATE productid = 1746, edited = 1, sysdate = '2024-05-20 23:57:31', userid = 1;
UPDATE product SET productName = '100جديد الجزار', productDescription = '', productCatId = '1', productBuyPrice = '380', productSellAllPrice = '380', productSellUnitPrice = '430', productSellHalfPrice = '390', productDate = '2024-05-04', conditions = '0', userId = '1', limitamount = '0', parcode = '01746',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '380.00',meanbuyprice_withDiscount = '380' , productbuypricereal = '380' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1746';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:27:33";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:57:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:57:33', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:28:13";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:58:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:58:13', '1', 'show', '156.210.41.61', '', 'DESKTOP');
UPDATE product SET productName = '101جديد الجزار', productDescription = '', productCatId = '1', productBuyPrice = '380.00', productSellAllPrice = '380.00', productSellUnitPrice = '460', productSellHalfPrice = '390.00', productDate = '2024-05-04', conditions = '0', userId = '1', limitamount = '0', parcode = '01745',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '380.00',lastbuyprice_withDiscount = '380',meanbuyprice = '380.00',meanbuyprice_withDiscount = '380' , productbuypricereal = '380.00' , buypricereal_precentage = '0.00' , buytotal_precentage = '0.00' , buyhalf_precentage = '2.63' , buypart_precentage = '13.16',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType ='0' , online = '' , updatebyuser = '0'  WHERE productId = '1745';
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1745, 1,'2024-05-20 23:58:28',1)
                ON DUPLICATE KEY UPDATE productid = 1745, edited = 1, sysdate = '2024-05-20 23:58:28', userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-05-20 20:28:56";
UPDATE user SET loginip = "156.210.41.61", lastactivetime = "2024-05-20 23:58:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-05-20 23:58:57', '1', 'show', '156.210.41.61', '', 'DESKTOP');
