UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:30:47";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:00:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:00:47', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '23', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5758';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1519', '7', '8', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '31.00', '23', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:30:50";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:00:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:00:50', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:32:52";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:02:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:02:52', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5977';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1642', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '1.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:32:54";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:02:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:02:55', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:33:32";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:03:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:03:32', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5975';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1639', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '10.00', '9', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:33:34";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:03:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:03:34', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:34:11";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:04:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:04:11', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '11', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5949';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1548', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '11', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:34:14";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:04:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:04:14', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:34:43";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:04:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:04:43', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5893';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1621', '7', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '2.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:34:46";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:04:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:04:46', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:35:14";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:05:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:05:14', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5884';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1617', '7', '16', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '28.00', '12', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:35:16";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:05:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:05:16', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:35:57";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:05:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:05:57', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5860';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1610', '7', '12', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '13.00', '1', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:35:59";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:05:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:05:59', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:36:59";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:06:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:06:59', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6065';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '7', '5', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:37:01";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:07:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:07:01', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:37:36";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:07:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:07:36', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '19', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6027';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1656', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '20.00', '19', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:37:38";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:07:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:07:38', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:38:09";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:08:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:08:10', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6023';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '7', '2', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '17.00', '15', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:38:12";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:08:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:08:12', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:41:11";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:11:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:11:11', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5979';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1641', '7', '11', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '16.00', '5', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:41:13";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:11:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:11:13', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:41:47";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:11:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:11:47', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '4', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5978';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1640', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '5.00', '4', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:41:49";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:11:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:11:49', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:42:25";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:12:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:12:25', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6174';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1704', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '9.00', '8', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:42:27";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:12:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:12:27', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:43:30";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:13:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:13:30', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1703', '7', '6', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '2.00', '8', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:43:32";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:13:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:13:32', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:44:04";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:14:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:14:04', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6163';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1702', '7', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '4.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:44:06";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:14:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:14:06', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:45:08";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:15:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:15:08', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6161';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '3.00', '2', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:45:10";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:15:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:15:10', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:45:44";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:15:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:15:44', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6144';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1695', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '17.00', '16', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:45:46";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:15:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:15:46', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:46:44";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:16:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:16:44', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '50', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1684', '7', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '51.00', '50', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:46:46";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:16:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:16:47', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:48:04";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:18:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:18:04', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '14', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6120';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1685', '7', '2', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '12.00', '14', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:48:06";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:18:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:18:06', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:48:39";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:18:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:18:39', '1', 'add', '156.210.3.208', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6111';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1681', '7', '4', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '12.00', '8', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:48:41";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:18:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 00:18:41', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:51:41";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:21:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:21:41', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:51:41";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:21:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:21:41', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:51:47";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:21:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:21:47', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:51:47";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:21:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:21:47', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:56:30";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:26:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:26:30', '1', 'add', '156.210.3.208', '', '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(1967,1,7,1023,5,'2024-04-29',1,0, '' ,0,0,0,0,0,'2024-04-29 00:26:30',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '-7', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '3550';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1023, 0, 0
                    , 165.00, -5, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyprice = 165.00,
                        buyQuantity =buyQuantity+-5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "5*2024-04-29*165.00," WHERE transferproductid = 8441;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1023', '1', '5', '1', '8441', 'تحويل منتجات من المخزن', 'storemovementController.php', '-2.00', '-7', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '5', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '3554';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1023, 0, 0
                    , 165.00, 5, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+5, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1023', '7', '5', '0', '8441', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '5', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1483', '8', '2024-04-29', '1', '0','1967',null,null,'2024-04-29 00:26:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5428';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1483, 0, 0
                    , 300.00, -8, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyprice = 300.00,
                        buyQuantity =buyQuantity+-8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "8*2024-04-29*300.00," WHERE transferproductid = 8442;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1483', '1', '8', '1', '8442', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-8', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5433';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1483, 0, 0
                    , 300.00, 8, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+8, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1483', '7', '8', '0', '8442', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '8', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1137', '1', '2024-04-29', '1', '0','1967',null,null,'2024-04-29 00:26:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '4158';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1137, 0, 0
                    , 190.00, -1, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyprice = 190.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-04-29*190.00," WHERE transferproductid = 8443;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1137', '1', '1', '1', '8443', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-1', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '4159';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1137, 0, 0
                    , 190.00, 1, 0, 0, 1, '2024-04-29 00:26:30')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:30' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1137', '7', '1', '0', '8443', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '1', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1492', '2', '2024-04-29', '1', '0','1967',null,null,'2024-04-29 00:26:30',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5464';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1492, 0, 0
                    , 300.00, -2, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyprice = 300.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-04-29*300.00," WHERE transferproductid = 8444;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1492', '1', '2', '1', '8444', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-2', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '9', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5466';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1492, 0, 0
                    , 300.00, 2, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1492', '7', '2', '0', '8444', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '7.00', '9', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1172', '2', '2024-04-29', '1', '0','1967',null,null,'2024-04-29 00:26:31',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-2', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '4298';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1172, 0, 0
                    , 270.00, -2, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-04-29*270.00," WHERE transferproductid = 8445;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1172', '1', '2', '1', '8445', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-2', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '2', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '4302';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1172, 0, 0
                    , 270.00, 2, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1172', '7', '2', '0', '8445', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '2', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '7', '1509', '1', '2024-04-29', '1', '0','1967',null,null,'2024-04-29 00:26:31',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5520';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1509, 0, 0
                    , 380.00, -1, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyprice = 380.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "1*2024-04-29*380.00," WHERE transferproductid = 8446;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1509', '1', '1', '1', '8446', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-1', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5523';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1509, 0, 0
                    , 380.00, 1, 0, 0, 1, '2024-04-29 00:26:31')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:26:31' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1509', '7', '1', '0', '8446', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '1', '1', '2024-04-29','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:56:31";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:26:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:26:31', '1', 'editshow', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:56:57";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:26:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 00:26:57', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 20:57:08";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:27:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 00:27:08', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:14:57";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:44:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 00:44:57', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:15:24";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:45:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:45:24', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:15:24";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:45:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:45:25', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:20:08";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:50:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:50:08', '1', 'add', '156.210.3.208', '', '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(1968,7,1,1608,24,'2024-04-29',1,0, '' ,0,0,0,0,0,'2024-04-29 00:50:09',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5847';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 7, 1608, 0, 0
                    , 320.00, 24, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-24, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2024-02-29*320.00," WHERE transferproductid = 8447;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1608', '7', '24', '1', '8447', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5842';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 1, 1608, 0, 0
                    , 320.00, 24, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1608', '1', '24', '0', '8447', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '24', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1545', '18', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5845';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 7, 1545, 0, 0
                    , 280.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-02-29*280.00," WHERE transferproductid = 8448;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1545', '7', '18', '1', '8448', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5582';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 1, 1545, 0, 0
                    , 280.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1545', '1', '18', '0', '8448', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '18', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1565', '27', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5761';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1565, 0, 0
                    , 300.00, 2, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-2, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1565, 0, 0
                    , 300.00, -25, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyprice = 300.00,
                        buyQuantity =buyQuantity+-25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "2*2024-02-25*300.00,25*2024-04-29*300.00," WHERE transferproductid = 8449;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1565', '7', '27', '1', '8449', 'تحويل منتجات من المخزن', 'storemovementController.php', '27.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '27', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5602';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1565, 0, 0
                    , 300.00, 2, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1565, 0, 0
                    , 300.00, 25, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1565', '1', '27', '0', '8449', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '27', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1544', '18', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5844';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 7, 1544, 0, 0
                    , 280.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-02-29*280.00," WHERE transferproductid = 8450;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1544', '7', '18', '1', '8450', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '18', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5581';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 1, 1544, 0, 0
                    , 280.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1544', '1', '18', '0', '8450', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '18', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1678', '11', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6108';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 7, 1678, 0, 0
                    , 390.00, 10, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-10, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1678, 0, 0
                    , 390.00, -1, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyprice = 390.00,
                        buyQuantity =buyQuantity+-1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "10*2024-03-30*390.00,1*2024-04-29*390.00," WHERE transferproductid = 8451;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '7', '11', '1', '8451', 'تحويل منتجات من المخزن', 'storemovementController.php', '11.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '29', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6089';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-03-30', 1, 1678, 0, 0
                    , 390.00, 10, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+10, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1678, 0, 0
                    , 390.00, 1, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+1, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1678', '1', '11', '0', '8451', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '29', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1561', '17', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5749';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 7, 1561, 0, 0
                    , 350.00, 17, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-17, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2024-02-25*350.00," WHERE transferproductid = 8452;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1561', '7', '17', '1', '8452', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '17', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5598';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-25', 1, 1561, 0, 0
                    , 350.00, 17, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1561', '1', '17', '0', '8452', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '17', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1606', '13', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5833';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 7, 1606, 0, 0
                    , 410.00, 11, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-11, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 7, 1606, 0, 0
                    , 410.00, -2, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyprice = 410.00,
                        buyQuantity =buyQuantity+-2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "11*2024-02-28*410.00,2*2024-04-29*410.00," WHERE transferproductid = 8453;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1606', '7', '13', '1', '8453', 'تحويل منتجات من المخزن', 'storemovementController.php', '13.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '13', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5825';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-28', 1, 1606, 0, 0
                    , 410.00, 11, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+11, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1606, 0, 0
                    , 410.00, 2, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+2, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1606', '1', '13', '0', '8453', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0.00', '13', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('7', '1', '1547', '18', '2024-04-29', '1', '0','1968',null,null,'2024-04-29 00:50:09',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5848';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 7, 1547, 0, 0
                    , 320.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity-18, sellQuantity = sellQuantity-0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "18*2024-02-29*320.00," WHERE transferproductid = 8454;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1547', '7', '18', '1', '8454', 'تحويل منتجات من المخزن', 'storemovementController.php', '18.00', '0', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '36', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5584';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-02-29', 1, 1547, 0, 0
                    , 320.00, 18, 0, 0, 1, '2024-04-29 00:50:09')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+18, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 00:50:09' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1547', '1', '18', '0', '8454', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '18.00', '36', '1', '2024-04-29','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:20:09";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:50:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 00:50:09', '1', 'editshow', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:24:27";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:54:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 00:54:27', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:24:28";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:54:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 00:54:28', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:24:59";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:54:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 00:55:00', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:29:38";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:59:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 00:59:38', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:29:47";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 00:59:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 00:59:47', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:31:37";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:01:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:01:37', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:32:29";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:02:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:02:30', '1', 'add', '156.210.3.208', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '6', '-1', '0', '1855.00', '215', '2070', '', '0', '2024-04-29 01:02:30', '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', '', '215', '1', ' خصم معالجة عجز  / ', '556', '-215', '2024-04-29', '1', 'supplierPayedDeptController.php', '', '0','6', '0','1','1','215','1');
UPDATE supplier SET  suppliercurrentDebt = '-215', userid = '1', supplierdate = '2024-04-29'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '215.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '556', supplierdebtchangeafter = '-215.00', supplierdebtchangedate = '2024-04-29 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '6',currencyId='1',conversionFactor='1',payedInCurrency='215',saveConversionFactor='1' WHERE supplierdebtchangeid = '931';
UPDATE save SET  savecurrentvalue = '2070',  userid = '1' WHERE saveid = '6';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1855.00','215', '0', '6', 'تسوية خزنة بالإضافة', '-1', '2070', '2024-04-29 01:02:30', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '27879' WHERE savedailyid = '27879';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '215', '215', '2024-04-29', '1', '0', '0', '2024-04-29 01:02:30','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10142', '140', '215', '','0');
UPDATE accountstree SET name = 'خزينة محل كفر الدوار', customName = 'خزينة محل كفر الدوار', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-1871967', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '140';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10142', '27', '215', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-130455', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:32:30";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:02:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:02:31', '1', 'sucess', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:32:32";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:02:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:02:33', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:33:28";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:03:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 01:03:28', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:35:49";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:05:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:05:49', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:36:03";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:06:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:06:03', '1', 'add', '156.210.3.208', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '5', '-1', '0', '17440.00', '85', '17525', '', '0', '2024-04-29 01:06:03', '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', '', '85', '1', ' خصم معالجة عجز  / ', '557', '-85', '2024-04-29', '1', 'supplierPayedDeptController.php', '', '0','5', '0','1','1','85','1');
UPDATE supplier SET  suppliercurrentDebt = '-85', userid = '1', supplierdate = '2024-04-29'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '85.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '557', supplierdebtchangeafter = '-85.00', supplierdebtchangedate = '2024-04-29 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='85',saveConversionFactor='1' WHERE supplierdebtchangeid = '932';
UPDATE save SET  savecurrentvalue = '17525',  userid = '1' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('17440.00','85', '0', '5', 'تسوية خزنة بالإضافة', '-1', '17525', '2024-04-29 01:06:03', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '27880' WHERE savedailyid = '27880';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '85', '85', '2024-04-29', '1', '0', '0', '2024-04-29 01:06:03','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10143', '139', '85', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3041033', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10143', '27', '85', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-130540', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:36:04";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:06:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:06:04', '1', 'sucess', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:36:06";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:06:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:06:06', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:36:36";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:06:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 01:06:36', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:39:27";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:09:27", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:09:27', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:39:51";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:09:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:09:51', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:43:11";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:13:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:13:11', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:43:15";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:13:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:13:15', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:43:15";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:13:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:13:15', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:43:48";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:13:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 01:13:48', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:45:09";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:15:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:15:09', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:45:13";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:15:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:15:13', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:45:58";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:15:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 01:15:58', '1', 'addsellBill', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:46:58";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:16:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:16:58', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:47:03";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:17:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:17:03', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:47:26";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:17:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:17:26', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:50:01";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:20:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:20:01', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 21:50:14";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:20:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:20:14', '1', 'show', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-28 22:06:12";
UPDATE user SET loginip = "156.210.3.208", lastactivetime = "2024-04-29 01:36:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 01:36:12', '1', '', '156.210.3.208', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:39:02";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:41:23";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:11:23", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 09:11:23', '4', '', '197.35.233.37', '', '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-04-29',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-04-29',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-04-29 05:41:27";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:41:27";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:11:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:11:28', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:41:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:11:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:11:45', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:41:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:11:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:11:46', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:43:35";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:13:35", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:13:35', '4', 'addAndRetuen', '197.35.233.37', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662f3a2264a08
-- ----------------------------------------------------------------------------------------------------

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-04-29 09:11:46', '0662f3a2264a08', '1', '0.00', '0', '0', '1', '470', '470', '470', '0', '7', '2024-04-29 09:13:35', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','470','0','','0','0','470','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '4' 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','اضافة فاتورة مبيعات','16819', '0', '2024-04-29 09:13:35', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '470', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17963;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('460','01680', '16819', '1', '1680', '1', '470', '470', '0', '', '2', '2024-04-29 09:13:35', '1680', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17963-1,');
UPDATE sellbilldetail SET  lastbuyprice = 460.00 , meanbuyprice = 460.00, lastbuyprice_withDiscount = 460.00, meanbuyprice_withDiscount = 460.00
                where sellbilldetailid = 49994;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1680, '2024-04-29', 470, 460, 460
                    , 460, 460, 460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , 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 (7, '2024-04-29', 470, 460, 460
                    , 460, 460, 460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , 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 = '13', userid = '4', storedetaildate = '2024-04-29 09:13:35' WHERE storedetailid = '6109';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1680', '7', '1', '1', '16819', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '4', '2024-04-29 09:13:35','0','0');
UPDATE save SET  savecurrentvalue = '15370',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('14900.00','470', '0', '7', 'اضافة فاتورة مبيعات', '16819', '15370', '2024-04-29 09:13:35', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 470, 460, 460
                    , 460, 460, 460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , 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-04-29', 470, 460, 460
                    , 460, 460, 460, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+470, sellCostBuyPrice =sellCostBuyPrice+460
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+460, sellCostMeanBuyPrice = sellCostMeanBuyPrice+460
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+460, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+460
                            , 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, 470, 460, 460
                    , 460, 460, 460, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+470, netSellCostBuyPrice = netSellCostBuyPrice+460
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+460
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+460
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+460
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+460
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662f3a2264a08 and sellbillId = 16819 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:43:35";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:13:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:13:36', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:43:57";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:13:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 09:13:57', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 05:44:09";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:14:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 09:14:09', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 4;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 06:27:35";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 06:27:36";
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 06:27:44";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 09:57:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 09:57:44', '4', '', '197.35.233.37', '', '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-04-29 06:27: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-04-29 06:46:41";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 10:16:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 10:16:41', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 07:15:57";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 10:45:57", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 10:45:58', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:23:47";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:23:47";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:24:20";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:24:21";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:24:38";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:24:39";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:25:11";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:55:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:55:12', '4', '', '197.35.233.37', '', '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-04-29 08:25:12";
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-04-29 08:26:11";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:56:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:56:11', '4', '', '197.35.233.37', '', '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-04-29 08:26:11";
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-04-29 08:26:21";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:56:21", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:56:21', '4', '', '197.35.233.37', '', '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-04-29 08:26:22";
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-04-29 08:26:28";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:56:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:56:28', '4', '', '197.35.233.37', '', '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-04-29 08:26:28";
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-04-29 08:26:30";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:56:30", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:56:30', '4', '', '197.35.233.37', '', '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-04-29 08:26: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-04-29 08:26:31";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:56:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2024-04-29 11:56:32', '4', 'edit', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:27:01";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:57:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:57:02', '4', '', '197.35.233.37', '', '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-04-29 08:27:02";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:27:08";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:57:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:57:08', '4', '', '197.35.233.37', '', '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-04-29 08:27: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-04-29 08:27:10";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:57:10", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 11:57:11', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:27:19";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:57:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:57:19', '4', '', '197.35.233.37', '', '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-04-29 08:27:19";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE userid = 4;
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-04-29 08:28:21";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:58:21", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:58:21', '4', '', '197.35.233.37', '', 'MOBILE');
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-04-29 08:28:22";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:28:37";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:58:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 11:58:37', '4', '', '197.35.233.37', '', '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-04-29 08:28:37";
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-04-29 08:28:40";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:58:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 11:58:41', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:28:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:58:45", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 11:58:45', '4', 'addsellBill', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:28:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:58:46", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 11:58:46', '4', 'addsellBill', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:29:10";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:59:10", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 11:59:10', '4', '', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:29:17";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 11:59:17", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 11:59:17', '4', 'addsellBill', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:50:52";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:20:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 12:20:52', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:57:07";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:27:07", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 12:27:07', '4', 'addAndRetuen', '197.35.233.37', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662f61413d942
-- ----------------------------------------------------------------------------------------------------

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-04-29 11:58:41', '0662f61413d942', '1', '0.00', '0', '0', '1', '950', '950', '950', '0', '7', '2024-04-29 12:27:08', '', '4', '0', 'نقدي', '7', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','950','0','','0','0','950','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '4' 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','اضافة فاتورة مبيعات','16820', '0', '2024-04-29 12:27:08', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '950', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17321;
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','01593', '16820', '1', '1593', '1', '430', '430', '0', '', '2', '2024-04-29 12:27:08', '1593', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17321-1,');
UPDATE sellbilldetail SET  lastbuyprice = 390.00 , meanbuyprice = 390.00, lastbuyprice_withDiscount = 390.00, meanbuyprice_withDiscount = 390.00
                where sellbilldetailid = 49995;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1593, '2024-04-29', 430, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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 (7, '2024-04-29', 430, 390, 390
                    , 390, 390, 390, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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 = '25', userid = '4', storedetaildate = '2024-04-29 12:27:08' WHERE storedetailid = '5806';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1593', '7', '1', '1', '16820', 'اضافة فاتورة مبيعات', 'sellbillController.php', '26.00', '25', '4', '2024-04-29 12:27:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17979;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01685', '16820', '1', '1685', '1', '260', '260', '0', '', '2', '2024-04-29 12:27:08', '1685', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17979-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 49996;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1685, '2024-04-29', 260, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-04-29', 260, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '4', storedetaildate = '2024-04-29 12:27:08' WHERE storedetailid = '6120';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1685', '7', '1', '1', '16820', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '4', '2024-04-29 12:27:08','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17981;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01684', '16820', '1', '1684', '1', '260', '260', '0', '', '2', '2024-04-29 12:27:08', '1684', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','17981-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 250.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 250.00
                where sellbilldetailid = 49997;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1684, '2024-04-29', 260, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-04-29', 260, 250, 250
                    , 250, 250, 250, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+260, sellCostBuyPrice =sellCostBuyPrice+250
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+250
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+250
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '49', userid = '4', storedetaildate = '2024-04-29 12:27:08' WHERE storedetailid = '6121';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1684', '7', '1', '1', '16820', 'اضافة فاتورة مبيعات', 'sellbillController.php', '50.00', '49', '4', '2024-04-29 12:27:08','0','0');
UPDATE save SET  savecurrentvalue = '16320',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('15370.00','950', '0', '7', 'اضافة فاتورة مبيعات', '16820', '16320', '2024-04-29 12:27:08', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 950, 890, 890
                    , 890, 890, 890, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , 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-04-29', 950, 890, 890
                    , 890, 890, 890, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+950, sellCostBuyPrice =sellCostBuyPrice+890
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+890, sellCostMeanBuyPrice = sellCostMeanBuyPrice+890
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+890, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+890
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 950, 890, 890
                    , 890, 890, 890, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+950, netSellCostBuyPrice = netSellCostBuyPrice+890
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+890
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+890
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+890
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+890
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662f61413d942 and sellbillId = 16820 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:57:09";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:27:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 12:27:09', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:57:15";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:27:15", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 12:27:15', '4', 'addAndRetuen', '197.35.233.37', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662f6674c4188
-- ----------------------------------------------------------------------------------------------------

BEGIN;
INSERT INTO returnsellbill (returnsellbilldate, returnsellbillserial, returnsellbillclientid, returnsellbilltotaldeptbefor, returnsellbilltotaldeptafter, returnsellbilldiscount, returnsellbilldiscounttype, returnsellbilltotalbill, returnsellbillaftertotalbill, returnsellbilltotalpayed, returnsellbillfinalbill, returnsellbillstoreid, returnsellbillsysdate,comment, userid, conditions, returnsellbillclientname, returnsellbillsaveid, returnsellbildirectpayment, billnameid, sellerid, tempclientName, returnsellQuantity,tax, carnumber, cartype, carchase, carmotor,costcenterid,dailyentryid,delbyuserid,billReservation,billReservationDate,visaAccountId,cashPayed,visaPayed,isBankAccountTransfer,extraDiscountPer,extraDiscountVal,taxOfDiscountPer,taxOfDiscountVal) VALUES ('2024-04-29 12:20:52', '0662f6674c4188', '1', '0.00', '0', '0', '1', '910', '910', '-910', '0', '7', '2024-04-29 12:27:15', '', '4', '0', 'نقدي','7', '0', '5', '0', 'نقدي', '2', '0', '', '','','','-1','0','0','0','','0','-910','0','0','0','0','0','0');
UPDATE client SET  clientdebt = '0', userid = '4' WHERE clientid = '1';
INSERT INTO clientdebtchange (clientid, clientdebtchangebefore, clientdebtchangeamount, clientdebtchangetype, processname, clientdebtchangemodelid, clientdebtchangeafter, clientdebtchangedate, userid, tablename, comment, totalOperationCost,discount,reciptid,dailyentryid , num , billid , paytype, costcenterid,currencyId,conversionFactor,payedInCurrency,saveConversionFactor ) VALUES ('1','0.00','0','1','اضافة فاتورة مردوات مبيعات','5721', '0', '2024-04-29 12:27:15', '4', 'returnsellbillController.php', 'اضافة فاتورة مردوات مبيعات', '910', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('460.00', '01639', '5721', '1', '1639', '1', '460', '460', '0', '', '0', '0', '1639', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 500.00 , meanbuyprice = 480.00, lastbuyprice_withDiscount = 500.00, meanbuyprice_withDiscount = 480.00
                where returnsellbilldetailid = 12396;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1639, '2024-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 460, 460, 500, 480
                    , 500, 480, 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+460, returnSellCostBuyPrice = returnSellCostBuyPrice+460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+500
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+500
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+480
                            , 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 (7, '2024-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 460, 460, 500, 480
                    , 500, 480, 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+460, returnSellCostBuyPrice = returnSellCostBuyPrice+460, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+500
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+480, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+500
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+480
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '4', storedetaildate = '2024-04-29 12:27:15' WHERE storedetailid = '5975';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1639', '7', '1', '0', '5721', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '9.00', '10', '4', '2024-04-29 12:27:15','0','0');
INSERT INTO returnsellbilldetail (buyprice, parcode, returnsellbillid, returnsellbilldetailcatid, returnsellbilldetailproductid, returnsellbilldetailquantity, returnsellbilldetailprice, returnsellbilldetailtotalprice, conditions, note, pricetype, discountvalue, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,pricetypepro) VALUES ('430.00', '01610', '5721', '1', '1610', '1', '450', '450', '0', '', '0', '0', '1610', '0.00', '0','7','0','','','0','0','0','0','0','0');
UPDATE returnsellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where returnsellbilldetailid = 12397;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1610, '2024-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 450, 430, 430, 430
                    , 430, 430, 0, 0, 1)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+450, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+0
                        , netQuantityRet = netQuantityRet+1;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 450, 430, 430, 430
                    , 430, 430, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+0, sellCostBuyPrice =sellCostBuyPrice+0
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+0, sellCostMeanBuyPrice = sellCostMeanBuyPrice+0
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+0, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+0
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+450, returnSellCostBuyPrice = returnSellCostBuyPrice+430, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+430
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+430, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+430
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+430
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '4', storedetaildate = '2024-04-29 12:27:15' WHERE storedetailid = '5860';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1610', '7', '1', '0', '5721', 'اضافة فاتورة مردودات مبيعات', 'returnsellbillController.php', '1.00', '2', '4', '2024-04-29 12:27:15','0','0');
UPDATE save SET  savecurrentvalue = '15410',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('16320.00','910', '1', '7', 'اضافة فاتورة مردوات مبيعات', '5721', '15410', '2024-04-29 12:27:15', '4',  'returnsellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 910, 890, 930, 910
                    , 930, 910, 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+910, returnSellCostBuyPrice = returnSellCostBuyPrice+890, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+930
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+910, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+930
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+910
                        , 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-04-29', 0, 0, 0
                    , 0, 0, 0, 0
                    , 910, 890, 930, 910
                    , 930, 910, 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+910, returnSellCostBuyPrice = returnSellCostBuyPrice+890, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+930
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+910, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+930
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+910
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, -910, -890, -930
                    , -910, -930, -910, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+-910, netSellCostBuyPrice = netSellCostBuyPrice+-890
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+-930
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+-910
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+-930
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+-910
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662f6674c4188 and sellbillId = 5721 and returnsellbillId = 5721
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 08:57:16";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:27:16", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 12:27:16', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 09:22:49";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 12:52:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 12:52:49', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 09:45:10";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 13:15:11", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 13:15:11', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 09:52:28";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 13:22:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 13:22:28', '4', 'addAndRetuen', '197.35.233.37', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662f732f32574
-- ----------------------------------------------------------------------------------------------------

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-04-29 13:15:11', '0662f732f32574', '1', '0.00', '0', '0', '1', '460', '460', '460', '0', '7', '2024-04-29 13:22:28', '', '4', '0', 'نقدي', '7', '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 = '4' 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','اضافة فاتورة مبيعات','16821', '0', '2024-04-29 13:22:28', '4', 'sellbillController.php', 'اضافة فاتورة مبيعات', '460', '0', null, '0', null, null,'', '0','1','1','0','1');
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('450','01696', '16821', '1', '1696', '1', '460.00', '460', '0', '', '2', '2024-04-29 13:22:28', '1696', '0.00', '0', '7','0','','','0','0','0','0','0','0','2','0','','');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 49998;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1696, '2024-04-29', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (7, '2024-04-29', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '2', userid = '4', storedetaildate = '2024-04-29 13:22:28' WHERE storedetailid = '6150';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1696', '7', '1', '1', '16821', 'اضافة فاتورة مبيعات', 'sellbillController.php', '3.00', '2', '4', '2024-04-29 13:22:28','0','0');
UPDATE save SET  savecurrentvalue = '15870',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('15410.00','460', '0', '7', 'اضافة فاتورة مبيعات', '16821', '15870', '2024-04-29 13:22:28', '4',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-04-29', 460, 450, 450
                    , 450, 450, 450, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+450
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+450, sellCostMeanBuyPrice = sellCostMeanBuyPrice+450
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+450, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+450
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 460, 450, 450
                    , 450, 450, 450, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+460, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662f732f32574 and sellbillId = 16821 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 09:52:29";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 13:22:29", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 13:22:29', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 09:56:33";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 13:26:33", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 13:26:34', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:29:09";
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-04-29 10:29:19";
UPDATE user SET loginip = "197.32.198.0", lastactivetime = "2024-04-29 13:59:20", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 13:59:20', '3', '', '197.32.198.0', '', '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-04-29 10:29:20";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:30:01";
UPDATE user SET loginip = "197.32.198.0", lastactivetime = "2024-04-29 14:00:01", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 14:00:01', '3', 'addsellBill', '197.32.198.0', '', '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-04-29 10:38:22";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:08:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 14:08:22', '1', '', '156.210.9.124', '', '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-04-29 10:38: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-04-29 10:44:50";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:44:51";
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-04-29 10:45:58";
UPDATE user SET loginip = "197.192.235.71", lastactivetime = "2024-04-29 14:15:58", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 14:15:58', '7', '', '197.192.235.71', '', '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-04-29 10:45:58";
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-04-29 10:46:00";
UPDATE user SET loginip = "197.192.235.71", lastactivetime = "2024-04-29 14:16:00", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 14:16:00', '7', 'addsellBill', '197.192.235.71', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:50:20";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:20:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:20:20', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:50:24";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:20:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:20:25', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:01";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:01', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:02";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:02', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:25";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:25', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:32";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:32', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:45";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:45', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:51:55";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:21:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 14:21:55', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:52:22";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:22:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 14:22:22', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:52:23";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:22:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 14:22:23', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:53:04";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:23:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 14:23:04', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:53:22";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:23:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 14:23:22', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:55:55";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 14:25:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 14:25:55', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:58:28";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 14:28:28", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 14:28:28', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:58:37";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 14:28:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 14:28:38', '4', 'add', '197.35.233.37', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'تروسيكل', '', '20', '2024-04-29', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '15850',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('15870.00','20', '1', '7', 'إضافة مصروف', '4961', '15850', '2024-04-29 14:28:38', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-04-29', '4', '0', '0', '2024-04-29 14:28:38','اضافة اسم مصروف( تروسيكل )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10144', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4448953', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10144', '141', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2020217', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'تروسيكل', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-04-29', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10144', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4961';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:58:38";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 14:28:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 14:28:38', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:58:40";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 14:28:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 14:28:40', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 10:58:40";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 14:28:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 14:28:40', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:17:34";
UPDATE user SET loginip = "197.192.235.71", lastactivetime = "2024-04-29 14:47:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 14:47:34', '7', 'addsellBill', '197.192.235.71', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:18:16";
UPDATE user SET loginip = "197.192.235.71", lastactivetime = "2024-04-29 14:48:16", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 14:48:16', '7', 'addsellBill', '197.192.235.71', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:44:50";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 15:14:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 15:14:50', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:44:58";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 15:14:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 15:14:59', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:45:05";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 15:15:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 15:15:05', '1', 'show', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:45:08";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 15:15:08", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 15:15:08', '1', '', '156.210.9.124', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 11:45:10";
UPDATE user SET loginip = "156.210.9.124", lastactivetime = "2024-04-29 15:15:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 15:15:10', '1', '', '156.210.9.124', '', '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-04-29 11:45:11";
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-04-29 12:06:19";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 15:36:19', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:29";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:29", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:29', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:37";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:37", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:37', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:38";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:38", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:38', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:39";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:39", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:39', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:40";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:40', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:40";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:40", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:40', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:41";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:41', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:41";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:41", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:41', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:42";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:42', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:42";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:42", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:42', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:43";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:43', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:43";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:43", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:43', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:44";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:44', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:44";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:44", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:44', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:45', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:45";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:45", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:45', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:46', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:46', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:47";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:47', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:47";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:47", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:47', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:48";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:48', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:48";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:48", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:48', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:49";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:49', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:49";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:49", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:49', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:50";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:50", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:50', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:51";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:51", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:51', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:52";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:52', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:52";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:52", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:52', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:53";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:53', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:53";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:53", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:53', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:54";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:54', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:54";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:55', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:55";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:55", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:55', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:55";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:56", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:56', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:06:58";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 15:36:58", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 15:36:58', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:00";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:00", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 16:01:01', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:01";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:01", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 16:01:01', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:18";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:18", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:01:18', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:18";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:01:19', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:19";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:01:20', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:31";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:31", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 16:01:31', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:31:32";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:01:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:01:32', '4', 'addsellBill', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:37:31";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:37: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-04-29 12:38:18";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:08:18", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 16:08:18', '4', '', '197.35.233.37', '', 'MOBILE');
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-04-29 12:38:19";
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-04-29 12:38:34";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:08:34", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 16:08:34', '4', '', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:40:26";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:10:26", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:10:26', '4', 'addsellBill', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:40:26";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:10:26", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:10:26', '4', '', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:40:32";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 16:10:32", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('userController.php', '2024-04-29 16:10:32', '4', 'edit', '197.35.233.37', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE userid = 4;
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-04-29 12:41:02";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 16:11:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 16:11:02', '1', '', '156.210.121.48', '', '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-04-29 12:41:02";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
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-04-29 12:41:13";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 16:11:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 16:11:13', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 12:41:13";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 16:11:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 16:11:13', '1', '', '156.210.121.48', '', '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-04-29 12:56:24";
UPDATE user SET loginip = "197.63.218.202", lastactivetime = "2024-04-29 16:26:24", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 16:26:24', '8', '', '197.63.218.202', '', '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-04-29 12:56:25";
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-04-29 13:05:22";
UPDATE user SET loginip = "197.63.218.202", lastactivetime = "2024-04-29 16:35:22", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 16:35:22', '8', 'addsellBill', '197.63.218.202', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 1;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:39: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;
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-04-29 13:40:44";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:10:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 17:10:44', '1', '', '156.210.121.48', '', '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-04-29 13:40:45";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:40:58";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:10:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:10:58', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:40:58";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:10:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:10:58', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:44:51";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:14:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:14:52', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:44:52";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:14:52", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:14:52', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:45:13";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:15:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:15:13', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:46:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:16:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:16:35', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:46:36";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:16:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:16:36', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:47:33";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:17:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 17:17:33', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:47:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:17:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:17:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 3;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:54:37";
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-04-29 13:54:51";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 17:24:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 17:24:51', '3', '', '197.32.217.247', '', '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-04-29 13:54: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-04-29 13:54:55";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 17:24:55", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:24:55', '3', 'addsellBill', '197.32.217.247', '', '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-04-29 13:55:41";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:25:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 17:25:41', '1', '', '156.210.121.48', '', '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-04-29 13:55:41";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
INSERT IGNORE INTO relusergroupproperties (usergroupid, propertyid, propertyvalue, theorder)
                SELECT -1,propertyid , 0,0
                from properties;
INSERT IGNORE INTO usergroupadmin (propertyid, isallowed)
                SELECT propertyid , propertydefault
                from properties;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:58:04";
UPDATE user SET loginip = "154.183.40.227", lastactivetime = "2024-04-29 17:28:04", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 17:28:04', '8', '', '154.183.40.227', '', 'DESKTOP');
UPDATE product
                JOIN (
                       select productingredients.productId
                              ,sum(productnumber * quantity * productBuyPrice) as productBuyPrice
                              ,sum(productnumber * quantity * lastbuyprice) as lastbuyprice
                              ,sum(productnumber * quantity * lastbuyprice_withDiscount) as lastbuyprice_withDiscount
                              ,sum(productnumber * quantity * meanbuyprice) as meanbuyprice
                              ,sum(productnumber * quantity * meanbuyprice_withDiscount) as meanbuyprice_withDiscount
                              ,sum(productnumber * quantity * overAllAveragePrice) as overAllAveragePrice
                      from product
                      join productingredients on product.productId = productingredients.ingridientId
                      join productunit on productunit.productunitid = productingredients.unitId
                      group by productingredients.productId
                    ) as ingridientPrice ON ingridientPrice.productId =  product.productId
                SET product.productBuyPrice = ingridientPrice.productBuyPrice,
                        product.lastbuyprice = ingridientPrice.lastbuyprice,
                    product.lastbuyprice_withDiscount = ingridientPrice.lastbuyprice_withDiscount,
                    product.meanbuyprice = ingridientPrice.meanbuyprice,
                    product.meanbuyprice_withDiscount = ingridientPrice.meanbuyprice_withDiscount,
                    product.overAllAveragePrice = ingridientPrice.overAllAveragePrice;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 13:58:04";
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-04-29 13:59:19";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:29:19", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:29:19', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:03";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:03", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:32:03', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:08";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:09", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:32:09', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:25";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:25", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:32:26', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:26";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:26", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2024-04-29 17:32:26', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:26";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:27", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('returnsellbillController.php', '2024-04-29 17:32:27', '4', 'showDetail', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:46";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:46", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:32:46', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:02:54";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:32:54", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 17:32:54', '4', 'editprint', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:03:04";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:33:04", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:33:04', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:03:08";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:33:08", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:33:08', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:04:17";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:34:17", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 17:34:17', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:04:31";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:34:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 17:34:32', '4', 'add', '197.35.233.37', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'مصروف احمد', '', '20', '2024-04-29', '4', '0','-1','7','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '15830',  userid = '4' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('15850.00','20', '1', '7', 'إضافة مصروف', '4962', '15830', '2024-04-29 17:34:32', '4',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '20', '20', '2024-04-29', '4', '0', '0', '2024-04-29 17:34:32','اضافة اسم مصروف( مصروف احمد )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10145', '160', '20', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4448973', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10145', '141', '20', '','0');
UPDATE accountstree SET name = 'خزينة محل العميد', customName = 'خزينة محل العميد', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2020237', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'مصروف احمد', expensesdetails = '', expensesValue = '20.00', expensesdate = '2024-04-29', userid = '4', conditions = '0',saveid = '7' , dailyentryid = '10145', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4962';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:04:32";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:34:32", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 17:34:32', '4', 'sucess', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:04:34";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:34:34", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 17:34:34', '4', 'show', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:04:36";
UPDATE user SET loginip = "197.35.233.37", lastactivetime = "2024-04-29 17:34:36", deviceType = "DESKTOP" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 17:34:36', '4', '', '197.35.233.37', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:06:50";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:36:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:36:50', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:07:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:37:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 17:37:35', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:08:33";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:38:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 17:38:33', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:09:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:39:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('saveController.php', '2024-04-29 17:39:32', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:09:44";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:39:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:39:44', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:09:45";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:39:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:39:45', '1', 'addsellBill', '156.210.121.48', '', '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-04-29 14:19:02";
UPDATE user SET loginip = "154.183.40.227", lastactivetime = "2024-04-29 17:49:02", deviceType = "DESKTOP" WHERE userid = 8;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 17:49:02', '8', 'addsellBill', '154.183.40.227', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:19:45";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:49:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:49:45', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:20:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:50:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:50:42', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5993';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1645', '8', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '21.00', '20', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:20:44";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:50:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:50:44', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:21:49";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:51:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:51:50', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '15', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5763';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1574', '8', '1', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '16.00', '15', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:21:51";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 17:51:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 17:51:52', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:33:50";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:03:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:03:50', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '16', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5763';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1574', '8', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '15.00', '16', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:33:51";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:03:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:03:51', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:39:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:09:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:09:25', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:39:32";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:09:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:09:32', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:39:56";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:09:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:09:56', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:07";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:07', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:09";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:09', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:10";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:10", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:10', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:12";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:12', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:14";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:14', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:15";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:16', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:22";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:22', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:25', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:26', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:28";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:28', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:30";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:30", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:30', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:32";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:32", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:32', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:33";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:33', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:35', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:37";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:38', '1', 'editorder', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:40:39";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:10:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 18:10:40', '1', 'editorder', '156.210.121.48', '', '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-04-29 14:46:56";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:16:56", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 18:16:56', '1', '', '156.210.121.48', '', '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-04-29 14:46: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-04-29 14:47:16";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:17:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 18:17:16', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:47:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:17:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 18:17:31', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:47:41";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:17:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 18:17:42', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:48:00";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:18:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 18:18:00', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:50:00";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:20:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:20:00', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:50:22";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:20:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:20:22', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6164';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1703', '7', '8', '1', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالنقص', 'inventoryController.php', '8.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:50:24";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:20:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:20:24', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:50:57";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:20:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:20:57', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '8', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6065';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '7', '8', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '8', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:50:59";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:20:59", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:20:59', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 14:52:14";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:22:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 18:22:14', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 15:06:09";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:36:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:36:09', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 15:06:15";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:36:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:36:15', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 15:06:18";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:36:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 18:36:18', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 15:06:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:36:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 18:36:20', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 15:06:28";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 18:36:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 18:36:28', '1', 'show', '156.210.121.48', '', '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-04-29 17:10:14";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 20:40:14", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 20:40:14', '3', '', '197.32.217.247', '', '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-04-29 17:10: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-04-29 17:12:56";
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:12:58";
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-04-29 17:14:13";
UPDATE user SET loginip = "197.32.178.226", lastactivetime = "2024-04-29 20:44:13", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 20:44:13', '4', '', '197.32.178.226', '', 'MOBILE');
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-04-29 17:14:13";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:14:18";
UPDATE user SET loginip = "197.32.178.226", lastactivetime = "2024-04-29 20:44:18", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 20:44:18', '4', '', '197.32.178.226', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:15:21";
UPDATE user SET loginip = "197.32.143.14", lastactivetime = "2024-04-29 20:45:21", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 20:45:21', '4', '', '197.32.143.14', '', 'MOBILE');
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-04-29 17:15:21";
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-04-29 17:15:23";
UPDATE user SET loginip = "197.32.143.14", lastactivetime = "2024-04-29 20:45:23", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-04-29 20:45:23', '4', '', '197.32.143.14', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:15:26";
UPDATE user SET loginip = "197.32.143.14", lastactivetime = "2024-04-29 20:45:26", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-04-29 20:45:26', '4', '', '197.32.143.14', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:15:28";
UPDATE user SET loginip = "197.32.143.14", lastactivetime = "2024-04-29 20:45:28", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-04-29 20:45:28', '4', '', '197.32.143.14', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:15:42";
UPDATE user SET loginip = "197.32.134.155", lastactivetime = "2024-04-29 20:45:42", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientReportsController.php', '2024-04-29 20:45:42', '4', 'show', '197.32.134.155', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:15:52";
UPDATE user SET loginip = "197.32.143.14", lastactivetime = "2024-04-29 20:45:52", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 20:45:52', '4', 'editprint', '197.32.143.14', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:16:07";
UPDATE user SET loginip = "197.32.178.226", lastactivetime = "2024-04-29 20:46:07", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 20:46:07', '4', 'editprint', '197.32.178.226', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:16:10";
UPDATE user SET loginip = "197.32.176.117", lastactivetime = "2024-04-29 20:46:10", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 20:46:10', '4', 'addsellBill', '197.32.176.117', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:16:10";
UPDATE user SET loginip = "197.32.178.226", lastactivetime = "2024-04-29 20:46:10", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 20:46:10', '4', 'addsellBill', '197.32.178.226', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:17:09";
UPDATE user SET loginip = "197.32.180.30", lastactivetime = "2024-04-29 20:47:09", deviceType = "MOBILE" WHERE userid = 4;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 20:47:09', '4', '', '197.32.180.30', '', 'MOBILE');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:27:40";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 20:57:40", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 20:57:40', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:51:33";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:21:33", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:21:33', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:54:17";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:24:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:24:18', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662fe52e08476
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:21:34', '0662fe52e08476', '1', '0.00', '0', '0', '1', '1310', '1310', '1310', '0', '8', '2024-04-29 21:24:18', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '3' ,'0','','','','','-1','0','0','0','0','0','1310','0','','0','0','1310','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','اضافة فاتورة مبيعات','16822', '0', '2024-04-29 21:24:18', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '1310', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01588', '16822', '1', '1588', '1', '410', '410', '0', '', '1', '2024-04-29 21:24:18', '1588', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17097-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 385.00
                where sellbilldetailid = 49999;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1588, '2024-04-29', 410, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 410, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '10', userid = '3', storedetaildate = '2024-04-29 21:24:18' WHERE storedetailid = '5784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1588', '8', '1', '1', '16822', 'اضافة فاتورة مبيعات', 'sellbillController.php', '11.00', '10', '3', '2024-04-29 21:24:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17081;
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','01561', '16822', '1', '1561', '1', '440', '440', '0', '', '1', '2024-04-29 21:24:18', '1561', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17081-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 350.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 350.00
                where sellbilldetailid = 50000;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1561, '2024-04-29', 440, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 440, 350, 350
                    , 350, 350, 350, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+350
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+350
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+350
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '3', storedetaildate = '2024-04-29 21:24:18' WHERE storedetailid = '5776';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1561', '8', '1', '1', '16822', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '3', '2024-04-29 21:24:18','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17099;
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','01531', '16822', '1', '1531', '1', '460', '460', '0', '', '1', '2024-04-29 21:24:18', '1531', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17099-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 50001;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1531, '2024-04-29', 460, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 460, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '4', userid = '3', storedetaildate = '2024-04-29 21:24:18' WHERE storedetailid = '5785';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1531', '8', '1', '1', '16822', 'اضافة فاتورة مبيعات', 'sellbillController.php', '5.00', '4', '3', '2024-04-29 21:24:18','0','0');
UPDATE save SET  savecurrentvalue = '1310',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('0.00','1310', '0', '8', 'اضافة فاتورة مبيعات', '16822', '1310', '2024-04-29 21:24: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-04-29', 1310, 1120, 1170
                    , 1145, 1170, 1145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1310, sellCostBuyPrice =sellCostBuyPrice+1120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1145
                            , 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-04-29', 1310, 1120, 1170
                    , 1145, 1170, 1145, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+1310, sellCostBuyPrice =sellCostBuyPrice+1120
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1170, sellCostMeanBuyPrice = sellCostMeanBuyPrice+1145
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1170, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+1145
                            , 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, 1310, 1120, 1170
                    , 1145, 1170, 1145, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+1310, netSellCostBuyPrice = netSellCostBuyPrice+1120
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+1170
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+1145
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+1170
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+1145
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662fe52e08476 and sellbillId = 16822 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 17:54:18";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:24:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:24:19', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:02:35";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:32:35", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:32:35', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662fe5d328dcd
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:24:19', '0662fe5d328dcd', '1', '0.00', '0', '0', '1', '3030', '3030', '3030', '0', '8', '2024-04-29 21:32:35', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '8' ,'0','','','','','-1','0','0','0','0','0','3030','0','','0','0','3030','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','اضافة فاتورة مبيعات','16823', '0', '2024-04-29 21:32:35', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '3030', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 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', '16823', '1', '1611', '2', '450.00', '900', '0', '', '0', '2024-04-29 21:32:35', '1611', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','17613-2,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50002;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1611, '2024-04-29', 900, 860, 860
                    , 860, 860, 860, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+860
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+860, sellCostMeanBuyPrice = sellCostMeanBuyPrice+860
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+860, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+860
                            , 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-04-29', 900, 860, 860
                    , 860, 860, 860, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+900, sellCostBuyPrice =sellCostBuyPrice+860
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+860, sellCostMeanBuyPrice = sellCostMeanBuyPrice+860
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+860, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+860
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '14', userid = '3', storedetaildate = '2024-04-29 21:32:35' WHERE storedetailid = '5864';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1611', '8', '2', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '14', '3', '2024-04-29 21:32:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 18111;
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 ('1','01701', '16823', '1', '1701', '2', '390.00', '780', '0', '', '0', '2024-04-29 21:32:35', '1701', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','18111-2,');
UPDATE sellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 195.50, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 195.50
                where sellbilldetailid = 50003;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1701, '2024-04-29', 780, 780, 2
                    , 391, 2, 391, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2, sellCostMeanBuyPrice = sellCostMeanBuyPrice+391
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+391
                            , 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-04-29', 780, 780, 2
                    , 391, 2, 391, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+780
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2, sellCostMeanBuyPrice = sellCostMeanBuyPrice+391
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+391
                            , 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-04-29 21:32:35' WHERE storedetailid = '6166';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '8', '2', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '8', '3', '2024-04-29 21:32:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16279;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('250','01418', '16823', '1', '1418', '1', '300', '300', '0', '', '0', '2024-04-29 21:32:35', '1418', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','16279-1,');
UPDATE sellbilldetail SET  lastbuyprice = 250.00 , meanbuyprice = 275.00, lastbuyprice_withDiscount = 250.00, meanbuyprice_withDiscount = 275.00
                where sellbilldetailid = 50004;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1418, '2024-04-29', 300, 300, 250
                    , 275, 250, 275, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , 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-04-29', 300, 300, 250
                    , 275, 250, 275, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+300, sellCostBuyPrice =sellCostBuyPrice+300
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+250, sellCostMeanBuyPrice = sellCostMeanBuyPrice+275
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+250, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+275
                            , 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 = '3', storedetaildate = '2024-04-29 21:32:35' WHERE storedetailid = '5235';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1418', '8', '1', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '3', '2024-04-29 21:32:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17859;
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', '16823', '1', '1577', '1', '450', '450', '0', '', '0', '2024-04-29 21:32:35', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','17859-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 50005;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-04-29', 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 (8, '2024-04-29', 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 = '1', userid = '3', storedetaildate = '2024-04-29 21:32:35' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '2.00', '1', '3', '2024-04-29 21:32:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18165;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('240','01230', '16823', '1', '1230', '1', '250', '250', '0', '', '0', '2024-04-29 21:32:35', '1230', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','18165-1,');
UPDATE sellbilldetail SET  lastbuyprice = 240.00 , meanbuyprice = 240.00, lastbuyprice_withDiscount = 240.00, meanbuyprice_withDiscount = 240.00
                where sellbilldetailid = 50006;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1230, '2024-04-29', 250, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 250, 240, 240
                    , 240, 240, 240, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+250, sellCostBuyPrice =sellCostBuyPrice+240
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+240
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+240
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '28', userid = '3', storedetaildate = '2024-04-29 21:32:35' WHERE storedetailid = '4676';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1230', '8', '1', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '29.00', '28', '3', '2024-04-29 21:32:35','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17431;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('320','01549', '16823', '1', '1549', '1', '350', '350', '0', '', '0', '2024-04-29 21:32:35', '1549', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','17431-1,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 50007;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1549, '2024-04-29', 350, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 350, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+350, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '3', storedetaildate = '2024-04-29 21:32:35' WHERE storedetailid = '5879';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1549', '8', '1', '1', '16823', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '3', '2024-04-29 21:32:35','0','0');
UPDATE save SET  savecurrentvalue = '4340',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('1310.00','3030', '0', '8', 'اضافة فاتورة مبيعات', '16823', '4340', '2024-04-29 21:32:35', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 3030, 2950, 2122
                    , 2536, 2122, 2536, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3030, sellCostBuyPrice =sellCostBuyPrice+2950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2122, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2536
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2122, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2536
                            , 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-04-29', 3030, 2950, 2122
                    , 2536, 2122, 2536, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+3030, sellCostBuyPrice =sellCostBuyPrice+2950
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2122, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2536
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2122, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2536
                            , 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, 3030, 2950, 2122
                    , 2536, 2122, 2536, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+3030, netSellCostBuyPrice = netSellCostBuyPrice+2950
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2122
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2536
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2122
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2536
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662fe5d328dcd and sellbillId = 16823 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:02:36";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:32:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:32:36', '3', 'addsellBill', '197.32.217.247', '', '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-04-29 18:02:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:32:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 21:32:42', '1', '', '156.210.121.48', '', '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-04-29 18:02:42";
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-04-29 18:04:43";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:34:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:34:43', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:05:37";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:35:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 21:35:37', '1', '', '156.210.121.48', '', '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-04-29 18:05:38";
DROP PROCEDURE IF EXISTS clientInUse;;

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

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

END

;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:24";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:38:24", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:24', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662fe7c46b036
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:32:36', '0662fe7c46b036', '1', '0.00', '0', '0', '1', '2590', '2590', '2590', '0', '8', '2024-04-29 21:38:24', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','2590','0','','0','0','2590','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','اضافة فاتورة مبيعات','16824', '0', '2024-04-29 21:38:24', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2590', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17085;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('370','01563', '16824', '1', '1563', '1', '450', '450', '0', '', '1', '2024-04-29 21:38:24', '1563', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17085-1,');
UPDATE sellbilldetail SET  lastbuyprice = 370.00 , meanbuyprice = 370.00, lastbuyprice_withDiscount = 370.00, meanbuyprice_withDiscount = 370.00
                where sellbilldetailid = 50008;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1563, '2024-04-29', 450, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 450, 370, 370
                    , 370, 370, 370, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+370
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+370, sellCostMeanBuyPrice = sellCostMeanBuyPrice+370
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+370, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+370
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '19', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '5778';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1563', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '20.00', '19', '3', '2024-04-29 21:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17097;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('410','01588', '16824', '1', '1588', '1', '410', '410', '0', '', '1', '2024-04-29 21:38:24', '1588', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17097-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 385.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 385.00
                where sellbilldetailid = 50009;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1588, '2024-04-29', 410, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 410, 360, 410
                    , 385, 410, 385, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+385
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+385
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '9', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '5784';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1588', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '10.00', '9', '3', '2024-04-29 21:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17091;
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', '16824', '1', '1521', '1', '410', '410', '0', '', '1', '2024-04-29 21:38:24', '1521', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17091-1,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 50010;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1521, '2024-04-29', 410, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, 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 (8, '2024-04-29', 410, 330, 330
                    , 330, 330, 330, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, 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 = '16', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '5781';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1521', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '3', '2024-04-29 21:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17377;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('320','01608', '16824', '1', '1608', '1', '410', '410', '0', '', '1', '2024-04-29 21:38:24', '1608', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17377-1,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 50011;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1608, '2024-04-29', 410, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 410, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '7', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '5849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1608', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '8.00', '7', '3', '2024-04-29 21:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17099;
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','01531', '16824', '1', '1531', '1', '460', '460', '0', '', '1', '2024-04-29 21:38:24', '1531', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17099-1,');
UPDATE sellbilldetail SET  lastbuyprice = 410.00 , meanbuyprice = 410.00, lastbuyprice_withDiscount = 410.00, meanbuyprice_withDiscount = 410.00
                where sellbilldetailid = 50012;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1531, '2024-04-29', 460, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 460, 410, 410
                    , 410, 410, 410, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+460, sellCostBuyPrice =sellCostBuyPrice+410
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+410, sellCostMeanBuyPrice = sellCostMeanBuyPrice+410
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+410, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+410
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '3', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '5785';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1531', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '4.00', '3', '3', '2024-04-29 21:38:24','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17855;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('400','01661', '16824', '1', '1661', '1', '450', '450', '0', '', '1', '2024-04-29 21:38:24', '1661', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17855-1,');
UPDATE sellbilldetail SET  lastbuyprice = 400.00 , meanbuyprice = 400.00, lastbuyprice_withDiscount = 400.00, meanbuyprice_withDiscount = 400.00
                where sellbilldetailid = 50013;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1661, '2024-04-29', 450, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 450, 400, 400
                    , 400, 400, 400, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+450, sellCostBuyPrice =sellCostBuyPrice+400
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+400, sellCostMeanBuyPrice = sellCostMeanBuyPrice+400
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+400, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+400
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '11', userid = '3', storedetaildate = '2024-04-29 21:38:24' WHERE storedetailid = '6062';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1661', '8', '1', '1', '16824', 'اضافة فاتورة مبيعات', 'sellbillController.php', '12.00', '11', '3', '2024-04-29 21:38:24','0','0');
UPDATE save SET  savecurrentvalue = '6930',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('4340.00','2590', '0', '8', 'اضافة فاتورة مبيعات', '16824', '6930', '2024-04-29 21:38:24', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 2590, 2190, 2240
                    , 2215, 2240, 2215, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2590, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2215
                            , 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-04-29', 2590, 2190, 2240
                    , 2215, 2240, 2215, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2590, sellCostBuyPrice =sellCostBuyPrice+2190
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2240, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2215
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2240, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2215
                            , 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, 2590, 2190, 2240
                    , 2215, 2240, 2215, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2590, netSellCostBuyPrice = netSellCostBuyPrice+2190
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2240
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2215
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2240
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2215
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662fe7c46b036 and sellbillId = 16824 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:25";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:38:25", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:25', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 21:38:25', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 21:38:25', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:28";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:38:28", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:38:28', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:35";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:38:35", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:35', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:37";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:37', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:38";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:38', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:43";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:43', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:43";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:38:43', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 21:38:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:08:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:38:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 21:38:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:09:03";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:39:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 21:39:03', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:09:04";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:39:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 21:39:04', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:09:15";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:39:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:39:15', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:09:16";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:39:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:39:16', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:10:09";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:40:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-04-29 21:40:09', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:11:07";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:41:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 21:41:07', '1', 'showbarcode', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:11:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:41:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:41:25', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:12:24";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:42:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 21:42:24', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:12:58";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:42:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 21:42:58', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:22";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 21:43:22', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:24";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:24", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:43:24', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 21:43:26', '1', 'showbarcode', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:37";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('billsettingsController.php', '2024-04-29 21:43:37', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:39";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:43:39', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 21:43:42', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:45";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:45", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 21:43:45', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:47";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:43:48', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:51";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:43:52', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 21:43:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:13:57";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:43:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 21:43:57', '1', '', '156.210.121.48', '', '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-04-29 18:13:58";
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-04-29 18:14:19";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:44:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 21:44:19', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:14:34";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:44:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 21:44:34', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:15:17";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:45:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 21:45:17', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:15:39";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:45:39", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 21:45:39', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:15:46";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:45:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 21:45:47', '1', '', '156.210.121.48', '', '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-04-29 18:15:47";
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-04-29 18:15:48";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:45:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 21:45:48', '1', '', '156.210.121.48', '', '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-04-29 18:15:48";
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-04-29 18:18:51";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:48:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:48:51', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662fe92c0bfd6
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:38:36', '0662fe92c0bfd6', '1', '0.00', '0', '0', '1', '450', '450', '450', '0', '8', '2024-04-29 21:48:51', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','450','0','','0','0','450','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '0', userid = '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','اضافة فاتورة مبيعات','16825', '0', '2024-04-29 21:48:51', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '450', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17859;
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', '16825', '1', '1577', '1', '450', '450', '0', '', '0', '2024-04-29 21:48:51', '1577', '0.00', '0', '8','0','','','0','0','0','0','0','0','0','0','','17859-1,');
UPDATE sellbilldetail SET  lastbuyprice = 450.00 , meanbuyprice = 450.00, lastbuyprice_withDiscount = 450.00, meanbuyprice_withDiscount = 450.00
                where sellbilldetailid = 50014;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1577, '2024-04-29', 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 (8, '2024-04-29', 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 = '0', userid = '3', storedetaildate = '2024-04-29 21:48:51' WHERE storedetailid = '5889';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1577', '8', '1', '1', '16825', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1.00', '0', '3', '2024-04-29 21:48:51','0','0');
UPDATE save SET  savecurrentvalue = '7380',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('6930.00','450', '0', '8', 'اضافة فاتورة مبيعات', '16825', '7380', '2024-04-29 21:48: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-04-29', 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;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-04-29', 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;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 450, 450, 450
                    , 450, 450, 450, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+450, netSellCostBuyPrice = netSellCostBuyPrice+450
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+450
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+450
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+450
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+450
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662fe92c0bfd6 and sellbillId = 16825 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:18:51";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:48:51", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:48:51', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:18:57";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:48:57", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:48:57', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:18:59";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:48:59", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:49:00', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:20:16";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:50:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:50:16', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:20:39";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:50:39", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:50:39', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662feb9c391f5
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:49:00', '0662feb9c391f5', '1', '0.00', '0', '0', '1', '2440', '2440', '2440', '0', '8', '2024-04-29 21:50:39', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '6' ,'0','','','','','-1','0','0','0','0','0','2440','0','','0','0','2440','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','اضافة فاتورة مبيعات','16826', '0', '2024-04-29 21:50:39', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '2440', '0', null, '0', null, null,'', '0','1','1','0','1');
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', '16826', '1', '1687', '1', '430', '430', '0', '', '1', '2024-04-29 21:50:39', '1687', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','18041-1,');
UPDATE sellbilldetail SET  lastbuyprice = 380.00 , meanbuyprice = 380.00, lastbuyprice_withDiscount = 380.00, meanbuyprice_withDiscount = 380.00
                where sellbilldetailid = 50015;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1687, '2024-04-29', 430, 380, 380
                    , 380, 380, 380, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 430, 380, 380
                    , 380, 380, 380, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+380
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+380, sellCostMeanBuyPrice = sellCostMeanBuyPrice+380
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+380, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+380
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '17', userid = '3', storedetaildate = '2024-04-29 21:50:39' WHERE storedetailid = '6146';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1687', '8', '1', '1', '16826', 'اضافة فاتورة مبيعات', 'sellbillController.php', '18.00', '17', '3', '2024-04-29 21:50:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 17377;
INSERT INTO sellbilldetail (buyprice, parcode, sellbillid, sellbilldetailcatid, sellbilldetailproductid, sellbilldetailquantity, sellbilldetailprice, sellbilldetailtotalprice, discountvalue, note, pricetype, sellbilldetaildate, productunitid, buydiscount, buydiscounttype,storeid,discounttype,lastbuyprice,meanbuyprice,lastbuyprice_withDiscount,meanbuyprice_withDiscount,otherdetailquantity,sizeid,colorid,onlineOrderId,pricetypepro,playstationPlayId,soldSerialsInDetails,buyPricesHistoryBookIdQuantity) VALUES ('320','01608', '16826', '1', '1608', '1', '410', '410', '0', '', '1', '2024-04-29 21:50:39', '1608', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17377-1,');
UPDATE sellbilldetail SET  lastbuyprice = 320.00 , meanbuyprice = 320.00, lastbuyprice_withDiscount = 320.00, meanbuyprice_withDiscount = 320.00
                where sellbilldetailid = 50016;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1608, '2024-04-29', 410, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 410, 320, 320
                    , 320, 320, 320, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+320
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+320, sellCostMeanBuyPrice = sellCostMeanBuyPrice+320
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+320, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+320
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '6', userid = '3', storedetaildate = '2024-04-29 21:50:39' WHERE storedetailid = '5849';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1608', '8', '1', '1', '16826', 'اضافة فاتورة مبيعات', 'sellbillController.php', '7.00', '6', '3', '2024-04-29 21:50:39','0','0');
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', '16826', '1', '1698', '2', '410', '820', '0', '', '1', '2024-04-29 21:50:39', '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 = 50017;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1698, '2024-04-29', 820, 720, 700
                    , 710, 700, 710, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, 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-04-29', 820, 720, 700
                    , 710, 700, 710, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+820, 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 = '11', userid = '3', storedetaildate = '2024-04-29 21:50:39' WHERE storedetailid = '6165';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '8', '2', '1', '16826', 'اضافة فاتورة مبيعات', 'sellbillController.php', '13.00', '11', '3', '2024-04-29 21:50:39','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+2 where id = 17089;
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','01525', '16826', '1', '1525', '2', '390', '780', '0', '', '1', '2024-04-29 21:50:39', '1525', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','17089-2,');
UPDATE sellbilldetail SET  lastbuyprice = 330.00 , meanbuyprice = 330.00, lastbuyprice_withDiscount = 330.00, meanbuyprice_withDiscount = 330.00
                where sellbilldetailid = 50018;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1525, '2024-04-29', 780, 660, 660
                    , 660, 660, 660, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 2, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+2
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (8, '2024-04-29', 780, 660, 660
                    , 660, 660, 660, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+780, sellCostBuyPrice =sellCostBuyPrice+660
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+660, sellCostMeanBuyPrice = sellCostMeanBuyPrice+660
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+660, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+660
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '23', userid = '3', storedetaildate = '2024-04-29 21:50:39' WHERE storedetailid = '5780';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1525', '8', '2', '1', '16826', 'اضافة فاتورة مبيعات', 'sellbillController.php', '25.00', '23', '3', '2024-04-29 21:50:39','0','0');
UPDATE save SET  savecurrentvalue = '9820',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('7380.00','2440', '0', '8', 'اضافة فاتورة مبيعات', '16826', '9820', '2024-04-29 21:50:39', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 2440, 2080, 2060
                    , 2070, 2060, 2070, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2440, sellCostBuyPrice =sellCostBuyPrice+2080
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2070
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2070
                            , 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-04-29', 2440, 2080, 2060
                    , 2070, 2060, 2070, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+2440, sellCostBuyPrice =sellCostBuyPrice+2080
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+2060, sellCostMeanBuyPrice = sellCostMeanBuyPrice+2070
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+2060, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+2070
                            , 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, 2440, 2080, 2060
                    , 2070, 2060, 2070, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+2440, netSellCostBuyPrice = netSellCostBuyPrice+2080
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+2060
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+2070
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+2060
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+2070
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662feb9c391f5 and sellbillId = 16826 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:20:40";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:50:40", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:50:40', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:20:43";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:50:43", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:50:43', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:20:50";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:50:50", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:50:50', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:01";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:52:01', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:11";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:52:11', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:52:20', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:52:22', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:23";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:52:23', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:22:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:52:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:52:26', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:23:19";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:53:19", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:53:19', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:23:55";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:53:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:53:55', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:12";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:54:12', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:17";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:17', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:20', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:22', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:23";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:23', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:25";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:25", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:25', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:24:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:54:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:54:26', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:00";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:56:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:56:00', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:18";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:56:18", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:56:18', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:33";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:56:33", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:56:33', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:47";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:56:47", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 21:56:47', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:53";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:56:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:56:53', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:26:55";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:56:55", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:56:55', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:27:17";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:57:17", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:57:17', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5080';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('581', '8', '1', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '0.00', '1', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:27:19";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:57:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:57:20', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:27:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:57:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:57:21', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:28:21";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:58:21", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:58:21', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:28:36";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:58:36", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:58:36', '3', 'addAndRetuen', '197.32.217.247', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662fedcda0bd1
-- ----------------------------------------------------------------------------------------------------

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-04-29 21:58:21', '0662fedcda0bd1', '1', '0.00', '0', '0', '1', '220', '220', '220', '0', '8', '2024-04-29 21:58:36', '', '3', '0', 'نقدي', '8', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','220','0','','0','0','220','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','اضافة فاتورة مبيعات','16827', '0', '2024-04-29 21:58:36', '3', 'sellbillController.php', 'اضافة فاتورة مبيعات', '220', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 15273;
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 ('185','00581', '16827', '1', '581', '1', '220', '220', '0', '', '1', '2024-04-29 21:58:36', '581', '0.00', '0', '8','0','','','0','0','0','0','0','0','1','0','','15273-1,');
UPDATE sellbilldetail SET  lastbuyprice = 185.00 , meanbuyprice = 285.00, lastbuyprice_withDiscount = 185.00, meanbuyprice_withDiscount = 285.00
                where sellbilldetailid = 50019;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (581, '2024-04-29', 220, 385, 185
                    , 285, 185, 285, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , 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-04-29', 220, 385, 185
                    , 285, 185, 285, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , 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 = '3', storedetaildate = '2024-04-29 21:58:36' WHERE storedetailid = '5080';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('581', '8', '1', '1', '16827', 'اضافة فاتورة مبيعات', 'sellbillController.php', '1.00', '0', '3', '2024-04-29 21:58:36','0','0');
UPDATE save SET  savecurrentvalue = '10040',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('9820.00','220', '0', '8', 'اضافة فاتورة مبيعات', '16827', '10040', '2024-04-29 21:58:36', '3',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 220, 385, 185
                    , 285, 185, 285, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , 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-04-29', 220, 385, 185
                    , 285, 185, 285, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+220, sellCostBuyPrice =sellCostBuyPrice+385
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+185, sellCostMeanBuyPrice = sellCostMeanBuyPrice+285
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+185, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+285
                            , 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, 220, 385, 185
                    , 285, 185, 285, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+220, netSellCostBuyPrice = netSellCostBuyPrice+385
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+185
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+285
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+185
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+285
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662fedcda0bd1 and sellbillId = 16827 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:28:37";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:58:37", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:58:37', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:28:53";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:58:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:58:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:28:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:58:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 21:58:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:29:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 21:59:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 21:59:27', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:29:33";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 21:59:33", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 21:59:33', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:30:36";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:00:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:00:36', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:00";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:00", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:00', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:12";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:12", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:12', '3', 'add', '197.32.217.247', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'القبض بدون النسبه', '', '1100', '2024-04-29', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '8940',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('10040.00','1100', '1', '8', 'إضافة مصروف', '4963', '8940', '2024-04-29 22:01:12', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '1100', '1100', '2024-04-29', '3', '0', '0', '2024-04-29 22:01:12','اضافة اسم مصروف( القبض بدون النسبه )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10146', '160', '1100', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4450073', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10146', '142', '1100', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2531146', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'القبض بدون النسبه', expensesdetails = '', expensesValue = '1100.00', expensesdate = '2024-04-29', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10146', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4963';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:12";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:12", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:12', '3', 'sucess', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:14";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:14", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:14', '3', 'show', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:14";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:01:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:01:14', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:16";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:16", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:16', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:36";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:37", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:37', '3', 'add', '197.32.217.247', '', 'DESKTOP');
BEGIN;
INSERT INTO expenses (expensestypeid, expensesname, expensesdetails, expensesValue, expensesdate, userid, conditions,costcenterid,saveid,dailyentryid,bankid,bankaccountid,checknum,productid) VALUES ('-1', 'تاكسي', '', '120', '2024-04-29', '3', '0','-1','8','0','0','0','','0');
UPDATE save SET  savecurrentvalue = '8820',  userid = '3' WHERE saveid = '8';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('8940.00','120', '1', '8', 'إضافة مصروف', '4964', '8820', '2024-04-29 22:01:37', '3',  'expensesController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '120', '120', '2024-04-29', '3', '0', '0', '2024-04-29 22:01:37','اضافة اسم مصروف( تاكسي )','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10147', '160', '120', '','0');
UPDATE accountstree SET name = '', customName = '', parent = '10', itemtype = '1', itemfrom = '0', notes = '', del = '1', userid = '1', mydate = '2021-12-01', itemtype2 = '1', theValue = '-4450193', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '160';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10147', '142', '120', '','0');
UPDATE accountstree SET name = 'خزينة محل ابو كريم', customName = 'خزينة محل ابو كريم', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-2531266', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '142';
UPDATE expenses SET expensestypeid = '-1', expensesname = 'تاكسي', expensesdetails = '', expensesValue = '120.00', expensesdate = '2024-04-29', userid = '3', conditions = '0',saveid = '8' , dailyentryid = '10147', bankid = '0', bankaccountid = '0', checknum = '', productid = '0' WHERE expensesid = '4964';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:37";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:37", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:37', '3', 'sucess', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:39";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:39", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('expensesController.php', '2024-04-29 22:01:39', '3', 'show', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:40";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:40", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:01:40', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:49";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:01:49", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:01:49', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:31:49";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:01:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:01:50', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:32:02";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:02:02", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:02:02', '3', '', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:32:14";
UPDATE user SET loginip = "197.32.217.247", lastactivetime = "2024-04-29 22:02:14", deviceType = "DESKTOP" WHERE userid = 3;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:02:14', '3', 'addsellBill', '197.32.217.247', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:32:28";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:02:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:02:28', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:36:36";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:06:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:06:36', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:00";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:00", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:00', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:01";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:01', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:21', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:34";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:34', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:35', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:37:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:07:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:07:54', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:40:05";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:10:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:10:05', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:40:27";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:10:28", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:10:28', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:40:44";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:10:44", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:10:44', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:41:03";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:11:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:11:03', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:41:22";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:11:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:11:22', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:41:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:11:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:11:42', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:44:58";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:14:58", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 22:14:58', '1', 'editprint', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:15:20', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:37";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:37", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 22:15:37', '1', 'editprint', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:46";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:46", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:15:46', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:49";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:49", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:15:49', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:50";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:50", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:15:50', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:45:55";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:15:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:15:55', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:01";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:16:01', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:06";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:16:07', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:09";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:16:09', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:11";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:11", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:16:11', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:15";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:16:16', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:18";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 22:16:18', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:22";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 22:16:22', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:26";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:26", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:16:26', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:16:35', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:46:40";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:16:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:16:40', '1', 'showDetail', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:47:07";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:17:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:17:07', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:47:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:17:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:17:42', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:47:53";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:17:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:17:53', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:48:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:18:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:18:35', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:53:58";
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-04-29 18:54:50";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:24:50", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('index.php', '2024-04-29 22:24:50', '7', '', '197.192.194.186', '', '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-04-29 18:54:50";
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-04-29 18:57:21";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:27:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:27:21', '7', '', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:57:24";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:27:24", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 22:27:24', '7', '', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:58:21";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:28:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 22:28:21', '7', 'add', '197.192.194.186', '', '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 =24939
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(60,@clientdebt,@clientname);
UPDATE client SET  clientdebt = '-240' , clientdate = '2024-04-29 22:28:21', userid = '7' WHERE clientid = '60';
UPDATE client SET  inUse = 0 where clientid = 60;
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 ('60','260.00','500','1','ايصال تحصيل (( قبض من عميل ))','24939', '-240', '2024-04-29 22:27:24', '7', 'clientPayedDeptController.php', '   ', '500', '0', null, '0', null, null,'', '-1','1','1','1','1');
UPDATE save SET  savecurrentvalue = '18025',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('17525.00','500', '0', '5', 'ايصال تحصيل (( قبض من عميل ))', '24939', '18025', '2024-04-29 22:28:21', '7',  'clientPayedDeptController.php','0','');
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '500', '500', '2024-04-29', '7', '0', '0', '2024-04-29 22:28:21','اضافة ايصال سداد للعميل ام حميس خطاب','1','0','-1');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10148', '139', '500', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3040533', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10148', '113', '500', '','0');
UPDATE accountstree SET name = 'ام حميس خطاب', customName = 'ام حميس خطاب', parent = '23', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2021-11-07', itemtype2 = '1', theValue = '-16920', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '113';
UPDATE clientdebtchange SET clientid = '60', clientdebtchangebefore = '260.00', clientdebtchangeamount = '500.00', clientdebtchangetype = '1', processname = 'ايصال تحصيل (( قبض من عميل ))', clientdebtchangemodelid = '24939', clientdebtchangeafter = '-240.00', clientdebtchangedate = '2024-04-29 22:27:24', userid = '7', tablename = 'clientPayedDeptController.php', comment = '   ', totalOperationCost = '500.00',discount='', reciptid=null, dailyentryid = '10148',seller = '0',currencyId='1',conversionFactor='1',payedInCurrency='1',saveConversionFactor='1' WHERE clientdebtchangeid = '24939';
COMMIT;

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

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:58:22";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:28:22", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 22:28:23', '7', 'sucess', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:58:25";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:28:25", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('clientPayedDeptController.php', '2024-04-29 22:28:25', '7', 'show', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:58:28";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:28:28", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:28:29', '7', 'addsellBill', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:59:13";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:29:13", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:29:13', '7', 'addAndRetuen', '197.192.194.186', '', '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 0662ff4dd1de70
-- ----------------------------------------------------------------------------------------------------

BEGIN;
CALL clientInUse(60,@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-04-29 22:28:29', '0662ff4dd1de70', '60', '-240.00', '190', '0', '1', '430', '430', '0', '430', '5', '2024-04-29 22:29:14', '', '7', '0', 'ام حميس خطاب', '5', '1', '3', '0', 'ام حميس خطاب', '1' ,'0','','','','','-1','0','0','0','0','0','430','0','','0','0','0','0','0','0','0','0','0','0','0','');
UPDATE client SET  clientdebt = '190', userid = '7' WHERE clientid = '60';
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 ('60','-240.00','430','0','اضافة فاتورة مبيعات','16828', '190', '2024-04-29 22:29:14', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '430', '0', null, '0', null, null,'', '0','1','1','430','1');
UPDATE client SET  inUse = 0 where clientid = 60;
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 16947;
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','01587', '16828', '1', '1587', '1', '430', '430', '0', '', '0', '2024-04-29 22:29:14', '1587', '0.00', '0', '5','0','','','0','0','0','0','0','0','0','0','','16947-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50020;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1587, '2024-04-29', 430, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-04-29', 430, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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 = '16', userid = '7', storedetaildate = '2024-04-29 22:29:14' WHERE storedetailid = '5710';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1587', '5', '1', '1', '16828', 'اضافة فاتورة مبيعات', 'sellbillController.php', '17.00', '16', '7', '2024-04-29 22:29:14','0','0');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 430, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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 (60, '2024-04-29', 430, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+430, 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, 430, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+430, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662ff4dd1de70 and sellbillId = 16828 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:59:14";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:29:14", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:29:14', '7', 'addsellBill', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:59:33";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:29:33", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:29:33', '7', 'addAndRetuen', '197.192.194.186', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662ff50b11277
-- ----------------------------------------------------------------------------------------------------

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-04-29 22:29:15', '0662ff50b11277', '1', '0.00', '0', '0', '1', '480', '480', '480', '0', '5', '2024-04-29 22:29:33', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '1' ,'0','','','','','-1','0','0','0','0','0','480','0','','0','0','480','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','اضافة فاتورة مبيعات','16829', '0', '2024-04-29 22:29:33', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '480', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18119;
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','01635', '16829', '1', '1635', '1', '480', '480', '0', '', '1', '2024-04-29 22:29:33', '1635', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18119-1,');
UPDATE sellbilldetail SET  lastbuyprice = 430.00 , meanbuyprice = 430.00, lastbuyprice_withDiscount = 430.00, meanbuyprice_withDiscount = 430.00
                where sellbilldetailid = 50021;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1635, '2024-04-29', 480, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-04-29', 480, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, sellCostBuyPrice =sellCostBuyPrice+430
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+430, sellCostMeanBuyPrice = sellCostMeanBuyPrice+430
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+430, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+430
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2024-04-29 22:29:33' WHERE storedetailid = '6055';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1635', '5', '1', '1', '16829', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2024-04-29 22:29:33','0','0');
UPDATE save SET  savecurrentvalue = '18505',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('18025.00','480', '0', '5', 'اضافة فاتورة مبيعات', '16829', '18505', '2024-04-29 22:29: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-04-29', 480, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, 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-04-29', 480, 430, 430
                    , 430, 430, 430, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+480, 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, 480, 430, 430
                    , 430, 430, 430, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+480, netSellCostBuyPrice = netSellCostBuyPrice+430
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+430
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+430
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+430
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+430
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662ff50b11277 and sellbillId = 16829 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 18:59:34";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:29:34", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:29:34', '7', 'addsellBill', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:00:14";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:30:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:30:15', '7', 'addAndRetuen', '197.192.194.186', '', 'DESKTOP');

-- ----------------------------------------------------------------------------------------------------
-- bill add start - with serial 0662ff51e63baf
-- ----------------------------------------------------------------------------------------------------

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-04-29 22:29:34', '0662ff51e63baf', '1', '0.00', '0', '0', '1', '850', '850', '850', '0', '5', '2024-04-29 22:30:15', '', '7', '0', 'نقدي', '5', '0', '3', '0', 'نقدي', '2' ,'0','','','','','-1','0','0','0','0','0','850','0','','0','0','850','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','اضافة فاتورة مبيعات','16830', '0', '2024-04-29 22:30:15', '7', 'sellbillController.php', 'اضافة فاتورة مبيعات', '850', '0', null, '0', null, null,'', '0','1','1','0','1');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18115;
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', '16830', '1', '1698', '1', '410', '410', '0', '', '1', '2024-04-29 22:30:15', '1698', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18115-1,');
UPDATE sellbilldetail SET  lastbuyprice = 350.00 , meanbuyprice = 355.00, lastbuyprice_withDiscount = 350.00, meanbuyprice_withDiscount = 355.00
                where sellbilldetailid = 50022;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1698, '2024-04-29', 410, 360, 350
                    , 355, 350, 355, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , 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-04-29', 410, 360, 350
                    , 355, 350, 355, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+410, sellCostBuyPrice =sellCostBuyPrice+360
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+350, sellCostMeanBuyPrice = sellCostMeanBuyPrice+355
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+350, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+355
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '15', userid = '7', storedetaildate = '2024-04-29 22:30:15' WHERE storedetailid = '6168';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1698', '5', '1', '1', '16830', 'اضافة فاتورة مبيعات', 'sellbillController.php', '16.00', '15', '7', '2024-04-29 22:30:15','0','0');
UPDATE buypriceshistorybook set sellQuantity = sellQuantity+1 where id = 18117;
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 ('1','01701', '16830', '1', '1701', '1', '440', '440', '0', '', '1', '2024-04-29 22:30:15', '1701', '0.00', '0', '5','0','','','0','0','0','0','0','0','1','0','','18117-1,');
UPDATE sellbilldetail SET  lastbuyprice = 1.00 , meanbuyprice = 195.50, lastbuyprice_withDiscount = 1.00, meanbuyprice_withDiscount = 195.50
                where sellbilldetailid = 50023;
 INSERT INTO quickprofitproduct (productId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice,netQuantity,netQuantityRet)
                    VALUES (1701, '2024-04-29', 440, 390, 1
                    , 195.5, 1, 195.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0, 1, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0
                        , netQuantity = netQuantity+1
                        , netQuantityRet = netQuantityRet+0;
 INSERT INTO quickprofitstore (storeId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount, returnSellCostOverAllAveragePrice)
                    VALUES (5, '2024-04-29', 440, 390, 1
                    , 195.5, 1, 195.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+440, sellCostBuyPrice =sellCostBuyPrice+390
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+1, sellCostMeanBuyPrice = sellCostMeanBuyPrice+195.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+1, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+195.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
UPDATE storedetail SET  productquantity = '13', userid = '7', storedetaildate = '2024-04-29 22:30:15' WHERE storedetailid = '6169';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1701', '5', '1', '1', '16830', 'اضافة فاتورة مبيعات', 'sellbillController.php', '14.00', '13', '7', '2024-04-29 22:30:15','0','0');
UPDATE save SET  savecurrentvalue = '19355',  userid = '7' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('18505.00','850', '0', '5', 'اضافة فاتورة مبيعات', '16830', '19355', '2024-04-29 22:30:15', '7',  'sellbillController.php','1','');
 INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES ('2024-04-29', 850, 750, 351
                    , 550.5, 351, 550.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+351, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+351, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitclient (clientId, theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice)
                    VALUES (1, '2024-04-29', 850, 750, 351
                    , 550.5, 351, 550.5, 0
                    , 0, 0, 0, 0
                    , 0, 0, 0)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+850, sellCostBuyPrice =sellCostBuyPrice+750
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+351, sellCostMeanBuyPrice = sellCostMeanBuyPrice+550.5
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+351, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+550.5
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+0
                        , returnSellVal = returnSellVal+0, returnSellCostBuyPrice = returnSellCostBuyPrice+0, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+0
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+0, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+0
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+0
                        , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+0;
 INSERT INTO quickprofitgeneral (id, netSellVal, netSellCostBuyPrice, netSellCostLastBuyPrice, netSellCostMeanBuyPrice, netSellCostLastBuyPricewithDiscount, netSellCostMeanBuyPricewithDiscount, netSellCostOverAllAveragePrice)
                    VALUES (1, 850, 750, 351
                    , 550.5, 351, 550.5, 0)
                ON DUPLICATE KEY UPDATE netSellVal = netSellVal+850, netSellCostBuyPrice = netSellCostBuyPrice+750
                , netSellCostLastBuyPrice = netSellCostLastBuyPrice+351
                , netSellCostMeanBuyPrice = netSellCostMeanBuyPrice+550.5
                , netSellCostLastBuyPricewithDiscount = netSellCostLastBuyPricewithDiscount+351
                , netSellCostMeanBuyPricewithDiscount = netSellCostMeanBuyPricewithDiscount+550.5
                , netSellCostOverAllAveragePrice = netSellCostOverAllAveragePrice+0;
COMMIT;

-- ----------------------------------------------------------------------------------------------------
-- bill add end - with serial 0662ff51e63baf and sellbillId = 16830 and returnsellbillId = 
-- ----------------------------------------------------------------------------------------------------

UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:00:15";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:30:15", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:30:15', '7', 'addsellBill', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:00:21";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:30:21", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:30:21', '7', '', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:00:36";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:30:36", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:30:36', '7', 'showDetail', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:01:05";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:31:05", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:31:05', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:03:18";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:33:18", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 22:33:18', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:03:32";
UPDATE user SET loginip = "197.192.194.186", lastactivetime = "2024-04-29 22:33:32", deviceType = "DESKTOP" WHERE userid = 7;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 22:33:32', '7', 'addsellBill', '197.192.194.186', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:04:03";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:34:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 22:34:03', '1', 'add', '156.210.121.48', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '7', '-1', '0', '15830.00', '50', '15880', '', '0', '2024-04-29 22:34: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', '', '50', '1', ' خصم معالجة عجز  / ', '558', '-50', '2024-04-29', '1', 'supplierPayedDeptController.php', '', '0','7', '0','1','1','50','1');
UPDATE supplier SET  suppliercurrentDebt = '-50', userid = '1', supplierdate = '2024-04-29'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '50.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '558', supplierdebtchangeafter = '-50.00', supplierdebtchangedate = '2024-04-29 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '7',currencyId='1',conversionFactor='1',payedInCurrency='50',saveConversionFactor='1' WHERE supplierdebtchangeid = '933';
UPDATE save SET  savecurrentvalue = '15880',  userid = '1' WHERE saveid = '7';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('15830.00','50', '0', '7', 'تسوية خزنة بالإضافة', '-1', '15880', '2024-04-29 22:34:04', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '27898' WHERE savedailyid = '27898';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '50', '50', '2024-04-29', '1', '0', '0', '2024-04-29 22:34:04','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10149', '141', '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 = '-2020187', theOrder = '0', layingOrder = '',reportid = '2' WHERE id = '141';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10149', '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 = '-130590', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:04:04";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:34:04", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 22:34:04', '1', 'sucess', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:04:06";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:34:06", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 22:34:06', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:04:14";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:34:14", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('transfermoneyController.php', '2024-04-29 22:34:14', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:05:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:35:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:35:35', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:05:36";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:35:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:35:36', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:05:51";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:35:51", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:35:51', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:07:09";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:37:09", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 22:37:09', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:17:01";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:47:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 22:47:01', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:17:01";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:47:01", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 22:47:01', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:17:42";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:47:42", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 22:47:43', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:17:43";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:47:43", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 22:47:43', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:26:12";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:56:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 22:56:12', '1', 'add', '156.210.121.48', '', 'DESKTOP');
BEGIN;
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('9014جديد','','1','350','350', '400','360', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '350','350','350','350','350','0','0','2.86','14.29','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '9014جديد', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '350', productSellUnitPrice = '400', productSellHalfPrice = '360', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01716',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1716';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1716', '1', '2024-04-29', '1', '0','0171601','350','360','400','350');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1716', '1', '17', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1716', '1', '17', '0', '1716', 'إضافة منتج', 'productController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1716, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1716, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5950', '5950', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 9014جديد الكمية 17','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10150', '19', '5950', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18790175.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10150', '7', '5950', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19548456.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '9014جديد', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '400.00', productSellHalfPrice = '360.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01716',type ='0', expireDate = '0' , dailyentryId = '10150',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1716';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('فسكوز66جديد','','1','260','260', '300','270', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '260','260','260','260','260','0','0','3.85','15.38','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1717';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1717', '1', '2024-04-29', '1', '0','0171701','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1717', '1', '24', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1717', '1', '24', '0', '1717', 'إضافة منتج', 'productController.php', '0', '24', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1717, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1717, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '6240', '6240', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج فسكوز66جديد الكمية 24','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10151', '19', '6240', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18796415.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10151', '7', '6240', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19554696.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'فسكوز66جديد', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01717',type ='0', expireDate = '0' , dailyentryId = '10151',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1717';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('كتان4جديد','','1','260','260', '300','270', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '260','260','260','260','260','0','0','3.85','15.38','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'كتان4جديد', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01718',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1718';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1718', '1', '2024-04-29', '1', '0','0171801','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1718', '1', '17', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '1', '17', '0', '1718', 'إضافة منتج', 'productController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1718, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1718, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4420', '4420', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج كتان4جديد الكمية 17','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10152', '19', '4420', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18800835.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10152', '7', '4420', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19559116.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'كتان4جديد', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01718',type ='0', expireDate = '0' , dailyentryId = '10152',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1718';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('33جديدcy','','1','270','270', '310','280', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '270','270','270','270','270','0','0','3.7','14.81','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '270', productSellAllPrice = '270', productSellUnitPrice = '310', productSellHalfPrice = '280', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.7' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1719';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1719', '1', '2024-04-29', '1', '0','0171901','270','280','310','270');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1719', '1', '15', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1719', '1', '15', '0', '1719', 'إضافة منتج', 'productController.php', '0', '15', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1719, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1719, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '4050', '4050', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 33جديدcy الكمية 15','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10153', '19', '4050', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18804885.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10153', '7', '4050', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19563166.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '33جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270.00', productSellUnitPrice = '310.00', productSellHalfPrice = '280.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01719',type ='0', expireDate = '0' , dailyentryId = '10153',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.7' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1719';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('6009جديد','','1','270','270', '310','280', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '270','270','270','270','270','0','0','3.7','14.81','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '6009جديد', productDescription = '', productCatId = '1', productBuyPrice = '270', productSellAllPrice = '270', productSellUnitPrice = '310', productSellHalfPrice = '280', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01720',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.7' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1720';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1720', '1', '2024-04-29', '1', '0','0172001','270','280','310','270');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1720', '1', '29', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '1', '29', '0', '1720', 'إضافة منتج', 'productController.php', '0', '29', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1720, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1720, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '7830', '7830', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 6009جديد الكمية 29','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10154', '19', '7830', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18812715.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10154', '7', '7830', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19570996.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '6009جديد', productDescription = '', productCatId = '1', productBuyPrice = '270.00', productSellAllPrice = '270.00', productSellUnitPrice = '310.00', productSellHalfPrice = '280.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01720',type ='0', expireDate = '0' , dailyentryId = '10154',isService = '0',isOptic = '0',lastbuyprice = '270',lastbuyprice_withDiscount = '270',meanbuyprice = '270',meanbuyprice_withDiscount = '270' , productbuypricereal = '270' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.7' , buypart_precentage = '14.81',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1720';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('ص30جديد','','1','350','350', '400','360', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '350','350','350','350','350','0','0','2.86','14.29','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'ص30جديد', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '350', productSellUnitPrice = '400', productSellHalfPrice = '360', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01721',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1721';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1721', '1', '2024-04-29', '1', '0','0172101','350','360','400','350');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1721', '1', '84', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '1', '84', '0', '1721', 'إضافة منتج', 'productController.php', '0', '84', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1721, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1721, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '29400', '29400', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج ص30جديد الكمية 84','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10155', '19', '29400', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18842115.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10155', '7', '29400', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19600396.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'ص30جديد', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '400.00', productSellHalfPrice = '360.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01721',type ='0', expireDate = '0' , dailyentryId = '10155',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1721';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('ص31جديد','','1','350','350', '400','360', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '350','350','350','350','350','0','0','2.86','14.29','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'ص31جديد', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '350', productSellUnitPrice = '400', productSellHalfPrice = '360', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01722',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1722';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1722', '1', '2024-04-29', '1', '0','0172201','350','360','400','350');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1722', '1', '78', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '1', '78', '0', '1722', 'إضافة منتج', 'productController.php', '0', '78', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1722, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1722, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '27300', '27300', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج ص31جديد الكمية 78','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10156', '19', '27300', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18869415.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10156', '7', '27300', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19627696.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'ص31جديد', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '400.00', productSellHalfPrice = '360.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01722',type ='0', expireDate = '0' , dailyentryId = '10156',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1722';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('ص28جديد','','1','450','450', '500','460', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '450','450','450','450','450','0','0','2.22','11.11','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = 'ص28جديد', productDescription = '', productCatId = '1', productBuyPrice = '450', productSellAllPrice = '450', productSellUnitPrice = '500', productSellHalfPrice = '460', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01723',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1723';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1723', '1', '2024-04-29', '1', '0','0172301','450','460','500','450');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1723', '1', '64', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '1', '64', '0', '1723', 'إضافة منتج', 'productController.php', '0', '64', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1723, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1723, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '28800', '28800', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج ص28جديد الكمية 64','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10157', '19', '28800', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18898215.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10157', '7', '28800', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19656496.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = 'ص28جديد', productDescription = '', productCatId = '1', productBuyPrice = '450.00', productSellAllPrice = '450.00', productSellUnitPrice = '500.00', productSellHalfPrice = '460.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01723',type ='0', expireDate = '0' , dailyentryId = '10157',isService = '0',isOptic = '0',lastbuyprice = '450',lastbuyprice_withDiscount = '450',meanbuyprice = '450',meanbuyprice_withDiscount = '450' , productbuypricereal = '450' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.22' , buypart_precentage = '11.11',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1723';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('9015جديد','','1','350','350', '400','360', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '350','350','350','350','350','0','0','2.86','14.29','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '9015جديد', productDescription = '', productCatId = '1', productBuyPrice = '350', productSellAllPrice = '350', productSellUnitPrice = '400', productSellHalfPrice = '360', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01724',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1724';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1724', '1', '2024-04-29', '1', '0','0172401','350','360','400','350');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1724', '1', '17', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1724', '1', '17', '0', '1724', 'إضافة منتج', 'productController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1724, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1724, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5950', '5950', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 9015جديد الكمية 17','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10158', '19', '5950', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18904165.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10158', '7', '5950', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19662446.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '9015جديد', productDescription = '', productCatId = '1', productBuyPrice = '350.00', productSellAllPrice = '350.00', productSellUnitPrice = '400.00', productSellHalfPrice = '360.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01724',type ='0', expireDate = '0' , dailyentryId = '10158',isService = '0',isOptic = '0',lastbuyprice = '350',lastbuyprice_withDiscount = '350',meanbuyprice = '350',meanbuyprice_withDiscount = '350' , productbuypricereal = '350' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '2.86' , buypart_precentage = '14.29',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1724';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('11كتان جديد','','1','260','260', '300','270', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '260','260','260','260','260','0','0','3.85','15.38','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '11كتان جديد', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01725',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1725';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1725', '1', '2024-04-29', '1', '0','0172501','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1725', '1', '20', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1725', '1', '20', '0', '1725', 'إضافة منتج', 'productController.php', '0', '20', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1725, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1725, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5200', '5200', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 11كتان جديد الكمية 20','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10159', '19', '5200', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18909365.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10159', '7', '5200', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19667646.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '11كتان جديد', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01725',type ='0', expireDate = '0' , dailyentryId = '10159',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1725';
INSERT INTO product (productName, productDescription, productCatId, productBuyPrice, productSellAllPrice, productSellUnitPrice, productSellHalfPrice, productDate, conditions, userId, limitamount, parcode,type, expireDate, dailyentryId,isService,isOptic,lastbuyprice,lastbuyprice_withDiscount,meanbuyprice,meanbuyprice_withDiscount , productbuypricereal , buypricereal_precentage , buytotal_precentage , buyhalf_precentage , buypart_precentage,logo,inMenu,obygyDetectionId,hasSizeAndColor,overAllAveragePrice,reviewType,online,updatebyuser,proExcelid,proExcelParcode,webApiId) VALUES ('10جديدcy','','1','260','260', '300','270', '2024-04-29', '0', '1', '0', '', '0', '0', '0', '0', '0', '260','260','260','260','260','0','0','3.85','15.38','.','0','0','0','0','0','','','0','0','0');
UPDATE product SET productName = '10جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '260', productSellAllPrice = '260', productSellUnitPrice = '300', productSellHalfPrice = '270', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01726',type ='0', expireDate = '0' , dailyentryId = '0',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1726';
INSERT INTO productunit (unitid, productid, productnumber, productunitdate, userid, conditions,proUnitParcode,proUnitSellAllPrice,proUnitSellHalfPrice,proUnitSellUnitPrice,proUnitBuyPrice) VALUES ('1', '1726', '1', '2024-04-29', '1', '0','0172601','260','270','300','260');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1726', '1', '21', '1', '2024-04-29');
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1726', '1', '21', '0', '1726', 'إضافة منتج', 'productController.php', '0', '21', '1', '2024-04-29','0','0');
INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES (1726, 1,'2024-04-29 22:56:13',1)
                ON DUPLICATE KEY UPDATE productid = 1726, edited = 1, sysdate = '2024-04-29 22:56:13', userid = 1;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '5460', '5460', '2024-04-29', '1', '0', '0', '2024-04-29 22:56:13','إضافة منتج 10جديدcy الكمية 21','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10160', '19', '5460', '','0');
UPDATE accountstree SET name = 'البضاعة (بضاعة أول المدة)', customName = 'البضاعة (بضاعة أول المدة)', parent = '6', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '0', mydate = '0000-00-00', itemtype2 = '1', theValue = '18914825.95', theOrder = '0', layingOrder = '121',reportid = '0' WHERE id = '19';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10160', '7', '5460', '','0');
UPDATE accountstree SET name = 'رأس المال', customName = 'رأس المال', parent = '25', itemtype = '1', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-11-23', itemtype2 = '1', theValue = '19673106.75', theOrder = '0', layingOrder = '211',reportid = '0' WHERE id = '7';
UPDATE product SET productName = '10جديدcy', productDescription = '', productCatId = '1', productBuyPrice = '260.00', productSellAllPrice = '260.00', productSellUnitPrice = '300.00', productSellHalfPrice = '270.00', productDate = '2024-04-29', conditions = '0', userId = '1', limitamount = '0', parcode = '01726',type ='0', expireDate = '0' , dailyentryId = '10160',isService = '0',isOptic = '0',lastbuyprice = '260',lastbuyprice_withDiscount = '260',meanbuyprice = '260',meanbuyprice_withDiscount = '260' , productbuypricereal = '260' , buypricereal_precentage = '0' , buytotal_precentage = '0' , buyhalf_precentage = '3.85' , buypart_precentage = '15.38',logo = '.',inMenu='0', obygyDetectionId = '0',hasSizeAndColor = '0',logo1 = '',logo2 = '',logo3 = '',logo4 = '',logo5 = '',logo6 = '',logo7 = '',reviewType =null , online = '' , updatebyuser = ''  WHERE productId = '1726';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:26:15";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:56:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('productController.php', '2024-04-29 22:56:16', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:26:19";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:56:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 22:56:20', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:26:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 22:56:20", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 22:56:20', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE userid = 7;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:36:02";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:06:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:06:02', '1', 'add', '156.210.121.48', '', '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(1969,1,5,1716,17,'2024-04-29',1,0, '' ,0,0,0,0,0,'2024-04-29 23:06:02',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6206';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1716, 0, 0
                    , 350.00, -17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2024-04-29*350.00," WHERE transferproductid = 8455;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1716', '1', '17', '1', '8455', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1716', '5', '17', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1716, 0, 0
                    , 350.00, 17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1716', '5', '17', '0', '8455', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1717', '24', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6207';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1717, 0, 0
                    , 260.00, -24, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2024-04-29*260.00," WHERE transferproductid = 8456;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1717', '1', '24', '1', '8456', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1717', '5', '24', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1717, 0, 0
                    , 260.00, 24, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1717', '5', '24', '0', '8456', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1718', '17', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6208';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1718, 0, 0
                    , 260.00, -17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2024-04-29*260.00," WHERE transferproductid = 8457;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '1', '17', '1', '8457', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1718', '5', '17', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1718, 0, 0
                    , 260.00, 17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1718', '5', '17', '0', '8457', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1719', '15', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6209';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1719, 0, 0
                    , 270.00, -15, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "15*2024-04-29*270.00," WHERE transferproductid = 8458;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1719', '1', '15', '1', '8458', 'تحويل منتجات من المخزن', 'storemovementController.php', '15.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1719', '5', '15', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1719, 0, 0
                    , 270.00, 15, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+15, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1719', '5', '15', '0', '8458', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '15', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1720', '17', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '12', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6210';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1720, 0, 0
                    , 270.00, -17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2024-04-29*270.00," WHERE transferproductid = 8459;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '1', '17', '1', '8459', 'تحويل منتجات من المخزن', 'storemovementController.php', '29.00', '12', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1720', '5', '17', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1720, 0, 0
                    , 270.00, 17, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '5', '17', '0', '8459', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1581', '30', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '31', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1581, 0, 0
                    , 450.00, -30, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-04-29*450.00," WHERE transferproductid = 8460;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '30', '1', '8460', 'تحويل منتجات من المخزن', 'storemovementController.php', '61.00', '31', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5688';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1581, 0, 0
                    , 450.00, 30, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '5', '30', '0', '8460', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '10.00', '40', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1721', '30', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '54', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6211';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1721, 0, 0
                    , 350.00, -30, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-04-29*350.00," WHERE transferproductid = 8461;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '1', '30', '1', '8461', 'تحويل منتجات من المخزن', 'storemovementController.php', '84.00', '54', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1721', '5', '30', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1721, 0, 0
                    , 350.00, 30, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '5', '30', '0', '8461', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1722', '25', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '53', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6212';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1722, 0, 0
                    , 350.00, -25, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "25*2024-04-29*350.00," WHERE transferproductid = 8462;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '1', '25', '1', '8462', 'تحويل منتجات من المخزن', 'storemovementController.php', '78.00', '53', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1722', '5', '25', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1722, 0, 0
                    , 350.00, 25, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+25, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '5', '25', '0', '8462', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '25', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '5', '1723', '24', '2024-04-29', '1', '0','1969',null,null,'2024-04-29 23:06:02',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '40', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6213';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1723, 0, 0
                    , 450.00, -24, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2024-04-29*450.00," WHERE transferproductid = 8463;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '1', '24', '1', '8463', 'تحويل منتجات من المخزن', 'storemovementController.php', '64.00', '40', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1723', '5', '24', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 5, 1723, 0, 0
                    , 450.00, 24, 0, 0, 1, '2024-04-29 23:06:02')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:06:02' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '5', '24', '0', '8463', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2024-04-29','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:36:03";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:06:03", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:06:03', '1', 'editshow', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:38:40";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:08:40", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:08:40', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:39:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:09:22", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:09:22', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:41:34";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:11:34", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:11:34', '1', 'add', '156.210.121.48', '', '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(1970,1,6,1724,17,'2024-04-29',1,0, '' ,0,0,0,0,0,'2024-04-29 23:11:34',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6214';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1724, 0, 0
                    , 350.00, -17, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "17*2024-04-29*350.00," WHERE transferproductid = 8464;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1724', '1', '17', '1', '8464', 'تحويل منتجات من المخزن', 'storemovementController.php', '17.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1724', '6', '17', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1724, 0, 0
                    , 350.00, 17, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+17, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1724', '6', '17', '0', '8464', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '17', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1720', '12', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6210';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1720, 0, 0
                    , 270.00, -12, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 270.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-04-29*270.00," WHERE transferproductid = 8465;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '1', '12', '1', '8465', 'تحويل منتجات من المخزن', 'storemovementController.php', '12.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1720', '6', '12', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1720, 0, 0
                    , 270.00, 12, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1720', '6', '12', '0', '8465', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1725', '20', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6215';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1725, 0, 0
                    , 260.00, -20, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-04-29*260.00," WHERE transferproductid = 8466;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1725', '1', '20', '1', '8466', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1725', '6', '20', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1725, 0, 0
                    , 260.00, 20, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1725', '6', '20', '0', '8466', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1726', '21', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6216';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1726, 0, 0
                    , 260.00, -21, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 260.00,
                        buyQuantity =buyQuantity+-21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "21*2024-04-29*260.00," WHERE transferproductid = 8467;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1726', '1', '21', '1', '8467', 'تحويل منتجات من المخزن', 'storemovementController.php', '21.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1726', '6', '21', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1726, 0, 0
                    , 260.00, 21, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+21, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1726', '6', '21', '0', '8467', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '21', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1581', '30', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '1', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5618';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1581, 0, 0
                    , 450.00, -30, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-04-29*450.00," WHERE transferproductid = 8468;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '1', '30', '1', '8468', 'تحويل منتجات من المخزن', 'storemovementController.php', '31.00', '1', '1', '2024-04-29','0','0');
UPDATE storedetail SET  productquantity = '46', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '5629';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1581, 0, 0
                    , 450.00, 30, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1581', '6', '30', '0', '8468', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '16.00', '46', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1721', '30', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '24', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6211';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1721, 0, 0
                    , 350.00, -30, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "30*2024-04-29*350.00," WHERE transferproductid = 8469;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '1', '30', '1', '8469', 'تحويل منتجات من المخزن', 'storemovementController.php', '54.00', '24', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1721', '6', '30', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1721, 0, 0
                    , 350.00, 30, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+30, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '6', '30', '0', '8469', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '30', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1722', '27', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '26', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6212';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1722, 0, 0
                    , 350.00, -27, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "27*2024-04-29*350.00," WHERE transferproductid = 8470;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '1', '27', '1', '8470', 'تحويل منتجات من المخزن', 'storemovementController.php', '53.00', '26', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1722', '6', '27', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1722, 0, 0
                    , 350.00, 27, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+27, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '6', '27', '0', '8470', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '27', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '6', '1723', '20', '2024-04-29', '1', '0','1970',null,null,'2024-04-29 23:11:34',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '20', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6213';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1723, 0, 0
                    , 450.00, -20, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-04-29*450.00," WHERE transferproductid = 8471;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '1', '20', '1', '8471', 'تحويل منتجات من المخزن', 'storemovementController.php', '40.00', '20', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1723', '6', '20', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 6, 1723, 0, 0
                    , 450.00, 20, 0, 0, 1, '2024-04-29 23:11:34')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:11:34' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '6', '20', '0', '8471', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-04-29','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:41:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:11:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:11:35', '1', 'editshow', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:42:57";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:12:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:12:57', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:43:16";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:13:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 23:13:16', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:43:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:13:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:13:55', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:45:13";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:15:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:15:13', '1', 'add', '156.210.121.48', '', '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(1971,1,8,1721,24,'2024-04-29',1,0, '' ,0,0,0,0,0,'2024-04-29 23:15:13',0,'',@id,@optnum);
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6211';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1721, 0, 0
                    , 350.00, -24, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "24*2024-04-29*350.00," WHERE transferproductid = 8472;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '1', '24', '1', '8472', 'تحويل منتجات من المخزن', 'storemovementController.php', '24.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1721', '8', '24', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 8, 1721, 0, 0
                    , 350.00, 24, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+24, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1721', '8', '24', '0', '8472', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '24', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '1722', '26', '2024-04-29', '1', '0','1971',null,null,'2024-04-29 23:15:13',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6212';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1722, 0, 0
                    , 350.00, -26, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyprice = 350.00,
                        buyQuantity =buyQuantity+-26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "26*2024-04-29*350.00," WHERE transferproductid = 8473;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '1', '26', '1', '8473', 'تحويل منتجات من المخزن', 'storemovementController.php', '26.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1722', '8', '26', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 8, 1722, 0, 0
                    , 350.00, 26, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+26, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1722', '8', '26', '0', '8473', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '26', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '1723', '20', '2024-04-29', '1', '0','1971',null,null,'2024-04-29 23:15:13',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6213';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1723, 0, 0
                    , 450.00, -20, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyprice = 450.00,
                        buyQuantity =buyQuantity+-20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "20*2024-04-29*450.00," WHERE transferproductid = 8474;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '1', '20', '1', '8474', 'تحويل منتجات من المخزن', 'storemovementController.php', '20.00', '0', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1723', '8', '20', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 8, 1723, 0, 0
                    , 450.00, 20, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+20, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1723', '8', '20', '0', '8474', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '20', '1', '2024-04-29','0','0');
INSERT INTO storemovement (storeidfrom, storeidto, productid, transferproductamount, transferproductdate, userid, conditions ,operationnum,driverid,drivertimeout,driverdate,delivererid,deliverdate,storetype,priceType,price,sizeid,colorid) VALUES ('1', '8', '1671', '12', '2024-04-29', '1', '0','1971',null,null,'2024-04-29 23:15:13',null,'','0','hide','0','0','0');
UPDATE storedetail SET  productquantity = '-12', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6072';
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 1, 1671, 0, 0
                    , 250.00, -12, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyprice = 250.00,
                        buyQuantity =buyQuantity+-12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
UPDATE storemovement SET  buyPricesHistoryBookData = "12*2024-04-29*250.00," WHERE transferproductid = 8475;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1671', '1', '12', '1', '8475', 'تحويل منتجات من المخزن', 'storemovementController.php', '0.00', '-12', '1', '2024-04-29','0','0');
INSERT INTO storedetail (productid, storeid, productquantity, userid, storedetaildate) VALUES ('1671', '8', '12', '1', '2024-04-29');
INSERT INTO buypriceshistorybook (theDate, storeId, productid, sizeid, colorid, buyprice, buyQuantity, sellQuantity, del, userid, sysDate)
                    VALUES ('2024-04-29', 8, 1671, 0, 0
                    , 250.00, 12, 0, 0, 1, '2024-04-29 23:15:13')
                ON DUPLICATE KEY UPDATE buyQuantity =buyQuantity+12, sellQuantity = sellQuantity+0,
                        del = 0,userid = 1,sysDate = '2024-04-29 23:15:13' ;
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1671', '8', '12', '0', '8475', 'تحويل منتجات إلى المخزن', 'storemovementController.php', '0', '12', '1', '2024-04-29','0','0');
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:45:13";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:15:13", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storemovementController.php', '2024-04-29 23:15:14', '1', 'editshow', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:46:48";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:16:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 23:16:48', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:47:12";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:17:12", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 23:17:12', '1', 'add', '156.210.121.48', '', 'DESKTOP');
UPDATE storedetail SET  productquantity = '0', userid = '1', storedetaildate = '2024-04-29' WHERE storedetailid = '6072';
INSERT INTO storereport (productid, storeid, productquantity, storereporttype, storereportmodelid, processname, tablename, productbefore, productafter, userid, storereportdate,sizeid,colorid) VALUES ('1671', '1', '12', '0', '-1', 'تم إعادة جرد المنتج بالقيمة الحالية بالزيادة', 'inventoryController.php', '-12.00', '0', '1', '2024-04-29','0','0');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:47:14";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:17:15", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 23:17:15', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 19:47:55";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:17:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('sellbillController.php', '2024-04-29 23:17:55', '1', 'addsellBill', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:00:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:30:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:30:31', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:00:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:30:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:30:31', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:01:02";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:31:02", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:31:02', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:01:16";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:31:16", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('inventoryController.php', '2024-04-29 23:31:16', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:01:41";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:31:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:31:41', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:01:41";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:31:41", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:31:42', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:01:57";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:31:57", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:31:57', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:09:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:39:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:39:31', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:09:31";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:39:31", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:39:31', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:12:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:42:54", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:42:54', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:13:07";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:43:07", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('savedailyController.php', '2024-04-29 23:43:07', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:14:48";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:44:48", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 23:44:48', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:15:20";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:45:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 23:45:21', '1', 'add', '156.210.121.48', '', 'DESKTOP');
INSERT INTO impotencetreatmentsuppliersave (typesimpotencetreatmentid, saveid, supplierid, impotencetreatmentsuppliersavetype, impotencetreatmentsuppliersavebefore, impotencetreatmentsuppliersavetamount, impotencetreatmentsuppliersaveafter, impotencetreatmentsuppliersavecomment, conditions, impotencetreatmentsuppliersavedate, userid, tablename) VALUES ('-1', '5', '-1', '0', '19355.00', '645', '20000', '', '0', '2024-04-29 23:45:21', '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', '', '645', '1', ' خصم معالجة عجز  / ', '559', '-645', '2024-04-29', '1', 'supplierPayedDeptController.php', '', '0','5', '0','1','1','645','1');
UPDATE supplier SET  suppliercurrentDebt = '-645', userid = '1', supplierdate = '2024-04-29'   WHERE supplierid = '-1';
UPDATE supplierdebtchange SET supplierid = '-1', supplierdebtchangebefore = '0.00', supplierdebtchangeamount = '645.00', supplierdebtchangetype = '1', processname = ' خصم معالجة عجز  / ', supplierdebtchangemodelid = '559', supplierdebtchangeafter = '-645.00', supplierdebtchangedate = '2024-04-29 00:00:00', userid = '1', tablename = 'supplierPayedDeptController.php', comment = '', dailyentryid = '0',saveid = '5',currencyId='1',conversionFactor='1',payedInCurrency='645',saveConversionFactor='1' WHERE supplierdebtchangeid = '934';
UPDATE save SET  savecurrentvalue = '20000',  userid = '1' WHERE saveid = '5';
INSERT INTO savedaily (savedailysavebefore, savedailychangeamount, savedailychangetype, saveid, processname, savedailymodelid, savedailysaveafter, savedailydate, userid, tablename,clientid ,note) VALUES ('19355.00','645', '0', '5', 'تسوية خزنة بالإضافة', '-1', '20000', '2024-04-29 23:45:21', '1',  'settlementsaveController.php','0','');
UPDATE savedaily SET  savedailymodelid = '27899' WHERE savedailyid = '27899';
BEGIN;
INSERT INTO dailyentry (totalcreditor, totaldebtor, thedate, userid, `condition`, reverseofid, dDateTime,entryComment,fromFlag,related,branchid) VALUES ( '645', '645', '2024-04-29', '1', '0', '0', '2024-04-29 23:45:21','اضافة معالجة عجز ( بالاضافة )','1','0','0');
INSERT INTO dailyentrydebtor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10161', '139', '645', '','0');
UPDATE accountstree SET name = 'خزينة محل عبدالله', customName = 'خزينة محل عبدالله', parent = '20', itemtype = '3', itemfrom = '0', notes = '', del = '0', userid = '1', mydate = '2022-07-06', itemtype2 = '1', theValue = '-3039888', theOrder = '0', layingOrder = '',reportid = '0' WHERE id = '139';
INSERT INTO dailyentrycreditor (dailyentryid, accountstreeid, value, dComment,costcenterid) VALUES ('10161', '27', '645', '','0');
UPDATE accountstree SET name = 'معالجة عجز خزنة', customName = 'معالجة عجز خزنة', parent = '3', itemtype = '0', itemfrom = '0', notes = '', del = '0', userid = '2', mydate = '2016-06-15', itemtype2 = '1', theValue = '-131235', theOrder = '0', layingOrder = '35',reportid = '1' WHERE id = '27';
COMMIT;
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:15:21";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:45:21", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 23:45:21', '1', 'sucess', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:15:23";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:45:23", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('settlementsaveController.php', '2024-04-29 23:45:23', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:15:38";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:45:38", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:45:38', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:15:54";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:45:55", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:45:55', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:22:36";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:52:36", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:52:36', '1', 'show', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:28:35";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:58:35", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:58:35', '1', '', '156.210.121.48', '', 'DESKTOP');
UPDATE user SET loginip = "" WHERE lastactivetime < "2024-04-29 20:29:53";
UPDATE user SET loginip = "156.210.121.48", lastactivetime = "2024-04-29 23:59:53", deviceType = "DESKTOP" WHERE userid = 1;
INSERT INTO movementmanage (operationname, movementmanagedate, userid, currentDo, ip, mac, deviceType) VALUES ('storedetailController.php', '2024-04-29 23:59:54', '1', 'show', '156.210.121.48', '', 'DESKTOP');
